Search in sources :

Example 71 with OrcidMessage

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());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 72 with OrcidMessage

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());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 73 with OrcidMessage

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());
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 74 with OrcidMessage

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());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) CreditName(org.orcid.jaxb.model.message.CreditName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Test(org.junit.Test)

Example 75 with OrcidMessage

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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Affiliation(org.orcid.jaxb.model.message.Affiliation) Test(org.junit.Test)

Aggregations

OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)173 Test (org.junit.Test)108 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)64 DBUnitTest (org.orcid.test.DBUnitTest)49 ClientResponse (com.sun.jersey.api.client.ClientResponse)36 Response (javax.ws.rs.core.Response)26 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)22 Transactional (org.springframework.transaction.annotation.Transactional)22 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)20 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)19 Email (org.orcid.jaxb.model.message.Email)18 BaseTest (org.orcid.core.BaseTest)17 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)16 Affiliation (org.orcid.jaxb.model.message.Affiliation)13 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)12 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)12 JAXBContext (javax.xml.bind.JAXBContext)11 Unmarshaller (javax.xml.bind.Unmarshaller)11 Organization (org.orcid.jaxb.model.message.Organization)11 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)11