use of org.orcid.jaxb.model.v3.dev1.record.OtherNames in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testDeleteOtherName.
@Test
public void testDeleteOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewOtherNames("4444-4444-4444-4447");
assertNotNull(response);
OtherNames otherNames = (OtherNames) response.getEntity();
assertNotNull(otherNames);
assertNotNull(otherNames.getOtherNames());
assertEquals(1, otherNames.getOtherNames().size());
response = serviceDelegator.deleteOtherName("4444-4444-4444-4447", 9L);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
response = serviceDelegator.viewOtherNames("4444-4444-4444-4447");
assertNotNull(response);
otherNames = (OtherNames) response.getEntity();
assertNotNull(otherNames);
assertNotNull(otherNames.getOtherNames());
assertTrue(otherNames.getOtherNames().isEmpty());
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherNames in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testReadPublicScope_OtherNames.
@Test
public void testReadPublicScope_OtherNames() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewOtherNames(ORCID);
assertNotNull(r);
assertEquals(OtherNames.class.getName(), r.getEntity().getClass().getName());
OtherNames o = (OtherNames) r.getEntity();
assertNotNull(o);
Utils.verifyLastModified(o.getLastModifiedDate());
assertEquals(3, o.getOtherNames().size());
boolean found1 = false, found2 = false, found3 = false;
for (OtherName element : o.getOtherNames()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
r = serviceDelegator.viewOtherName(ORCID, 13L);
assertNotNull(r);
assertEquals(OtherName.class.getName(), r.getEntity().getClass().getName());
// Limited where am the source should work
serviceDelegator.viewOtherName(ORCID, 14L);
// Limited where am not the source of should fail
try {
serviceDelegator.viewOtherName(ORCID, 16L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private where am the source should work
serviceDelegator.viewOtherName(ORCID, 15L);
// Private where am not the source should work
try {
serviceDelegator.viewOtherName(ORCID, 17L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherNames in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testViewOtherNamesReadPublic.
@Test
public void testViewOtherNamesReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewOtherNames(ORCID);
OtherNames element = (OtherNames) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/other-names", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherNames in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testViewOtherNames.
@Test
public void testViewOtherNames() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewOtherNames("4444-4444-4444-4446");
assertNotNull(response);
OtherNames otherNames = (OtherNames) response.getEntity();
assertNotNull(otherNames);
assertEquals("/4444-4444-4444-4446/other-names", otherNames.getPath());
Utils.verifyLastModified(otherNames.getLastModifiedDate());
assertNotNull(otherNames.getOtherNames());
assertEquals(3, otherNames.getOtherNames().size());
for (OtherName otherName : otherNames.getOtherNames()) {
Utils.verifyLastModified(otherName.getLastModifiedDate());
assertThat(otherName.getPutCode(), anyOf(is(5L), is(6L), is(8L)));
assertThat(otherName.getContent(), anyOf(is("Other Name # 1"), is("Other Name # 2"), is("Other Name # 4")));
if (otherName.getPutCode() == 5L) {
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
} else if (otherName.getPutCode() == 6L) {
assertEquals(Visibility.LIMITED, otherName.getVisibility());
assertEquals("4444-4444-4444-4446", otherName.getSource().retrieveSourcePath());
} else {
assertEquals(Visibility.PRIVATE, otherName.getVisibility());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
}
}
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherNames in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method filterOtherNamesTest.
@Test
public void filterOtherNamesTest() {
OtherNames x = getOtherNamesElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
assertEquals(3, x.getOtherNames().size());
publicAPISecurityManagerV3.filter(x);
assertEquals(3, x.getOtherNames().size());
assertAllArePublic(x.getOtherNames());
x = getOtherNamesElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
assertEquals(3, x.getOtherNames().size());
publicAPISecurityManagerV3.filter(x);
assertEquals(2, x.getOtherNames().size());
assertAllArePublic(x.getOtherNames());
x = getOtherNamesElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, x.getOtherNames().size());
publicAPISecurityManagerV3.filter(x);
assertEquals(1, x.getOtherNames().size());
assertAllArePublic(x.getOtherNames());
x = getOtherNamesElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, x.getOtherNames().size());
publicAPISecurityManagerV3.filter(x);
assertTrue(x.getOtherNames().isEmpty());
}
Aggregations