use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method testAttemptCreateWithTotallyIncorrectVersion.
@Test(expected = OrcidValidationException.class)
public void testAttemptCreateWithTotallyIncorrectVersion() {
setUpSecurityContextForClientOnly();
OrcidMessage orcidMessage = createStubOrcidMessage();
orcidMessage.setMessageVersion("abc");
Email email = new Email("madeupemail4@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 T2OrcidApiServiceDelegatorTest method testAddWorks.
@Test
public void testAddWorks() {
SecurityContextTestUtils.setUpSecurityContext();
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4441"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
Response response = t2OrcidApiServiceDelegator.addWorks(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
assertNotNull(response);
assertEquals(201, response.getStatus());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddDuplicatedExtIdsDontModifyProfile.
@Test
public void testAddDuplicatedExtIdsDontModifyProfile() {
String userOrcid = "0000-0000-0000-0005";
OrcidMessage message = new OrcidMessage();
message.setMessageVersion("1.2_rc6");
message.setOrcidProfile(new OrcidProfile());
message.getOrcidProfile().setOrcidBio(new OrcidBio());
ExternalIdentifiers extIds = new ExternalIdentifiers();
ExternalIdentifier extId1 = new ExternalIdentifier();
String commonName = "common-name-1-" + System.currentTimeMillis();
extId1.setExternalIdCommonName(new ExternalIdCommonName(commonName));
extId1.setExternalIdReference(new ExternalIdReference("ext-id-reference-1"));
extId1.setExternalIdUrl(new ExternalIdUrl("http://test.orcid.org/" + System.currentTimeMillis()));
extIds.getExternalIdentifier().add(extId1);
message.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
// Add for client 1
SecurityContextTestUtils.setUpSecurityContext(userOrcid, "APP-5555555555555555", ScopePathType.PERSON_UPDATE, ScopePathType.PERSON_READ_LIMITED);
Response r = t2OrcidApiServiceDelegator.addExternalIdentifiers(null, userOrcid, message);
assertNotNull(r);
OrcidMessage newMessage1 = (OrcidMessage) r.getEntity();
assertNotNull(newMessage1);
assertNotNull(newMessage1.getOrcidProfile());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
assertEquals(1, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals(commonName, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals("APP-5555555555555555", newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getSource().retrieveSourcePath());
// Reset message to add it again
message = new OrcidMessage();
message.setMessageVersion("1.2_rc6");
message.setOrcidProfile(new OrcidProfile());
message.getOrcidProfile().setOrcidBio(new OrcidBio());
extId1.setSource(null);
message.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
r = t2OrcidApiServiceDelegator.addExternalIdentifiers(null, userOrcid, message);
// If we add it again, no error, but it is not duplicated
assertNotNull(r);
OrcidMessage newMessage2 = (OrcidMessage) r.getEntity();
assertNotNull(newMessage2);
assertNotNull(newMessage2.getOrcidProfile());
assertNotNull(newMessage2.getOrcidProfile().getOrcidBio());
assertNotNull(newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers());
assertNotNull(newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
assertEquals(1, newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals(commonName, newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals("APP-5555555555555555", newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testReadPrivateEmailsOnBio.
@Test
public void testReadPrivateEmailsOnBio() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.ORCID_BIO_READ_LIMITED, ScopePathType.EMAIL_READ_PRIVATE);
/*Example A List on 4444-4444-4444-4497:
Item 1 Private (client is source)
Item 2 Private (other source)
Item 3 Limited
Item 4 Public
*/
OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4497").getEntity()).getOrcidProfile();
List<Email> emails = p.getOrcidBio().getContactDetails().getEmail();
assertEquals(3, emails.size());
boolean privateFound = false;
boolean publicFound = false;
boolean limitedFound = false;
for (Email email : emails) {
if ("public_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.PUBLIC.equals(email.getVisibility())) {
publicFound = true;
} else if ("limited_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.LIMITED.equals(email.getVisibility())) {
limitedFound = true;
} else if ("private_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.PRIVATE.equals(email.getVisibility())) {
privateFound = true;
}
}
assertTrue(publicFound);
assertTrue(limitedFound);
assertTrue(privateFound);
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddAffiliationToDeprecatedAccount.
@Test(expected = OrcidDeprecatedException.class)
public void testAddAffiliationToDeprecatedAccount() {
SecurityContextTestUtils.setUpSecurityContext();
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-444X"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrganizationAddress address = new OrganizationAddress();
address.setCity("City");
address.setCountry(Iso3166Country.US);
Organization org = new Organization();
org.setAddress(address);
org.setName("Testing org name");
Affiliations affiliations = new Affiliations();
Affiliation affiliation = new Affiliation();
affiliation.setDepartmentName("Dept name");
affiliation.setOrganization(org);
affiliation.setType(AffiliationType.EMPLOYMENT);
affiliations.getAffiliation().add(affiliation);
orcidActivities.setAffiliations(affiliations);
t2OrcidApiServiceDelegator.addAffiliations(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Aggregations