use of org.orcid.jaxb.model.message.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testUpdateWorkWhenNotSource.
@Test(expected = WrongSourceException.class)
@Transactional
public void testUpdateWorkWhenNotSource() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = new OrcidWork();
orcidWorks.getOrcidWork().add(orcidWork);
orcidWork.setPutCode("6");
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Updated by works update"));
orcidWork.setWorkTitle(workTitle);
orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
}
use of org.orcid.jaxb.model.message.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testUpdateExistingNonPrivateWork.
@Test
@Transactional
public void testUpdateExistingNonPrivateWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = new OrcidWork();
orcidWorks.getOrcidWork().add(orcidWork);
orcidWork.setPutCode("5");
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Updated by works update"));
orcidWork.setWorkTitle(workTitle);
orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
Response response = t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
assertNotNull(response);
OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4446");
List<OrcidWork> retreivedWorksList = retrievedProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
boolean foundWorkFromAnotherSource = false;
boolean foundUpdated = false;
boolean foundExisting = false;
boolean foundExistingPrivate = false;
for (OrcidWork retrievedWork : retreivedWorksList) {
if ("5".equals(retrievedWork.getPutCode())) {
// The updated work
assertEquals("Updated by works update", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PUBLIC, retrievedWork.getVisibility());
foundUpdated = true;
} else if ("6".equals(retrievedWork.getPutCode())) {
assertEquals("Journal article B", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.LIMITED, retrievedWork.getVisibility());
foundWorkFromAnotherSource = true;
} else if ("7".equals(retrievedWork.getPutCode())) {
// Existing private work
assertEquals("Journal article C", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
foundExisting = true;
} else if ("8".equals(retrievedWork.getPutCode())) {
// Existing private work added by the user
assertEquals("Journal article D", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
foundExistingPrivate = true;
}
}
assertTrue("Work from other source should be there", foundWorkFromAnotherSource);
assertTrue("Updated work should be there", foundUpdated);
assertTrue("Existing private work should be there", foundExisting);
assertTrue("Existing private work added by the user should be there", foundExistingPrivate);
assertEquals(4, retreivedWorksList.size());
}
use of org.orcid.jaxb.model.message.OrcidActivities 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.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method buildMessageWithAffiliation.
private OrcidMessage buildMessageWithAffiliation(AffiliationType type, String dept, String role, String orcid) {
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier(orcid));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
Affiliation affiliation = new Affiliation();
affiliation.setStartDate(new FuzzyDate(2010, 01, 01));
affiliation.setEndDate(new FuzzyDate(2015, 01, 01));
affiliation.setDepartmentName(dept);
affiliation.setRoleTitle(role);
affiliation.setType(type);
Organization organization = new Organization();
organization.setName("My Org");
OrganizationAddress add = new OrganizationAddress();
add.setCity("My City");
add.setCountry(Iso3166Country.US);
organization.setAddress(add);
DisambiguatedOrganization dorg = new DisambiguatedOrganization();
dorg.setDisambiguatedOrganizationIdentifier("disambiguated org ID");
dorg.setDisambiguationSource("THESOURCE");
organization.setDisambiguatedOrganization(dorg);
affiliation.setOrganization(organization);
affiliations.getAffiliation().add(affiliation);
orcidActivities.setAffiliations(affiliations);
return orcidMessage;
}
use of org.orcid.jaxb.model.message.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method testAddWorks.
@Test
public void testAddWorks() {
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 = t2OrcidApiServiceDelegatorLatest.addWorks(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
assertNotNull(response);
}
Aggregations