Search in sources :

Example 61 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testUpdateEducationLeavingVisibilityNullTest.

@Test
public void testUpdateEducationLeavingVisibilityNullTest() {
    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(null);
    response = serviceDelegator.updateEducation("4444-4444-4444-4443", 3L, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    education = (Education) response.getEntity();
    assertNotNull(education);
    assertEquals(Visibility.PUBLIC, education.getVisibility());
}
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 62 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testDeleteEducation.

@Test(expected = NoResultException.class)
public void testDeleteEducation() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEducation("4444-4444-4444-4447", 12L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    response = serviceDelegator.deleteAffiliation("4444-4444-4444-4447", 12L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    serviceDelegator.viewEducation("4444-4444-4444-4447", 12L);
}
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 63 with Education

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

the class MemberV2ApiServiceDelegator_EducationsTest method testViewLimitedEducation.

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

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

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

the class MapperFacadeFactory method getEducationMapperFacade.

public MapperFacade getEducationMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<Education, OrgAffiliationRelationEntity> educationClassMap = mapperFactory.classMap(Education.class, OrgAffiliationRelationEntity.class);
    addV2CommonFields(educationClassMap);
    registerSourceConverters(mapperFactory, educationClassMap);
    educationClassMap.fieldBToA("org.name", "organization.name");
    educationClassMap.fieldBToA("org.city", "organization.address.city");
    educationClassMap.fieldBToA("org.region", "organization.address.region");
    educationClassMap.fieldBToA("org.country", "organization.address.country");
    educationClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    educationClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    educationClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    educationClassMap.field("departmentName", "department");
    educationClassMap.field("roleTitle", "title");
    educationClassMap.register();
    ClassMapBuilder<EducationSummary, OrgAffiliationRelationEntity> educationSummaryClassMap = mapperFactory.classMap(EducationSummary.class, OrgAffiliationRelationEntity.class);
    addV2CommonFields(educationSummaryClassMap);
    registerSourceConverters(mapperFactory, educationSummaryClassMap);
    educationSummaryClassMap.fieldBToA("org.name", "organization.name");
    educationSummaryClassMap.fieldBToA("org.city", "organization.address.city");
    educationSummaryClassMap.fieldBToA("org.region", "organization.address.region");
    educationSummaryClassMap.fieldBToA("org.country", "organization.address.country");
    educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    educationSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    educationSummaryClassMap.field("departmentName", "department");
    educationSummaryClassMap.field("roleTitle", "title");
    educationSummaryClassMap.register();
    mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    return mapperFactory.getMapperFacade();
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Aggregations

Education (org.orcid.jaxb.model.record_v2.Education)45 Test (org.junit.Test)41 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 IOException (java.io.IOException)7 InputStreamReader (java.io.InputStreamReader)7 Reader (java.io.Reader)7 Education (org.orcid.jaxb.model.record_rc1.Education)7 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