Search in sources :

Example 16 with Education

use of org.orcid.jaxb.model.record_v2.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 17 with Education

use of org.orcid.jaxb.model.record_v2.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 18 with Education

use of org.orcid.jaxb.model.record_v2.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 19 with Education

use of org.orcid.jaxb.model.record_v2.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 20 with Education

use of org.orcid.jaxb.model.record_v2.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

Test (org.junit.Test)44 Education (org.orcid.jaxb.model.record_v2.Education)42 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)14 DBUnitTest (org.orcid.test.DBUnitTest)14 OtherName (org.orcid.jaxb.model.record_v2.OtherName)9 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)9 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 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)6 Address (org.orcid.jaxb.model.record_v2.Address)6 Keyword (org.orcid.jaxb.model.record_v2.Keyword)6 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)6 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)5 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)5