Skip to content

Commit

Permalink
# Conflicts:
Browse files Browse the repository at this point in the history
#	pom.xml
#	registry-persistence/src/main/java/org/gbif/registry/persistence/mapper/collections/dto/SearchDto.java
#	registry-persistence/src/main/java/org/gbif/registry/persistence/mapper/collections/params/SearchParams.java
#	registry-persistence/src/main/resources/liquibase/137-featured-image-attribution-grscicoll.xml
#	registry-persistence/src/main/resources/liquibase/138-dataset-occurrence-download-created-index.xml
#	registry-persistence/src/main/resources/liquibase/139-dataset-occurrence-download-created-index.xml
#	registry-persistence/src/main/resources/liquibase/master.xml
#	registry-search/src/main/java/org/gbif/registry/search/dataset/service/collections/CollectionsSearchService.java
#	registry-ws/src/main/java/org/gbif/registry/ws/export/CsvWriter.java
  • Loading branch information
marcos-lg committed Aug 16, 2024
1 parent 7b4b19e commit 85d7f86
Show file tree
Hide file tree
Showing 92 changed files with 5,954 additions and 984 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@
<spring-cloud-sleuth.version>2.2.8.RELEASE</spring-cloud-sleuth.version>

<!-- GBIF -->
<gbif-api.version>1.16.5</gbif-api.version>
<gbif-api.version>1.16.7</gbif-api.version>
<gbif-common.version>0.59</gbif-common.version>
<gbif-common-mybatis.version>1.3</gbif-common-mybatis.version>
<gbif-common-mybatis.version>1.4</gbif-common-mybatis.version>
<gbif-common-ws.version>1.26</gbif-common-ws.version>
<gbif-directory.version>1.13</gbif-directory.version>
<gbif-doi.version>2.17</gbif-doi.version>
<gbif-download-query-tools.version>1.51.0</gbif-download-query-tools.version>
<gbif-httputils.version>0.10</gbif-httputils.version>
<gbif-metadata-profile.version>2.2</gbif-metadata-profile.version>
<gbif-parsers.version>0.60</gbif-parsers.version>
<gbif-parsers.version>0.67</gbif-parsers.version>
<gbif-postal-service.version>1.8.0</gbif-postal-service.version>
<xoai.version>4.1.0-gbif-4</xoai.version>
<gbif-occurrence.version>0.195.1</gbif-occurrence.version>
<gbif-vocabulary.version>1.0.5</gbif-vocabulary.version>
<checklistbank.version>2.125</checklistbank.version>
<checklistbank.version>2.128</checklistbank.version>

<!-- Third party -->
<commons-digester.version>3.2</commons-digester.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
*/
package org.gbif.registry.events.collections;

import org.gbif.api.model.collections.CollectionEntity;

import java.util.UUID;

import com.google.common.base.Preconditions;
import java.util.UUID;
import org.gbif.api.model.collections.CollectionEntity;

/**
* This event is fired after collection entity components such as contacts, identifiers or tags have
Expand Down Expand Up @@ -66,6 +64,22 @@ public static <T extends CollectionEntity, R> SubEntityCollectionEvent<T, R> new
eventType);
}

public static <T extends CollectionEntity, R> SubEntityCollectionEvent<T, R> newInstance(
UUID collectionEntityKey,
Class<T> collectionEntityClass,
Class<R> subEntity,
long subEntityKey,
EventType eventType) {
return new SubEntityCollectionEvent<>(
collectionEntityKey,
collectionEntityClass,
subEntity,
null,
null,
String.valueOf(subEntityKey),
eventType);
}

public static <T extends CollectionEntity, R> SubEntityCollectionEvent<T, R> newInstance(
UUID collectionEntityKey,
Class<T> collectionEntityClass,
Expand Down
7 changes: 7 additions & 0 deletions registry-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@
*/
package org.gbif.registry.database;

import org.gbif.registry.ws.it.fixtures.TestConstants;

import java.sql.SQLException;
import java.time.Duration;

import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.Wait;

import liquibase.Contexts;
import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.LiquibaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import org.gbif.registry.ws.it.fixtures.TestConstants;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.Wait;

public class BaseDBTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@
*/
package org.gbif.registry.database;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.sql.DataSource;

import com.google.common.base.Throwables;
import lombok.Data;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import com.google.common.base.Throwables;

