Search in sources :

Example 41 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testUpdateEducation.

@Test
public void testUpdateEducation() {
    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("Another Department", education.getDepartmentName());
    assertEquals("Student", education.getRoleTitle());
    Utils.verifyLastModified(education.getLastModifiedDate());
    LastModifiedDate before = education.getLastModifiedDate();
    education.setDepartmentName("Updated department name");
    education.setRoleTitle("The updated role title");
    response = serviceDelegator.updateEducation("4444-4444-4444-4443", 3L, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewEducation("4444-4444-4444-4443", 3L);
    assertNotNull(response);
    education = (Education) response.getEntity();
    assertNotNull(education);
    Utils.verifyLastModified(education.getLastModifiedDate());
    assertTrue(education.getLastModifiedDate().after(before));
    assertEquals("Updated department name", education.getDepartmentName());
    assertEquals("The updated role title", education.getRoleTitle());
    // Rollback changes
    education.setDepartmentName("Another Department");
    education.setRoleTitle("Student");
    response = serviceDelegator.updateEducation("4444-4444-4444-4443", 3L, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Education(org.orcid.jaxb.model.record_v2.Education) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 42 with Education

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

the class SourceInActivitiesTest method getEducation.

private Education getEducation(String userOrcid) {
    Education education = new Education();
    education.setOrganization(getOrganization());
    education = affiliationsManager.createEducationAffiliation(userOrcid, education, true);
    return affiliationsManager.getEducationAffiliation(userOrcid, education.getPutCode());
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education)

Example 43 with Education

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

the class SourceInActivitiesTest method getAffiliationWithPutCode.

private Education getAffiliationWithPutCode(String userOrcid) {
    Education education = new Education();
    education.setOrganization(getOrganization());
    education.setPutCode(Long.valueOf(111));
    education = affiliationsManager.createEducationAffiliation(userOrcid, education, true);
    return affiliationsManager.getEducationAffiliation(userOrcid, education.getPutCode());
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education)

Example 44 with Education

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

the class JpaJaxbEducationAdapterTest method fromOrgAffiliationRelationEntityToEducation.

@Test
public void fromOrgAffiliationRelationEntityToEducation() {
    OrgAffiliationRelationEntity entity = getEducationEntity();
    assertNotNull(entity);
    Education education = jpaJaxbEducationAdapter.toEducation(entity);
    assertNotNull(education);
    assertEquals("education:department", education.getDepartmentName());
    assertEquals(Long.valueOf(123456), education.getPutCode());
    assertEquals("education:title", education.getRoleTitle());
    assertEquals("private", education.getVisibility().value());
    assertNotNull(education.getStartDate());
    assertEquals("2000", education.getStartDate().getYear().getValue());
    assertEquals("01", education.getStartDate().getMonth().getValue());
    assertEquals("01", education.getStartDate().getDay().getValue());
    assertEquals("2020", education.getEndDate().getYear().getValue());
    assertEquals("02", education.getEndDate().getMonth().getValue());
    assertEquals("02", education.getEndDate().getDay().getValue());
    assertNotNull(education.getOrganization());
    assertEquals("org:name", education.getOrganization().getName());
    assertNotNull(education.getOrganization().getAddress());
    assertEquals("org:city", education.getOrganization().getAddress().getCity());
    assertEquals("org:region", education.getOrganization().getAddress().getRegion());
    assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.US, education.getOrganization().getAddress().getCountry());
    assertNotNull(education.getSource());
    assertNotNull(education.getSource().retrieveSourcePath());
    assertEquals("APP-000000001", education.getSource().retrieveSourcePath());
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 45 with Education

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

Aggregations

Test (org.junit.Test)42 Education (org.orcid.jaxb.model.record_v2.Education)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 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 Employment (org.orcid.jaxb.model.record_v2.Employment)4 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)4