use of org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewExternalIdentifier.
@Test
public void testViewExternalIdentifier() {
Response response = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(13), extId.getPutCode());
assertEquals("public_type", extId.getType());
assertNotNull(extId.getUrl());
assertEquals("http://ext-id/public_ref", extId.getUrl().getValue());
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testDeleteExternalIdentifierYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testDeleteExternalIdentifierYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 3L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
assertEquals("Facebook", extId.getType());
assertEquals("abc456", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://www.facebook.com/abc456", extId.getUrl().getValue());
serviceDelegator.deleteExternalIdentifier("4444-4444-4444-4442", 3L);
fail();
}
use of org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testViewPrivateExternalIdentifier.
@Test
public void testViewPrivateExternalIdentifier() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 5L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
assertEquals("/4444-4444-4444-4442/external-identifiers/5", extId.getPath());
Utils.verifyLastModified(extId.getLastModifiedDate());
assertEquals("Facebook", extId.getType());
assertEquals(Long.valueOf(5), extId.getPutCode());
assertEquals("abc012", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://www.facebook.com/abc012", extId.getUrl().getValue());
assertEquals(Visibility.PRIVATE, extId.getVisibility());
assertNotNull(extId.getSource());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
assertNotNull(extId.getCreatedDate());
Utils.verifyLastModified(extId.getLastModifiedDate());
}
use of org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testReadPublicScope_ExternalIdentifiers.
@Test
public void testReadPublicScope_ExternalIdentifiers() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewExternalIdentifiers(ORCID);
assertNotNull(r);
assertEquals(PersonExternalIdentifiers.class.getName(), r.getEntity().getClass().getName());
PersonExternalIdentifiers p = (PersonExternalIdentifiers) r.getEntity();
assertNotNull(p);
assertEquals("/0000-0000-0000-0003/external-identifiers", p.getPath());
Utils.verifyLastModified(p.getLastModifiedDate());
assertEquals(3, p.getExternalIdentifiers().size());
boolean found13 = false, found14 = false, found15 = false;
for (PersonExternalIdentifier element : p.getExternalIdentifiers()) {
if (element.getPutCode() == 13) {
found13 = true;
} else if (element.getPutCode() == 14) {
found14 = true;
} else if (element.getPutCode() == 15) {
found15 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found13);
assertTrue(found14);
assertTrue(found15);
r = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
assertNotNull(r);
assertEquals(PersonExternalIdentifier.class.getName(), r.getEntity().getClass().getName());
// Limited am the source of should work
serviceDelegator.viewExternalIdentifier(ORCID, 14L);
// Limited fail
try {
serviceDelegator.viewExternalIdentifier(ORCID, 16L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private am the source of should work
serviceDelegator.viewExternalIdentifier(ORCID, 15L);
// Private fail
try {
serviceDelegator.viewExternalIdentifier(ORCID, 17L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testViewLimitedExternalIdentifier.
@Test
public void testViewLimitedExternalIdentifier() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 3L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
assertEquals("/4444-4444-4444-4442/external-identifiers/3", extId.getPath());
Utils.verifyLastModified(extId.getLastModifiedDate());
assertEquals("Facebook", extId.getType());
assertEquals(Long.valueOf(3), extId.getPutCode());
assertEquals("abc456", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://www.facebook.com/abc456", extId.getUrl().getValue());
assertEquals(Visibility.LIMITED, extId.getVisibility());
assertNotNull(extId.getSource());
assertEquals("4444-4444-4444-4442", extId.getSource().retrieveSourcePath());
assertNotNull(extId.getCreatedDate());
Utils.verifyLastModified(extId.getLastModifiedDate());
}
Aggregations