Search in sources :

Example 56 with Education

use of org.orcid.jaxb.model.record_rc2.Education in project ORCID-Source by ORCID.

the class JpaJaxbEducationAdapterTest method testToOrgAffiliationRelationEntity.

@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
    Education e = getEducation(true);
    assertNotNull(e);
    OrgAffiliationRelationEntity oar = jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity(e);
    assertNotNull(oar);
    //General info
    assertEquals(Long.valueOf(0), oar.getId());
    assertEquals(Visibility.PRIVATE.value(), oar.getVisibility().value());
    assertEquals("education:department-name", oar.getDepartment());
    assertEquals("education:role-title", oar.getTitle());
    //Dates
    assertEquals(Integer.valueOf(2), oar.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getEndDate().getYear());
    // Source
    assertNull(oar.getSourceId());
    assertNull(oar.getClientSourceId());
    assertNull(oar.getElementSourceId());
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 57 with Education

use of org.orcid.jaxb.model.record_rc2.Education in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateEducation_dontChangeVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void validateEducation_dontChangeVisibilityTest() {
    Education education = getEducation();
    education.setVisibility(Visibility.LIMITED);
    activityValidator.validateEducation(education, null, false, true, Visibility.PUBLIC);
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education) Test(org.junit.Test)

Example 58 with Education

use of org.orcid.jaxb.model.record_rc2.Education in project ORCID-Source by ORCID.

the class MemberV2_1Test method createViewUpdateAndDeleteEducation.

@Test
public void createViewUpdateAndDeleteEducation() throws JSONException, InterruptedException, URISyntaxException {
    Education education = (Education) unmarshallFromPath("/record_2.1/samples/read_samples/education-2.1.xml", Education.class);
    education.setPutCode(null);
    education.setVisibility(Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2_1ApiClient.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.1/" + this.getUser1OrcidId() + "/education/\\d+"));
    ClientResponse getResponse = memberV2_1ApiClient.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 = memberV2_1ApiClient.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 = memberV2_1ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotEducation);
    assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2_1ApiClient.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 = memberV2_1ApiClient.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_v2.OrcidError) Education(org.orcid.jaxb.model.record_v2.Education) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Test(org.junit.Test)

Example 59 with Education

use of org.orcid.jaxb.model.record_rc2.Education in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewEducation.

@Test
public void testViewEducation() {
    Response response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    assertNotNull(education.getLastModifiedDate());
    assertNotNull(education.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(20), education.getPutCode());
    assertEquals("/0000-0000-0000-0003/education/20", education.getPath());
    assertEquals("PUBLIC Department", education.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
    assertEquals("APP-5555555555555555", education.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.record_v2.Education) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 60 with Education

use of org.orcid.jaxb.model.record_rc2.Education in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testGetPublicEducationUsingToken.

// Education
@Test
public void testGetPublicEducationUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(r);
    Education e = (Education) r.getEntity();
    assertNotNull(e);
    assertNotNull(e.getLastModifiedDate());
    assertNotNull(e.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(20), e.getPutCode());
}
Also used : Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.record_v2.Education) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Education (org.orcid.jaxb.model.record_v2.Education)45 Test (org.junit.Test)42 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)13 DBUnitTest (org.orcid.test.DBUnitTest)13 Funding (org.orcid.jaxb.model.record_v2.Funding)8 Work (org.orcid.jaxb.model.record_v2.Work)8 Education (org.orcid.jaxb.model.record_rc1.Education)7 IOException (java.io.IOException)6 InputStreamReader (java.io.InputStreamReader)6 Reader (java.io.Reader)6 ArrayList (java.util.ArrayList)6 Employment (org.orcid.jaxb.model.record_v2.Employment)6 OtherName (org.orcid.jaxb.model.record_v2.OtherName)5 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)5 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)4 Education (org.orcid.jaxb.model.record_rc2.Education)4 Education (org.orcid.jaxb.model.record_rc3.Education)4 Education (org.orcid.jaxb.model.record_rc4.Education)4 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)4