use of org.gbif.api.service.registry.NodeService 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.gbif.api.service.registry.NodeService 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.gbif.api.service.registry.NodeService in project registry by gbif.
the class NodeIT method testCountries.
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testCountries(ServiceType serviceType) {
NodeService service = (NodeService) getService(serviceType);
initVotingCountryNodes(serviceType);
List<Country> countries = service.listNodeCountries();
assertEquals(TEST_COUNTRIES.size(), countries.size());
for (Country c : countries) {
assertTrue(TEST_COUNTRIES.containsKey(c), "Unexpected node country" + c);
}
}
use of org.gbif.api.service.registry.NodeService in project registry by gbif.
the class NodeIT method testDatasets.
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testDatasets(ServiceType serviceType) {
NodeService service = (NodeService) getService(serviceType);
OrganizationService organizationService = getService(serviceType, organizationResource, organizationClient);
InstallationService installationService = getService(serviceType, installationResource, installationClient);
DatasetService datasetService = getService(serviceType, datasetResource, datasetClient);
// endorsing node for the organization
Node node = create(newEntity(serviceType), serviceType, 1);
// publishing organization (required field)
Organization o = testDataFactory.newOrganization(node.getKey());
o.setEndorsingNodeKey(node.getKey());
UUID organizationKey = organizationService.create(o);
// endorse organization
if (serviceType == ServiceType.RESOURCE) {
organizationService.confirmEndorsement(organizationKey);
} else {
((OrganizationClient) organizationClient).confirmEndorsementEndpoint(organizationKey);
}
// hosting technical installation (required field)
Installation i = testDataFactory.newInstallation(organizationKey);
UUID installationKey = installationService.create(i);
// 2 datasets
Dataset d1 = testDataFactory.newDataset(organizationKey, installationKey);
datasetService.create(d1);
Dataset d2 = testDataFactory.newDataset(organizationKey, installationKey);
UUID d2Key = datasetService.create(d2);
// test node service
PagingResponse<Dataset> resp = service.endorsedDatasets(node.getKey(), new PagingRequest());
assertEquals(2, resp.getResults().size());
assertEquals(2L, resp.getCount(), "Paging is not returning the correct count");
// the last created dataset should be the first in the list
assertEquals(d2Key, resp.getResults().get(0).getKey());
}
use of org.gbif.api.service.registry.NodeService in project registry by gbif.
the class NodeIT method testAddContact.
/**
* Node contacts are IMS managed and the service throws exceptions
*/
@ParameterizedTest
@EnumSource(ServiceType.class)
public void testAddContact(ServiceType serviceType) {
NodeService service = ((NodeService) getService(serviceType));
Node n = create(newEntity(serviceType), serviceType, 1);
assertThrows(UnsupportedOperationException.class, () -> service.addContact(n.getKey(), new Contact()));
}
Aggregations