import lombok.Data;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* A Rule that will truncate the tables ready for a new test. It is expected to do this before each
Expand Down Expand Up @@ -106,7 +103,10 @@ public class TestCaseDatabaseInitializer implements BeforeEachCallback {
"collection_contact",
"institution_collection_contact",
"collection_collection_contact",
"collections_batch");
"collections_batch",
"collection_descriptor_group",
"collection_descriptor",
"collection_descriptor_verbatim");

public TestCaseDatabaseInitializer() {}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.gbif.registry.test.mocks;

import java.util.Arrays;
import org.gbif.api.model.checklistbank.NameUsageMatch;
import org.gbif.api.model.common.LinneanClassification;
import org.gbif.api.v2.NameUsageMatch2;
import org.gbif.api.v2.RankedName;
import org.gbif.api.vocabulary.Rank;
import org.gbif.checklistbank.ws.client.NubResourceClient;

public class NubResourceClientMock implements NubResourceClient {

public static final RankedName DEFAULT_USAGE = new RankedName(100, "usage", Rank.SPECIES);
public static final RankedName DEFAULT_HIGHEST_USAGE =
new RankedName(1, "superHigherUsage", Rank.KINGDOM);

@Override
public NameUsageMatch match(
String s,
String s1,
String s2,
String s3,
String s4,
String s5,
String s6,
String s7,
LinneanClassification linneanClassification,
Boolean aBoolean,
Boolean aBoolean1) {
return null;
}

@Override
public NameUsageMatch2 match2(
String scientificName2,
String scientificName,
String authorship2,
String authorship,
String rank2,
String rank,
String genericName,
String specificEpithet,
String infraspecificEpithet,
LinneanClassification classification,
Boolean strict,
Boolean verbose) {

if ("Aves".equalsIgnoreCase(scientificName)) {
NameUsageMatch2 nameUsageMatch2 = new NameUsageMatch2();
nameUsageMatch2.setUsage(new RankedName(212, "Aves", Rank.CLASS));
nameUsageMatch2.setClassification(
Arrays.asList(
new RankedName(1, "Animalia", Rank.KINGDOM),
new RankedName(44, "Chordata", Rank.PHYLUM),
new RankedName(212, "Aves", Rank.CLASS)));
NameUsageMatch2.Diagnostics diagnostics = new NameUsageMatch2.Diagnostics();
diagnostics.setMatchType(NameUsageMatch.MatchType.EXACT);
nameUsageMatch2.setDiagnostics(diagnostics);
return nameUsageMatch2;
}

NameUsageMatch2 nameUsageMatch2 = new NameUsageMatch2();
nameUsageMatch2.setUsage(DEFAULT_USAGE);

nameUsageMatch2.setClassification(
Arrays.asList(new RankedName(50, "higherUsage", Rank.GENUS), DEFAULT_HIGHEST_USAGE));

return nameUsageMatch2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
package org.gbif.registry.ws.it;

import java.math.BigDecimal;

import org.gbif.api.model.common.paging.PagingRequest;
import org.gbif.api.model.common.paging.PagingResponse;
import org.gbif.api.model.registry.Dataset;
Expand Down Expand Up @@ -44,9 +46,13 @@
import javax.annotation.Nullable;

import org.apache.commons.beanutils.BeanUtils;
import org.geojson.Feature;
import org.geojson.FeatureCollection;
import org.geojson.Point;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.locationtech.jts.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.server.LocalServerPort;

Expand Down Expand Up @@ -266,6 +272,34 @@ public void testList(ServiceType serviceType) {
assertResultsOfSize(service.listDeleted(searchParams), 1);
}

@ParameterizedTest
@EnumSource(ServiceType.class)
public void testListPublishersAsGeoJson(ServiceType serviceType) {
OrganizationService service = (OrganizationService) getService(serviceType);

Node node = testDataFactory.newNode();
UUID nodeKey = nodeResource.create(node);

Organization o1 = testDataFactory.newOrganization(nodeKey);
o1.setTitle("n1");
o1.setEndorsementApproved(true);
o1.setLatitude(BigDecimal.valueOf(50d));
o1.setLongitude(BigDecimal.valueOf(12d));

UUID key1 = getService(serviceType).create(o1);

FeatureCollection expectedFeatureCollection = new FeatureCollection();
Feature f1 = new Feature();
f1.setGeometry(new Point(12d, 50d));
f1.setProperty("organization", "n1");
f1.setProperty("key", key1.toString());
expectedFeatureCollection.add(f1);

OrganizationRequestSearchParams searchParams = new OrganizationRequestSearchParams();
FeatureCollection result = service.listGeoJson(searchParams);
Assert.equals(expectedFeatureCollection.getFeatures().size(),result.getFeatures().size());
}

private void createOrgs(UUID nodeKey, ServiceType serviceType, Country... countries) {
OrganizationService service = (OrganizationService) getService(serviceType);
for (Country c : countries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
package org.gbif.registry.ws.it;

import com.zaxxer.hikari.HikariDataSource;
import java.util.Collections;
import java.util.Date;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.ConvertUtilsBean;
import org.apache.commons.beanutils.converters.DateConverter;
import org.apache.commons.beanutils.converters.DateTimeConverter;
import org.gbif.api.vocabulary.UserRole;
import org.gbif.checklistbank.ws.client.NubResourceClient;
import org.gbif.registry.doi.config.TitleLookupConfiguration;
import org.gbif.registry.events.config.VarnishPurgeConfiguration;
import org.gbif.registry.mail.EmailSenderImpl;
Expand All @@ -29,6 +32,7 @@
import org.gbif.registry.search.dataset.indexing.ws.GbifWsClient;
import org.gbif.registry.surety.OrganizationEmailTemplateManagerIT;
import org.gbif.registry.test.mocks.ConceptClientMock;
import org.gbif.registry.test.mocks.NubResourceClientMock;
import org.gbif.registry.ws.config.DataSourcesConfiguration;
import org.gbif.vocabulary.client.ConceptClient;
import org.gbif.ws.client.filter.SimplePrincipalProvider;
Expand Down Expand Up @@ -56,9 +60,6 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import java.util.Collections;
import java.util.Date;

@TestConfiguration
@SpringBootApplication(
exclude = {
Expand Down Expand Up @@ -212,4 +213,9 @@ public static void main(String[] args) {
public ConceptClient conceptClient() {
return new ConceptClientMock();
}

@Bean
public NubResourceClient nubResourceClient() {
return new NubResourceClientMock();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ abstract class BaseCollectionEntityResourceIT<
@Autowired protected ObjectMapper objectMapper;
@Autowired protected MockMvc mockMvc;

@MockBean private ResourceNotFoundService resourceNotFoundService;
@MockBean protected ResourceNotFoundService resourceNotFoundService;

public BaseCollectionEntityResourceIT(
Class<? extends BaseCollectionEntityClient<T, R>> cls,
Expand Down Expand Up @@ -528,7 +528,7 @@ public void listChangeSuggestionTest() {
UUID entityKey = UUID.randomUUID();
Pageable page = new PagingRequest();

when(getMockChangeSuggestionService().list(status, type, proposerEmail, entityKey, page))
when(getMockChangeSuggestionService().list(status, type, proposerEmail, entityKey, null, page))
.thenReturn(
new PagingResponse<>(
new PagingRequest(), 1L, Collections.singletonList(changeSuggestion)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
*/
package org.gbif.registry.ws.it.collections.resource;


import static org.gbif.registry.ws.it.fixtures.TestConstants.IT_APP_KEY2;

import java.util.Arrays;
import java.util.Collections;
import javax.sql.DataSource;
import org.gbif.api.vocabulary.UserRole;
import org.gbif.registry.search.test.EsManageServer;
import org.gbif.registry.test.mocks.IdentityServiceMock;
Expand All @@ -26,12 +32,6 @@
import org.gbif.ws.security.GbifAuthenticationManager;
import org.gbif.ws.security.GbifAuthenticationManagerImpl;
import org.gbif.ws.security.KeyStore;

import java.util.Arrays;
import java.util.Collections;

import javax.sql.DataSource;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
Expand All @@ -55,8 +55,6 @@
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.PlatformTransactionManager;

import static org.gbif.registry.ws.it.fixtures.TestConstants.IT_APP_KEY2;

/** Base class for IT tests that initializes data sources and basic security settings. */
@ExtendWith(SpringExtension.class)
@SpringBootTest(
Expand Down Expand Up @@ -146,6 +144,7 @@ protected <T> T prepareClient(String username, int localServerPort, Class<T> cls
return clientBuilder
.withUrl("http://localhost:" + localServerPort)
.withCredentials(username, username)
.withFormEncoder()
.build(cls);
}

Expand Down
Loading

0 comments on commit 85d7f86

Please sign in to comment.