use of org.junit.jupiter.params.provider.EnumSource in project registry by gbif.
the class OccurrenceDownloadIT method testListByStatus.
/**
* Creates several occurrence download with running status and retrieves the downloads done by
* status.
*/
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testListByStatus(ServiceType serviceType) {
OccurrenceDownloadService service = getService(serviceType, occurrenceDownloadResource, occurrenceDownloadClient);
for (int i = 1; i <= 5; i++) {
service.create(getTestInstancePredicateDownload());
}
assertTrue(service.list(new PagingRequest(0, 5), Download.Status.EXECUTING_STATUSES).getResults().size() > 0, "List by user operation should return 5 records");
}
use of org.junit.jupiter.params.provider.EnumSource in project registry by gbif.
the class OccurrenceDownloadIT method testCreateAndGet.
/**
* Tests the create and get(key) methods.
*/
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testCreateAndGet(ServiceType serviceType) {
OccurrenceDownloadService service = getService(serviceType, occurrenceDownloadResource, occurrenceDownloadClient);
Download occurrenceDownload = getTestInstancePredicateDownload();
service.create(occurrenceDownload);
Download occurrenceDownload2 = service.get(occurrenceDownload.getKey());
assertNotNull(occurrenceDownload2);
}
use of org.junit.jupiter.params.provider.EnumSource in project registry by gbif.
the class OrganizationCreationIT method testEndorsements.
/**
* It is not in the scope of this test to test the email bits.
*/
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testEndorsements(ServiceType serviceType) {
OrganizationService service = getService(serviceType, organizationResource, organizationClient);
NodeService nodeService = getService(serviceType, nodeResource, nodeClient);
Organization organization = prepareOrganization(prepareNode(nodeService, testDataFactory), service, testDataFactory);
assertEquals(0L, nodeService.endorsedOrganizations(organization.getEndorsingNodeKey(), new PagingRequest()).getCount());
assertEquals(1L, nodeService.pendingEndorsements(new PagingRequest()).getCount());
assertEquals(1L, nodeService.pendingEndorsements(organization.getEndorsingNodeKey(), new PagingRequest()).getCount());
assertEquals(1L, nodeService.pendingEndorsements(new PagingRequest()).getCount(), "Paging is not returning the correct count");
Integer challengeCodeKey = challengeCodeSupportMapper.getChallengeCodeKey(organization.getKey());
UUID challengeCode = challengeCodeMapper.getChallengeCode(challengeCodeKey);
assertTrue(service.confirmEndorsement(organization.getKey(), challengeCode), "endorsement should be confirmed");
// We should have no more pending endorsement for this node
assertEquals(0L, nodeService.pendingEndorsements(organization.getEndorsingNodeKey(), new PagingRequest()).getCount());
// We should also have a contact
assertEquals(1, service.get(organization.getKey()).getContacts().size());
// and a comment
assertEquals(1, service.get(organization.getKey()).getComments().size());
}
use of org.junit.jupiter.params.provider.EnumSource in project registry by gbif.
the class OrganizationCreationIT method testEndorsementsByUpdateMethodByAdmin.
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testEndorsementsByUpdateMethodByAdmin(ServiceType serviceType) {
OrganizationService service = getService(serviceType, organizationResource, organizationClient);
NodeService nodeService = getService(serviceType, nodeResource, nodeClient);
Organization organization = prepareOrganization(prepareNode(nodeService, testDataFactory), service, testDataFactory);
assertEquals(0L, nodeService.endorsedOrganizations(organization.getEndorsingNodeKey(), new PagingRequest()).getCount());
UUID organizationKey = organization.getKey();
boolean endorsement = service.confirmEndorsement(organizationKey, UUID.randomUUID());
assertFalse(endorsement, "endorsement should NOT be confirmed using appkey and no confirmation code");
// reset principal - use ADMIN role
setupPrincipal(TEST_ADMIN, REGISTRY_ADMIN);
OrganizationService adminService = getService(serviceType, organizationResource, adminOrganizationClient);
assertThrows(AccessDeniedException.class, () -> adminService.confirmEndorsement(organizationKey, UUID.randomUUID()), "endorsement should NOT be confirmed without confirmation code");
// get the latest version (to get fields like modified)
organization = service.get(organizationKey);
organization.setEndorsementApproved(true);
adminService.update(organization);
assertEquals(0L, nodeService.endorsedOrganizations(organization.getEndorsingNodeKey(), new PagingRequest()).getCount(), "Organization can't be endorsed by update method");
}
use of org.junit.jupiter.params.provider.EnumSource in project registry by gbif.
the class NetworkIT method testConstituentsHandlingErrors.
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testConstituentsHandlingErrors(ServiceType serviceType) {
NetworkService service = (NetworkService) getService(serviceType);
Network network = testDataFactory.newPersistedNetwork();
Organization organization = testDataFactory.newPersistedOrganization();
Installation installation = testDataFactory.newPersistedInstallation();
Dataset dataset = testDataFactory.newPersistedDataset(organization.getKey(), installation.getKey());
// Simple add
service.addConstituent(network.getKey(), dataset.getKey());
// Exception class depends on the service type
Class<? extends Throwable> expectedException = serviceType == ServiceType.RESOURCE ? WebApplicationException.class : IllegalArgumentException.class;
// Adding to a non-existing network
assertThrows(expectedException, () -> service.addConstituent(UUID.randomUUID(), dataset.getKey()));
// Adding a non-existing dataset
assertThrows(expectedException, () -> service.addConstituent(network.getKey(), UUID.randomUUID()));
// Removing from a non-existing network
assertThrows(expectedException, () -> service.removeConstituent(UUID.randomUUID(), dataset.getKey()));
// Removing a non-existing dataset
assertThrows(expectedException, () -> service.removeConstituent(network.getKey(), UUID.randomUUID()));
// Simple remove
service.removeConstituent(network.getKey(), dataset.getKey());
}
Aggregations