Search in sources :

Example 71 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPublic_NoSource_ReadLimitedToken.

@Test
public void testPersonalDetails_When_AllPublic_NoSource_ReadLimitedToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
    Name name = createName(Visibility.PUBLIC);
    Biography bio = createBiography(Visibility.PUBLIC);
    OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherName o3 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherNames otherNames = new OtherNames();
    otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
    PersonalDetails p = new PersonalDetails();
    p.setBiography(bio);
    p.setName(name);
    p.setOtherNames(otherNames);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertEquals(name, p.getName());
    assertEquals(bio, p.getBiography());
    assertNotNull(p.getOtherNames());
    assertNotNull(p.getOtherNames().getOtherNames());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertTrue(p.getOtherNames().getOtherNames().contains(o1));
    assertTrue(p.getOtherNames().getOtherNames().contains(o2));
    assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 72 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPrivate_NoSource_ReadPublicToken.

@Test
public void testPersonalDetails_When_AllPrivate_NoSource_ReadPublicToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    Name name = createName(Visibility.PRIVATE);
    Biography bio = createBiography(Visibility.PRIVATE);
    OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherNames otherNames = new OtherNames();
    otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
    PersonalDetails p = new PersonalDetails();
    p.setBiography(bio);
    p.setName(name);
    p.setOtherNames(otherNames);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertNull(p.getName());
    assertNull(p.getBiography());
    assertNotNull(p.getOtherNames());
    assertNotNull(p.getOtherNames().getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 73 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_SomePrivate_NoSource_ReadLimitedToken.

@Test
public void testPersonalDetails_When_SomePrivate_NoSource_ReadLimitedToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
    Name name = createName(Visibility.PRIVATE);
    Biography bio = createBiography(Visibility.PUBLIC);
    OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherName o3 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherNames otherNames = new OtherNames();
    otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
    PersonalDetails p = new PersonalDetails();
    p.setBiography(bio);
    p.setName(name);
    p.setOtherNames(otherNames);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertNull(p.getName());
    assertEquals(bio, p.getBiography());
    assertNotNull(p.getOtherNames());
    assertNotNull(p.getOtherNames().getOtherNames());
    assertEquals(2, p.getOtherNames().getOtherNames().size());
    assertFalse(p.getOtherNames().getOtherNames().contains(o1));
    assertTrue(p.getOtherNames().getOtherNames().contains(o2));
    assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 74 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPrivate_Source_ReadPublicToken.

@Test
public void testPersonalDetails_When_AllPrivate_Source_ReadPublicToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    Name name = createName(Visibility.PRIVATE);
    Biography bio = createBiography(Visibility.PRIVATE);
    OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_1);
    OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_1);
    OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_1);
    OtherNames otherNames = new OtherNames();
    otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
    PersonalDetails p = new PersonalDetails();
    p.setBiography(bio);
    p.setName(name);
    p.setOtherNames(otherNames);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertNull(p.getName());
    assertNull(p.getBiography());
    assertNotNull(p.getOtherNames());
    assertNotNull(p.getOtherNames().getOtherNames());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertTrue(p.getOtherNames().getOtherNames().contains(o1));
    assertTrue(p.getOtherNames().getOtherNames().contains(o2));
    assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 75 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class MemberV2Test method createViewUpdateAndDeleteEducation.

@Test
public void createViewUpdateAndDeleteEducation() throws JSONException, InterruptedException, URISyntaxException {
    Education education = (Education) unmarshallFromPath("/record_2.0_rc3/samples/education-2.0_rc3.xml", Education.class);
    education.setPutCode(null);
    education.setVisibility(Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createEducationXml(this.getUser1OrcidId(), education, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String locationPath = postResponse.getLocation().getPath();
    assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0_rc3/" + this.getUser1OrcidId() + "/education/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Education gotEducation = getResponse.getEntity(Education.class);
    assertEquals("education:department-name", gotEducation.getDepartmentName());
    assertEquals("education:role-title", gotEducation.getRoleTitle());
    //Save the original visibility
    Visibility originalVisibility = gotEducation.getVisibility();
    Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
    //Verify you cant update the visibility
    gotEducation.setVisibility(updatedVisibility);
    ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotEducation);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    OrcidError error = putResponse.getEntity(OrcidError.class);
    assertNotNull(error);
    assertEquals(Integer.valueOf(9035), error.getErrorCode());
    //Set the visibility again to the initial one
    gotEducation.setVisibility(originalVisibility);
    gotEducation.setDepartmentName("updated dept. name");
    gotEducation.setRoleTitle("updated role title");
    putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotEducation);
    assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Education gotAfterUpdateEducation = getAfterUpdateResponse.getEntity(Education.class);
    assertEquals("updated dept. name", gotAfterUpdateEducation.getDepartmentName());
    assertEquals("updated role title", gotAfterUpdateEducation.getRoleTitle());
    ClientResponse deleteResponse = memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), gotEducation.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidError(org.orcid.jaxb.model.error_rc3.OrcidError) Education(org.orcid.jaxb.model.record_rc3.Education) Visibility(org.orcid.jaxb.model.common_rc3.Visibility) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)92 Name (org.orcid.jaxb.model.record_v2.Name)75 OtherName (org.orcid.jaxb.model.record_v2.OtherName)61 Biography (org.orcid.jaxb.model.record_v2.Biography)45 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)40 Address (org.orcid.jaxb.model.record_v2.Address)30 Email (org.orcid.jaxb.model.record_v2.Email)30 Emails (org.orcid.jaxb.model.record_v2.Emails)29 Keyword (org.orcid.jaxb.model.record_v2.Keyword)29 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)29 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)29 Addresses (org.orcid.jaxb.model.record_v2.Addresses)28 Keywords (org.orcid.jaxb.model.record_v2.Keywords)28 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)28 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)28 Person (org.orcid.jaxb.model.record_v2.Person)26 ClientResponse (com.sun.jersey.api.client.ClientResponse)17 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)17