use of org.orcid.jaxb.model.record_v2.OtherNames in project ORCID-Source by ORCID.
the class ValidateV2RC4SamplesTest method testUnmarshallOtherNames.
@Test
public void testUnmarshallOtherNames() throws SAXException, URISyntaxException {
OtherNames otherNames = (OtherNames) unmarshallFromPath("/record_2.0_rc4/samples/other-names-2.0_rc4.xml", OtherNames.class, "/record_2.0_rc4/personal-details-2.0_rc4.xsd");
assertNotNull(otherNames);
assertNotNull(otherNames.getOtherNames());
assertEquals(2, otherNames.getOtherNames().size());
for (OtherName otherName : otherNames.getOtherNames()) {
assertThat(otherName.getContent(), anyOf(is("Other Name #1"), is("Other Name #2")));
assertThat(otherName.getPutCode(), anyOf(is(1L), is(2L)));
assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
assertNotNull(otherName.getCreatedDate());
assertNotNull(otherName.getLastModifiedDate());
assertNotNull(otherName.getSource());
assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
}
OtherName otherName = (OtherName) unmarshallFromPath("/record_2.0_rc4/samples/other-name-2.0_rc4.xml", OtherName.class);
assertNotNull(otherName);
assertEquals("Other Name #1", otherName.getContent());
assertEquals(Long.valueOf(1), otherName.getPutCode());
assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
assertNotNull(otherName.getCreatedDate());
assertNotNull(otherName.getLastModifiedDate());
assertNotNull(otherName.getSource());
assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_v2.OtherNames in project ORCID-Source by ORCID.
the class ValidateV2RC3SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_v2.OtherNames in project ORCID-Source by ORCID.
the class ValidateV2RC3SamplesTest method testMarshallOtherNames.
@Test
public void testMarshallOtherNames() throws JAXBException, SAXException, URISyntaxException {
OtherNames object = (OtherNames) unmarshallFromPath("/record_2.0_rc3/samples/other-names-2.0_rc3.xml", OtherNames.class);
marshall(object, "/record_2.0_rc3/other-name-2.0_rc3.xsd");
}
use of org.orcid.jaxb.model.record_v2.OtherNames in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.record_v2.OtherNames in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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());
}
}
}
Aggregations