Skip to content

Commit

Permalink
DescriptorSet renamed to DescriptorGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos-lg committed Jul 31, 2024
1 parent 63d3ff7 commit 8c71820
Show file tree
Hide file tree
Showing 20 changed files with 255 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class TestCaseDatabaseInitializer implements BeforeEachCallback {
"institution_collection_contact",
"collection_collection_contact",
"collections_batch",
"collection_descriptor_set",
"collection_descriptor_group",
"collection_descriptor",
"collection_descriptor_verbatim");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import org.gbif.api.model.collections.Collection;
import org.gbif.api.model.collections.CollectionImportParams;
import org.gbif.api.model.collections.descriptors.Descriptor;
import org.gbif.api.model.collections.descriptors.DescriptorSet;
import org.gbif.api.model.collections.descriptors.DescriptorGroup;
import org.gbif.api.model.collections.latimercore.ObjectGroup;
import org.gbif.api.model.collections.request.CollectionSearchRequest;
import org.gbif.api.model.collections.request.DescriptorSearchRequest;
import org.gbif.api.model.collections.request.DescriptorSetSearchRequest;
import org.gbif.api.model.collections.request.DescriptorGroupSearchRequest;
import org.gbif.api.model.collections.suggestions.CollectionChangeSuggestion;
import org.gbif.api.model.collections.suggestions.Type;
import org.gbif.api.model.collections.view.CollectionView;
Expand Down Expand Up @@ -238,8 +238,8 @@ public void createFromDatasetTest() {

@SneakyThrows
@Test
public void createDescriptorSetTest() {
when(descriptorsService.createDescriptorSet(any(), any(), any(), any(), any())).thenReturn(1L);
public void createDescriptorGroupTest() {
when(descriptorsService.createDescriptorGroup(any(), any(), any(), any(), any())).thenReturn(1L);

Resource descriptorsResource = new ClassPathResource("collections/descriptors.csv");
MultipartFile descriptorsFile =
Expand All @@ -248,22 +248,22 @@ public void createDescriptorSetTest() {
assertEquals(
1L,
getClient()
.createDescriptorSet(
.createDescriptorGroup(
UUID.randomUUID(), ExportFormat.CSV, descriptorsFile, "title", "desc"));
}

@SneakyThrows
@Test
public void updateDescriptorSetTest() {
public void updateDescriptorGroupTest() {
UUID collectionKey = UUID.randomUUID();
DescriptorSet descriptorSet = new DescriptorSet();
descriptorSet.setCollectionKey(collectionKey);
descriptorSet.setTitle("title");
DescriptorGroup descriptorGroup = new DescriptorGroup();
descriptorGroup.setCollectionKey(collectionKey);
descriptorGroup.setTitle("title");

when(descriptorsService.getDescriptorSet(anyLong())).thenReturn(descriptorSet);
when(descriptorsService.getDescriptorGroup(anyLong())).thenReturn(descriptorGroup);
doNothing()
.when(descriptorsService)
.updateDescriptorSet(anyLong(), any(), any(), anyString(), anyString());
.updateDescriptorGroup(anyLong(), any(), any(), anyString(), anyString());

Resource descriptorsResource = new ClassPathResource("collections/descriptors.csv");
MultipartFile descriptorsFile =
Expand All @@ -272,47 +272,47 @@ public void updateDescriptorSetTest() {
assertDoesNotThrow(
() ->
getClient()
.updateDescriptorSet(
.updateDescriptorGroup(
collectionKey, 1L, ExportFormat.CSV, descriptorsFile, "title", "desc"));
}

@Test
public void getDescriptorSetTest() {
public void getDescriptorGroupTest() {
UUID collectionKey = UUID.randomUUID();
DescriptorSet descriptorSet = new DescriptorSet();
descriptorSet.setCollectionKey(collectionKey);
descriptorSet.setTitle("title");
DescriptorGroup descriptorGroup = new DescriptorGroup();
descriptorGroup.setCollectionKey(collectionKey);
descriptorGroup.setTitle("title");

when(resourceNotFoundService.entityExists(any(), any())).thenReturn(true);
when(descriptorsService.getDescriptorSet(1L)).thenReturn(descriptorSet);
when(descriptorsService.getDescriptorGroup(1L)).thenReturn(descriptorGroup);

assertEquals(descriptorSet, getClient().getCollectionDescriptorSet(collectionKey, 1L));
assertEquals(descriptorGroup, getClient().getCollectionDescriptorGroup(collectionKey, 1L));
}

@Test
public void listDescriptorSetTest() {
DescriptorSet descriptorSet = new DescriptorSet();
descriptorSet.setCollectionKey(UUID.randomUUID());
descriptorSet.setTitle("title");
public void listDescriptorGroupTest() {
DescriptorGroup descriptorGroup = new DescriptorGroup();
descriptorGroup.setCollectionKey(UUID.randomUUID());
descriptorGroup.setTitle("title");

when(resourceNotFoundService.entityExists(any(), any())).thenReturn(true);
when(descriptorsService.listDescriptorSets(
any(UUID.class), any(DescriptorSetSearchRequest.class)))
.thenReturn(new PagingResponse<>(0, 10, 1L, Collections.singletonList(descriptorSet)));
when(descriptorsService.listDescriptorGroups(
any(UUID.class), any(DescriptorGroupSearchRequest.class)))
.thenReturn(new PagingResponse<>(0, 10, 1L, Collections.singletonList(descriptorGroup)));

assertEquals(
1,
getClient()
.listCollectionDescriptorSets(
UUID.randomUUID(), DescriptorSetSearchRequest.builder().query("foo").build())
.listCollectionDescriptorGroups(
UUID.randomUUID(), DescriptorGroupSearchRequest.builder().query("foo").build())
.getResults()
.size());
}

@Test
public void listDescriptorsTest() {
Descriptor descriptor = new Descriptor();
descriptor.setDescriptorSetKey(1L);
descriptor.setDescriptorGroupKey(1L);
descriptor.setUsageRank(Rank.ABERRATION);
descriptor.setCountry(Country.SPAIN);

Expand All @@ -335,17 +335,17 @@ public void listDescriptorsTest() {
public void getDescriptorTest() {
UUID collectionKey = UUID.randomUUID();
Descriptor descriptor = new Descriptor();
descriptor.setDescriptorSetKey(1L);
descriptor.setDescriptorGroupKey(1L);
descriptor.setUsageRank(Rank.ABERRATION);
descriptor.setCountry(Country.SPAIN);

DescriptorSet descriptorSet = new DescriptorSet();
descriptorSet.setCollectionKey(collectionKey);
descriptorSet.setTitle("title");
DescriptorGroup descriptorGroup = new DescriptorGroup();
descriptorGroup.setCollectionKey(collectionKey);
descriptorGroup.setTitle("title");

when(resourceNotFoundService.entityExists(any(), any())).thenReturn(true);
when(descriptorsService.getDescriptor(anyLong())).thenReturn(descriptor);
when(descriptorsService.getDescriptorSet(anyLong())).thenReturn(descriptorSet);
when(descriptorsService.getDescriptorGroup(anyLong())).thenReturn(descriptorGroup);

assertEquals(descriptor, getClient().getCollectionDescriptor(collectionKey, 1L, 1L));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ public void loadData() {
c1.setDisplayOnNHCPortal(false);
collectionService.create(c1);

descriptorsService.createDescriptorSet(
descriptorsService.createDescriptorGroup(
StreamUtils.copyToByteArray(
new ClassPathResource("collections/descriptors.csv").getInputStream()),
ExportFormat.TSV,
"My personal descriptor set",
"description",
c1.getKey());

descriptorsService.createDescriptorSet(
descriptorsService.createDescriptorGroup(
StreamUtils.copyToByteArray(
new ClassPathResource("collections/descriptors2.csv").getInputStream()),
ExportFormat.TSV,
Expand All @@ -145,7 +145,7 @@ public void loadData() {
c2.getIdentifiers().add(new Identifier(IdentifierType.LSID, "lsid-coll"));
collectionService.create(c2);

descriptorsService.createDescriptorSet(
descriptorsService.createDescriptorGroup(
StreamUtils.copyToByteArray(
new ClassPathResource("collections/descriptors3.csv").getInputStream()),
ExportFormat.TSV,
Expand Down Expand Up @@ -458,7 +458,7 @@ public void searchCollectionsTest() {
assertEquals(1, result.getResults().size());
assertEquals(c1.getKey(), result.getResults().get(0).getKey());
assertEquals(
"descriptorSet.title",
"descriptorGroup.title",
result.getResults().get(0).getHighlights().iterator().next().getField());
assertTrue(result.getResults().get(0).getDescriptorMatches().isEmpty());

Expand All @@ -468,7 +468,7 @@ public void searchCollectionsTest() {
assertEquals(1, result.getResults().size());
assertEquals(c2.getKey(), result.getResults().get(0).getKey());
assertEquals(
"descriptorSet.description",
"descriptorGroup.description",
result.getResults().get(0).getHighlights().iterator().next().getField());
assertTrue(result.getResults().get(0).getDescriptorMatches().isEmpty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.gbif.api.model.collections.Collection;
import org.gbif.api.model.collections.descriptors.Descriptor;
import org.gbif.api.model.collections.request.DescriptorSearchRequest;
import org.gbif.api.model.collections.request.DescriptorSetSearchRequest;
import org.gbif.api.model.collections.request.DescriptorGroupSearchRequest;
import org.gbif.api.model.common.export.ExportFormat;
import org.gbif.api.model.common.paging.PagingResponse;
import org.gbif.api.service.collections.CollectionService;
Expand Down Expand Up @@ -64,19 +64,19 @@ public void descriptorsTest() {
collectionService.create(collection);

Resource descriptorsFile = new ClassPathResource("collections/descriptors.csv");
long descriptorSetKey =
descriptorsService.createDescriptorSet(
long DescriptorGroupKey =
descriptorsService.createDescriptorGroup(
StreamUtils.copyToByteArray(descriptorsFile.getInputStream()),
ExportFormat.TSV,
"My descriptor set",
"description",
collection.getKey());
assertTrue(descriptorSetKey > 0);
assertTrue(DescriptorGroupKey > 0);

assertEquals(
1,
descriptorsService
.listDescriptorSets(collection.getKey(), DescriptorSetSearchRequest.builder().build())
.listDescriptorGroups(collection.getKey(), DescriptorGroupSearchRequest.builder().build())
.getResults()
.size());

Expand Down Expand Up @@ -119,8 +119,8 @@ public void descriptorsTest() {
.size());

Resource descriptorsFile2 = new ClassPathResource("collections/descriptors2.csv");
descriptorsService.updateDescriptorSet(
descriptorSetKey,
descriptorsService.updateDescriptorGroup(
DescriptorGroupKey,
StreamUtils.copyToByteArray(descriptorsFile2.getInputStream()),
ExportFormat.TSV,
"My descriptor set",
Expand All @@ -130,14 +130,14 @@ public void descriptorsTest() {
assertEquals(4, descriptors.getResults().size());
assertTrue(descriptors.getResults().stream().allMatch(r -> r.getVerbatim().size() == 3));

descriptorsService.deleteDescriptorSet(descriptorSetKey);
descriptorsService.deleteDescriptorGroup(DescriptorGroupKey);
assertEquals(
0,
descriptorsService.listDescriptors(DescriptorSearchRequest.builder().build()).getCount());
assertEquals(
0,
descriptorsService
.listDescriptorSets(collection.getKey(), DescriptorSetSearchRequest.builder().build())
.listDescriptorGroups(collection.getKey(), DescriptorGroupSearchRequest.builder().build())
.getCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.gbif.api.model.collections.Address;
import org.gbif.api.model.collections.AlternativeCode;
import org.gbif.api.model.collections.Collection;
import org.gbif.api.model.collections.descriptors.DescriptorSet;
import org.gbif.api.model.collections.descriptors.DescriptorGroup;
import org.gbif.api.vocabulary.Country;
import org.gbif.api.vocabulary.License;
import org.gbif.registry.database.TestCaseDatabaseInitializer;
Expand Down Expand Up @@ -123,15 +123,15 @@ public void searchTest() {

collectionMapper.create(collection);

DescriptorSet descriptorSet = new DescriptorSet();
descriptorSet.setCollectionKey(collectionKey);
descriptorSet.setTitle("title");
descriptorSet.setCreatedBy("test");
descriptorSet.setModifiedBy("test");
descriptorsMapper.createDescriptorSet(descriptorSet);
DescriptorGroup DescriptorGroup = new DescriptorGroup();
DescriptorGroup.setCollectionKey(collectionKey);
DescriptorGroup.setTitle("title");
DescriptorGroup.setCreatedBy("test");
DescriptorGroup.setModifiedBy("test");
descriptorsMapper.createDescriptorGroup(DescriptorGroup);

DescriptorDto descriptorDto = new DescriptorDto();
descriptorDto.setDescriptorSetKey(descriptorSet.getKey());
descriptorDto.setDescriptorGroupKey(DescriptorGroup.getKey());
descriptorDto.setUsageName("aves");
descriptorDto.setCountry(Country.SPAIN);
descriptorsMapper.createDescriptor(descriptorDto);
Expand Down
Loading

0 comments on commit 8c71820

Please sign in to comment.