Search in sources :

Example 66 with EnumSource

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");
}
Also used : OccurrenceDownloadService(org.gbif.api.service.registry.OccurrenceDownloadService) PagingRequest(org.gbif.api.model.common.paging.PagingRequest) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 67 with EnumSource

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);
}
Also used : OccurrenceDownloadService(org.gbif.api.service.registry.OccurrenceDownloadService) Download(org.gbif.api.model.occurrence.Download) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 68 with EnumSource

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());
}
Also used : OrganizationService(org.gbif.api.service.registry.OrganizationService) Organization(org.gbif.api.model.registry.Organization) NodeService(org.gbif.api.service.registry.NodeService) UUID(java.util.UUID) PagingRequest(org.gbif.api.model.common.paging.PagingRequest) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 69 with EnumSource

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");
}
Also used : OrganizationService(org.gbif.api.service.registry.OrganizationService) Organization(org.gbif.api.model.registry.Organization) NodeService(org.gbif.api.service.registry.NodeService) UUID(java.util.UUID) PagingRequest(org.gbif.api.model.common.paging.PagingRequest) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 70 with EnumSource

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());
}
Also used : Installation(org.gbif.api.model.registry.Installation) Organization(org.gbif.api.model.registry.Organization) Dataset(org.gbif.api.model.registry.Dataset) Network(org.gbif.api.model.registry.Network) NetworkService(org.gbif.api.service.registry.NetworkService) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)1702 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1697 Objs (io.github.mianalysis.mia.object.Objs)238 Obj (io.github.mianalysis.mia.object.Obj)232 SpatCal (io.github.sjcross.common.object.volume.SpatCal)174 JavaFileObject (javax.tools.JavaFileObject)113 Workspace (io.github.mianalysis.mia.object.Workspace)112 Workspaces (io.github.mianalysis.mia.object.Workspaces)112 Compilation (io.jbock.testing.compile.Compilation)107 ArrayList (java.util.ArrayList)90 Point (io.github.sjcross.common.object.Point)88 ImagePlus (ij.ImagePlus)84 Objects3D (io.github.mianalysis.mia.expectedobjects.Objects3D)82 Image (io.github.mianalysis.mia.object.Image)82 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)58 HashMap (java.util.HashMap)47 Path (java.nio.file.Path)44 List (java.util.List)42 Account (io.nem.symbol.sdk.model.account.Account)40 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)38