Search in sources :

Example 66 with Keywords

use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method filterKeywordsTest.

@Test
public void filterKeywordsTest() {
    Keywords x = getKeywordsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, x.getKeywords().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(3, x.getKeywords().size());
    assertAllArePublic(x.getKeywords());
    x = getKeywordsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, x.getKeywords().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(2, x.getKeywords().size());
    assertAllArePublic(x.getKeywords());
    x = getKeywordsElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getKeywords().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(1, x.getKeywords().size());
    assertAllArePublic(x.getKeywords());
    x = getKeywordsElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getKeywords().size());
    publicAPISecurityManagerV2.filter(x);
    assertTrue(x.getKeywords().isEmpty());
}
Also used : Keywords(org.orcid.jaxb.model.record_v2.Keywords) Test(org.junit.Test)

Example 67 with Keywords

use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method checkIsPublicPersonTest.

@Test
public void checkIsPublicPersonTest() {
    Person p = getPersonElement();
    publicAPISecurityManagerV2.filter(p);
    // Nothing is filtered yet
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Addresses filtered
    p = getPersonElement();
    setVisibility(p.getAddresses().getAddress(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    // --- filtered ---
    assertNotNull(p.getAddresses());
    assertTrue(p.getAddresses().getAddress().isEmpty());
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Bio filtered
    p = getPersonElement();
    p.getBiography().setVisibility(Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNull(p.getBiography());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Emails filtered
    p = getPersonElement();
    setVisibility(p.getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    // --- filtered ---
    assertNotNull(p.getEmails());
    assertTrue(p.getEmails().getEmails().isEmpty());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // External ids filtered
    p = getPersonElement();
    setVisibility(p.getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getExternalIdentifiers());
    assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Keywords filtered
    p = getPersonElement();
    setVisibility(p.getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getKeywords());
    assertTrue(p.getKeywords().getKeywords().isEmpty());
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Name filtered
    p = getPersonElement();
    p.getName().setVisibility(Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNull(p.getName());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Other names filtered
    p = getPersonElement();
    setVisibility(p.getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    // --- filtered ---
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Researcher urls filtered
    p = getPersonElement();
    setVisibility(p.getResearcherUrls().getResearcherUrls(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getResearcherUrls());
    assertTrue(p.getResearcherUrls().getResearcherUrls().isEmpty());
}
Also used : Person(org.orcid.jaxb.model.record_v2.Person) Test(org.junit.Test)

Example 68 with Keywords

use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method checkIsPublicRecordTest.

@Test
public void checkIsPublicRecordTest() {
    Record r = getRecordElement();
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - nothing filtered
    ActivitiesSummary as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    // Verify bio sections - nothing filtered
    Person p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertAllArePublic(p.getAddresses().getAddress());
    assertEquals(3, p.getEmails().getEmails().size());
    assertAllArePublic(p.getEmails().getEmails());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertAllArePublic(p.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertAllArePublic(p.getKeywords().getKeywords());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertAllArePublic(p.getOtherNames().getOtherNames());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertAllArePublic(p.getResearcherUrls().getResearcherUrls());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter biography, name, educations and funding
    r = getRecordElement();
    r.getPerson().getBiography().setVisibility(Visibility.LIMITED);
    r.getPerson().getName().setVisibility(Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - educations and funding filtered
    as = r.getActivitiesSummary();
    assertNotNull(as.getEducations());
    assertTrue(as.getEducations().getSummaries().isEmpty());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertTrue(as.getFundings().getFundingGroup().isEmpty());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    // Verify bio sections - bio and name filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNull(p.getBiography());
    assertNull(p.getName());
    // Filter emails, external identifiers, peer reviews and works
    r = getRecordElement();
    setVisibility(r.getPerson().getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - peer reviews and works filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
    assertTrue(as.getWorks().getWorkGroup().isEmpty());
    // Verify bio sections - emails, external identifiers filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertNotNull(p.getEmails());
    assertTrue(p.getEmails().getEmails().isEmpty());
    assertNotNull(p.getExternalIdentifiers());
    assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter keywords and other names
    r = getRecordElement();
    setVisibility(r.getPerson().getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - nothing filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    // Verify bio sections - keywords and other names filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertNotNull(p.getKeywords());
    assertTrue(p.getKeywords().getKeywords().isEmpty());
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
}
Also used : Record(org.orcid.jaxb.model.record_v2.Record) Person(org.orcid.jaxb.model.record_v2.Person) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test)

Example 69 with Keywords

use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.

the class OrcidInfo method groupKeywords.

private LinkedHashMap<String, List<Keyword>> groupKeywords(Keywords keywords) {
    if (keywords == null || keywords.getKeywords() == null) {
        return null;
    }
    /* Grouping items */
    LinkedHashMap<String, List<Keyword>> groups = new LinkedHashMap<String, List<Keyword>>();
    for (Keyword k : keywords.getKeywords()) {
        if (groups.containsKey(k.getContent())) {
            groups.get(k.getContent()).add(k);
        } else {
            List<Keyword> list = new ArrayList<Keyword>();
            list.add(k);
            groups.put(k.getContent(), list);
        }
    }
    return groups;
}
Also used : Keyword(org.orcid.jaxb.model.record_v2.Keyword) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap)

Example 70 with Keywords

use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.

the class KeywordsTest method testCreateGetUpdateAndDeleteKeyword_rc3.

/**
     * --------- -- -- -- RC3 -- -- -- ---------
     * 
     */
@SuppressWarnings({ "deprecation", "rawtypes" })
@Test
public void testCreateGetUpdateAndDeleteKeyword_rc3() throws InterruptedException, JSONException {
    changeDefaultUserVisibility(org.orcid.jaxb.model.common_v2.Visibility.LIMITED);
    changeCurrentKeywordsVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    String accessToken = getAccessToken();
    assertNotNull(accessToken);
    org.orcid.jaxb.model.record_rc3.Keyword newKeyword = new org.orcid.jaxb.model.record_rc3.Keyword();
    newKeyword.setContent("keyword-3");
    newKeyword.setVisibility(org.orcid.jaxb.model.common_rc3.Visibility.PUBLIC);
    // Create
    ClientResponse response = memberV2ApiClient_rc3.createKeyword(getUser1OrcidId(), newKeyword, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.CREATED.getStatusCode(), response.getStatus());
    Map map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List resultWithPutCode = (List) map.get("Location");
    String location = resultWithPutCode.get(0).toString();
    Long putCode = Long.valueOf(location.substring(location.lastIndexOf('/') + 1));
    // Get all and verify
    response = memberV2ApiClient_rc3.viewKeywords(getUser1OrcidId(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    Keywords keywords = response.getEntity(Keywords.class);
    assertNotNull(keywords);
    assertNotNull(keywords.getKeywords());
    boolean found1 = false;
    boolean found2 = false;
    boolean foundNew = false;
    for (org.orcid.jaxb.model.record_rc3.Keyword existingKeyword : keywords.getKeywords()) {
        if (existingKeyword.getContent().equals(keyword1)) {
            assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.PUBLIC, existingKeyword.getVisibility());
            found1 = true;
        } else if (existingKeyword.getContent().equals(keyword2)) {
            assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.PUBLIC, existingKeyword.getVisibility());
            found2 = true;
        } else if (existingKeyword.getContent().equals(newKeyword.getContent())) {
            assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.LIMITED, existingKeyword.getVisibility());
            assertEquals("keyword-3", existingKeyword.getContent());
            assertEquals(getClient1ClientId(), existingKeyword.getSource().retrieveSourcePath());
            foundNew = true;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(foundNew);
    // Get it
    response = memberV2ApiClient_rc3.viewKeyword(getUser1OrcidId(), putCode, accessToken);
    assertNotNull(response);
    newKeyword = response.getEntity(Keyword.class);
    assertNotNull(newKeyword);
    assertNotNull(newKeyword.getSource());
    assertEquals(getClient1ClientId(), newKeyword.getSource().retrieveSourcePath());
    assertEquals("keyword-3", newKeyword.getContent());
    assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.LIMITED, newKeyword.getVisibility());
    assertNotNull(newKeyword.getDisplayIndex());
    Long originalDisplayIndex = newKeyword.getDisplayIndex();
    // Save the original visibility
    org.orcid.jaxb.model.common_rc3.Visibility originalVisibility = newKeyword.getVisibility();
    org.orcid.jaxb.model.common_rc3.Visibility updatedVisibility = org.orcid.jaxb.model.common_rc3.Visibility.PRIVATE;
    // Verify you cant update the visibility
    newKeyword.setVisibility(updatedVisibility);
    ClientResponse putResponse = memberV2ApiClient_rc3.updateKeyword(getUser1OrcidId(), newKeyword, accessToken);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    org.orcid.jaxb.model.error_rc3.OrcidError error = putResponse.getEntity(org.orcid.jaxb.model.error_rc3.OrcidError.class);
    assertNotNull(error);
    assertEquals(Integer.valueOf(9035), error.getErrorCode());
    // Set the visibility again to the initial one
    newKeyword.setVisibility(originalVisibility);
    // Update
    newKeyword.setContent("keyword-3-updated");
    response = memberV2ApiClient_rc3.updateKeyword(getUser1OrcidId(), newKeyword, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.OK.getStatusCode(), response.getStatus());
    response = memberV2ApiClient_rc3.viewKeyword(getUser1OrcidId(), putCode, accessToken);
    assertNotNull(response);
    org.orcid.jaxb.model.record_rc3.Keyword updatedKeyword = response.getEntity(Keyword.class);
    assertNotNull(updatedKeyword);
    assertEquals("keyword-3-updated", updatedKeyword.getContent());
    assertEquals(newKeyword.getPutCode(), updatedKeyword.getPutCode());
    assertEquals(originalDisplayIndex, updatedKeyword.getDisplayIndex());
    // Delete
    response = memberV2ApiClient_rc3.deleteKeyword(getUser1OrcidId(), putCode, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Keywords(org.orcid.jaxb.model.record_rc3.Keywords) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) List(java.util.List) Map(java.util.Map) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)62 Keywords (org.orcid.jaxb.model.record_v2.Keywords)54 Keyword (org.orcid.jaxb.model.record_v2.Keyword)53 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)37 Address (org.orcid.jaxb.model.record_v2.Address)36 Biography (org.orcid.jaxb.model.record_v2.Biography)36 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)36 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Email (org.orcid.jaxb.model.record_v2.Email)35 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)35 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 OtherName (org.orcid.jaxb.model.record_v2.OtherName)34 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Name (org.orcid.jaxb.model.record_v2.Name)30 Person (org.orcid.jaxb.model.record_v2.Person)28 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)17 Record (org.orcid.jaxb.model.record_v2.Record)17