Search in sources :

Example 11 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testViewPublicEducation.

@Test
public void testViewPublicEducation() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewEducation("4444-4444-4444-4446", 7L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    Utils.verifyLastModified(education.getLastModifiedDate());
    assertEquals(Long.valueOf(7L), education.getPutCode());
    assertEquals("/4444-4444-4444-4446/education/7", education.getPath());
    assertEquals("Education Dept # 2", education.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
}
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 12 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testViewPrivateEducation.

@Test
public void testViewPrivateEducation() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewEducation("4444-4444-4444-4446", 6L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    Utils.verifyLastModified(education.getLastModifiedDate());
    assertEquals(Long.valueOf(6L), education.getPutCode());
    assertEquals("/4444-4444-4444-4446/education/6", education.getPath());
    assertEquals("Education Dept # 1", education.getDepartmentName());
    assertEquals(Visibility.PRIVATE.value(), education.getVisibility().value());
}
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 13 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testUpdateEducationChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateEducationChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEducation("4444-4444-4444-4443", 3L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    assertEquals(Visibility.PUBLIC, education.getVisibility());
    education.setVisibility(education.getVisibility().equals(Visibility.PRIVATE) ? Visibility.LIMITED : Visibility.PRIVATE);
    response = serviceDelegator.updateEducation("4444-4444-4444-4443", 3L, education);
    fail();
}
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 14 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testViewEducationReadPublic.

@Test
public void testViewEducationReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEducation(ORCID, 20L);
    Education element = (Education) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/education/20", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
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 15 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testUpdateEducationYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateEducationYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEducation("4444-4444-4444-4442", 1L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    education.setDepartmentName("Updated department name");
    education.setRoleTitle("The updated role title");
    serviceDelegator.updateEducation("4444-4444-4444-4442", 1L, education);
    fail();
}
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