use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testReadUnclaimedWhenNotOwnCreation.
@Test
public void testReadUnclaimedWhenNotOwnCreation() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
OrcidMessage orcidMessage = createStubOrcidMessage();
Email email = new Email("madeupemail2@semantico.com");
email.setPrimary(true);
orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
Response createResponse = t2OrcidApiServiceDelegator.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);
SecurityContextTestUtils.setUpSecurityContextForClientOnly("4444-4444-4444-4448");
Response readResponse = t2OrcidApiServiceDelegator.findFullDetails(orcid);
assertNotNull(readResponse);
assertEquals(HttpStatus.SC_OK, readResponse.getStatus());
OrcidMessage retrievedMessage = (OrcidMessage) readResponse.getEntity();
assertEquals(orcid, retrievedMessage.getOrcidProfile().getOrcidIdentifier().getPath());
GivenNames givenNames = retrievedMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames();
assertNotNull(givenNames);
assertEquals("Reserved For Claim", givenNames.getContent());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddExternalIdentifiersToDeprecatedAccount.
@Test(expected = OrcidDeprecatedException.class)
public void testAddExternalIdentifiersToDeprecatedAccount() {
SecurityContextTestUtils.setUpSecurityContext();
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
orcidMessage.setOrcidProfile(new OrcidProfile());
orcidMessage.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);
orcidMessage.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
t2OrcidApiServiceDelegator.addExternalIdentifiers(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddFundingToDeprecatedAccount.
@Test(expected = OrcidDeprecatedException.class)
public void testAddFundingToDeprecatedAccount() {
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);
FundingList fundings = new FundingList();
Funding funding = new Funding();
OrganizationAddress address = new OrganizationAddress();
address.setCity("City");
address.setCountry(Iso3166Country.US);
Organization org = new Organization();
org.setAddress(address);
org.setName("Testing org name");
funding.setOrganization(org);
FundingExternalIdentifiers fExtIds = new FundingExternalIdentifiers();
FundingExternalIdentifier fExtId = new FundingExternalIdentifier();
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER);
fExtId.setValue("FExtId");
fExtIds.getFundingExternalIdentifier().add(fExtId);
funding.setFundingExternalIdentifiers(fExtIds);
funding.setType(FundingType.AWARD);
funding.setOrganizationDefinedFundingType(new OrganizationDefinedFundingSubType("fType"));
FundingTitle title = new FundingTitle();
title.setTitle(new Title("Funding title"));
funding.setTitle(title);
fundings.getFundings().add(funding);
orcidActivities.setFundings(fundings);
t2OrcidApiServiceDelegator.addFunding(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBio.
@Test
public void testReadPrivacyOnBio() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.READ_LIMITED);
/*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();
assertEquals(3, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("type2", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals(Visibility.PRIVATE, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
assertEquals("type3", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdCommonName().getContent());
assertEquals(Visibility.LIMITED, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getVisibility());
assertEquals("type4", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(2).getExternalIdCommonName().getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(2).getVisibility());
assertEquals(Visibility.PRIVATE, p.getOrcidBio().getExternalIdentifiers().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBioAsPublic.
@Test
public void testReadPrivacyOnBioAsPublic() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.READ_PUBLIC);
/*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();
assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("type4", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
}
Aggregations