use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method testCreateWithAffiliations.
@Test
public void testCreateWithAffiliations() throws JAXBException {
setUpSecurityContextForClientOnly();
OrcidMessage orcidMessage = getOrcidMessage("/orcid-message-for-create-latest.xml");
Response createResponse = t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
assertNotNull(createResponse);
assertEquals(HttpStatus.SC_CREATED, createResponse.getStatus());
String location = ((URI) createResponse.getMetadata().getFirst("Location")).getPath();
assertNotNull(location);
String orcid = location.substring(1, 20);
Response readResponse = t2OrcidApiServiceDelegatorLatest.findFullDetails(orcid);
assertNotNull(readResponse);
assertEquals(HttpStatus.SC_OK, readResponse.getStatus());
OrcidMessage retrievedMessage = (OrcidMessage) readResponse.getEntity();
OrcidProfile orcidProfile = retrievedMessage.getOrcidProfile();
assertEquals(orcid, orcidProfile.getOrcidIdentifier().getPath());
Affiliations affiliations = orcidProfile.retrieveAffiliations();
assertNotNull(affiliations);
assertEquals(1, affiliations.getAffiliation().size());
Affiliation affiliation = affiliations.getAffiliation().get(0);
assertEquals(Visibility.PRIVATE, affiliation.getVisibility());
Source source = affiliation.getSource();
assertNotNull(source);
String sourceOrcid = source.retrieveSourcePath();
assertNotNull(sourceOrcid);
assertEquals("4444-4444-4444-4445", sourceOrcid);
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBio3.
@Test
public void testReadPrivacyOnBio3() {
/*Example C List:
Item 1 Public
*/
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED);
OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4443").getEntity()).getOrcidProfile();
System.out.println(p.toString());
assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("Facebook", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_PUBLIC);
p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4443").getEntity()).getOrcidProfile();
System.out.println(p.toString());
assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("Facebook", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method testAttemptCreateWithLaterButOtherwiseValidVersion.
@Test(expected = OrcidValidationException.class)
public void testAttemptCreateWithLaterButOtherwiseValidVersion() {
setUpSecurityContextForClientOnly();
OrcidMessage orcidMessage = createStubOrcidMessage();
orcidMessage.setMessageVersion("1.0.22");
Email email = new Email("madeupemail3@semantico.com");
orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
t2OrcidApiServiceDelegatorV2_1.createProfile(mockedUriInfo, orcidMessage);
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class JaxbOrcidMessageUtil method getPublicOrcidMessage.
public static OrcidMessage getPublicOrcidMessage() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(PACKAGE);
Unmarshaller unmarshaller = context.createUnmarshaller();
return (OrcidMessage) unmarshaller.unmarshal(JaxbOrcidMessageUtil.class.getResourceAsStream(ORCID_PUBLIC_FULL_XML));
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method createFilteredOrcidMessage.
private OrcidMessage createFilteredOrcidMessage(OrcidProfile orcidProfile) {
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
orcidMessage.setOrcidProfile(orcidProfile);
visibilityFilter.filter(orcidMessage, Visibility.PUBLIC);
return orcidMessage;
}
Aggregations