use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testAddServiceNoStartDate.
@Test(expected = OrcidValidationException.class)
public void testAddServiceNoStartDate() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Service service = (Service) Utils.getAffiliation(AffiliationType.SERVICE);
service.setStartDate(null);
serviceDelegator.createService(ORCID, service);
}
use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testViewPublicService.
@Test
public void testViewPublicService() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewService(ORCID, 47L);
assertNotNull(response);
Service service = (Service) response.getEntity();
assertNotNull(service);
Utils.verifyLastModified(service.getLastModifiedDate());
assertEquals(Long.valueOf(47L), service.getPutCode());
assertEquals("/0000-0000-0000-0003/service/47", service.getPath());
assertEquals("PUBLIC Department", service.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), service.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testUpdateServiceDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateServiceDuplicateExternalIDs() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
ExternalID e1 = new ExternalID();
e1.setRelationship(Relationship.SELF);
e1.setType("erm");
e1.setUrl(new Url("https://orcid.org"));
e1.setValue("err");
ExternalID e2 = new ExternalID();
e2.setRelationship(Relationship.SELF);
e2.setType("err");
e2.setUrl(new Url("http://bbc.co.uk"));
e2.setValue("erm");
ExternalIDs externalIDs = new ExternalIDs();
externalIDs.getExternalIdentifier().add(e1);
externalIDs.getExternalIdentifier().add(e2);
Service service = (Service) Utils.getAffiliation(AffiliationType.SERVICE);
service.setExternalIDs(externalIDs);
Response response = serviceDelegator.createService(ORCID, service);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
Service another = (Service) Utils.getAffiliation(AffiliationType.SERVICE);
response = serviceDelegator.createService(ORCID, another);
map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
resultWithPutCode = (List<?>) map.get("Location");
Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewService(ORCID, putCode2);
another = (Service) response.getEntity();
another.setExternalIDs(externalIDs);
try {
serviceDelegator.updateService(ORCID, putCode2, another);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode1);
serviceDelegator.deleteAffiliation(ORCID, putCode2);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testViewServiceReadPublic.
@Test
public void testViewServiceReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewService(ORCID, 47L);
Service element = (Service) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/service/47", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.Service in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testViewServices.
@Test
public void testViewServices() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewServices(ORCID);
assertNotNull(r);
Services services = (Services) r.getEntity();
assertNotNull(services);
assertEquals("/0000-0000-0000-0003/services", services.getPath());
Utils.verifyLastModified(services.getLastModifiedDate());
assertNotNull(services.getSummaries());
assertEquals(4, services.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (ServiceSummary summary : services.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(47).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(48).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(49).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(50).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid service found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
Aggregations