use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method orcidMultipleOrcidsIndexed.
/**
*
*/
@Test
public void orcidMultipleOrcidsIndexed() {
when(solrDao.findByDocumentCriteria("rndQuery", null, null)).thenReturn(multipleResultsForQuery());
when(orcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfile5678MandatoryOnly());
when(orcidProfileCacheManager.retrievePublicBio("6789")).thenReturn(getOrcidProfile6789MandatoryOnly());
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidsByQuery("rndQuery");
assertNotNull(retrievedOrcidMessage);
assertTrue(retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 2);
OrcidSearchResult result = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
OrcidProfile retrievedProfile = result.getOrcidProfile();
assertEquals("5678", retrievedProfile.getOrcidIdentifier().getPath());
OrcidBio orcidBio = retrievedProfile.getOrcidBio();
assertEquals("Logan", orcidBio.getPersonalDetails().getFamilyName().getContent());
assertEquals("Donald Edward", orcidBio.getPersonalDetails().getGivenNames().getContent());
assertNull(orcidBio.getContactDetails());
OrcidSearchResult result2 = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(1);
OrcidProfile retrievedProfile2 = result2.getOrcidProfile();
assertEquals("6789", retrievedProfile2.getOrcidIdentifier().getPath());
OrcidBio orcidBio2 = retrievedProfile2.getOrcidBio();
assertEquals("Thomson", orcidBio2.getPersonalDetails().getFamilyName().getContent());
assertEquals("Homer J", orcidBio2.getPersonalDetails().getGivenNames().getContent());
assertNotNull(orcidBio2.getContactDetails());
assertEquals("don@semantico.com", orcidBio2.getContactDetails().retrievePrimaryEmail().getValue());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method orcidRetrievalMandatoryFieldsOnly.
@Test
@Rollback
public void orcidRetrievalMandatoryFieldsOnly() {
when(solrDao.findByOrcid("1434")).thenReturn(getSolrRes5678());
when(orcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfile5678MandatoryOnly());
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidSearchResultsById("1434");
assertNotNull(retrievedOrcidMessage);
assertTrue(retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 1);
OrcidSearchResult result = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
OrcidProfile retrievedProfile = result.getOrcidProfile();
assertEquals("5678", retrievedProfile.getOrcidIdentifier().getPath());
OrcidBio orcidBio = retrievedProfile.getOrcidBio();
assertEquals("Logan", orcidBio.getPersonalDetails().getFamilyName().getContent());
assertEquals("Donald Edward", orcidBio.getPersonalDetails().getGivenNames().getContent());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method orcidInIndexButNotinDb.
@Test
@Rollback
public void orcidInIndexButNotinDb() {
when(solrDao.findByOrcid("1434")).thenReturn(getSolrRes5678());
when(orcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(null);
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidSearchResultsById("1434");
assertNotNull(retrievedOrcidMessage);
assertNotNull(retrievedOrcidMessage.getOrcidSearchResults());
assertTrue(retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().isEmpty());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class Api12MembersTest method personUpdateTest.
@Test
public void personUpdateTest() throws InterruptedException, JSONException {
String clientId = getClient1ClientId();
String clientRedirectUri = getClient1RedirectUri();
String clientSecret = getClient1ClientSecret();
String userId = getUser1OrcidId();
String password = getUser1Password();
String giveName = getUser1GivenName();
String familyName = getUser1FamilyNames();
String creditName = getUser1CreditName();
String accessToken = getAccessToken(userId, password, Arrays.asList("/person/update", "/orcid-bio/read-limited"), clientId, clientSecret, clientRedirectUri, true);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
OrcidBio orcidBio = new OrcidBio();
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setGivenNames(new GivenNames("My given name"));
personalDetails.setFamilyName(new FamilyName("My family name"));
CreditName creditNameElement = new CreditName("My credit name");
creditNameElement.setVisibility(Visibility.LIMITED);
personalDetails.setCreditName(creditNameElement);
orcidBio.setPersonalDetails(personalDetails);
orcidProfile.setOrcidBio(orcidBio);
ClientResponse clientResponse = t2OAuthClient_1_2.updateBioDetailsXml(userId, orcidMessage, accessToken);
assertEquals(200, clientResponse.getStatus());
ClientResponse response = t2OAuthClient_1_2.viewBioDetailsXml(userId, accessToken);
assertNotNull(response);
assertEquals(200, response.getStatus());
OrcidMessage orcidMessageWithBio = response.getEntity(OrcidMessage.class);
assertNotNull(orcidMessageWithBio);
assertNotNull(orcidMessageWithBio.getOrcidProfile());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames());
assertEquals("My given name", orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames().getContent());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName());
assertEquals("My family name", orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName().getContent());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName());
assertEquals("My credit name", orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getContent());
assertEquals(Visibility.LIMITED, orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getVisibility());
//Rollback changes
orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidBio = new OrcidBio();
personalDetails = new PersonalDetails();
personalDetails.setGivenNames(new GivenNames(giveName));
personalDetails.setFamilyName(new FamilyName(familyName));
creditNameElement = new CreditName(creditName);
creditNameElement.setVisibility(Visibility.PUBLIC);
personalDetails.setCreditName(creditNameElement);
orcidBio.setPersonalDetails(personalDetails);
orcidProfile.setOrcidBio(orcidBio);
clientResponse = t2OAuthClient_1_2.updateBioDetailsXml(userId, orcidMessage, accessToken);
assertEquals(200, clientResponse.getStatus());
response = t2OAuthClient_1_2.viewBioDetailsXml(userId, accessToken);
assertNotNull(response);
assertEquals(200, response.getStatus());
orcidMessageWithBio = response.getEntity(OrcidMessage.class);
assertNotNull(orcidMessageWithBio);
assertNotNull(orcidMessageWithBio.getOrcidProfile());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames());
assertEquals(giveName, orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames().getContent());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName());
assertEquals(familyName, orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName().getContent());
assertNotNull(orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName());
assertEquals(creditName, orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getContent());
assertEquals(Visibility.PUBLIC, orcidMessageWithBio.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.
the class Api12MembersTest method addAffiliationTest.
@Test
public void addAffiliationTest() throws InterruptedException, JSONException {
String clientId = getClient1ClientId();
String clientRedirectUri = getClient1RedirectUri();
String clientSecret = getClient1ClientSecret();
String userId = getUser1OrcidId();
String password = getUser1Password();
String accessToken = getAccessToken(userId, password, Arrays.asList("/affiliations/read-limited", "/activities/update"), clientId, clientSecret, clientRedirectUri, true);
String orgName = "Org_" + System.currentTimeMillis();
Long putCode = null;
Api12Helper.addAffiliation(userId, accessToken, orgName, t2OAuthClient_1_2);
ClientResponse response = t2OAuthClient_1_2.viewAffiliationDetailsXml(userId, accessToken);
assertNotNull(response);
assertEquals(200, response.getStatus());
assertEquals("application/vnd.orcid+xml; charset=UTF-8; qs=5", response.getType().toString());
OrcidMessage orcidMessage = response.getEntity(OrcidMessage.class);
assertNotNull(orcidMessage);
assertNotNull(orcidMessage.getOrcidProfile());
assertNotNull(orcidMessage.getOrcidProfile().getOrcidActivities());
assertNotNull(orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations());
assertNotNull(orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation());
boolean found = false;
for (Affiliation affiliation : orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation()) {
if (orgName.equals(affiliation.getOrganization().getName())) {
assertNotNull(affiliation.getPutCode());
putCode = Long.valueOf(affiliation.getPutCode());
found = true;
}
}
assertTrue(found);
//Delete it
ClientResponse deleteResponse = memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), putCode, accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations