Search in sources :

Example 31 with EmploymentSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewEmploymentSummaryReadPublic.

@Test
public void testViewEmploymentSummaryReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEmploymentSummary(ORCID, 17L);
    EmploymentSummary element = (EmploymentSummary) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/employment/17", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with EmploymentSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_EmploymentsTest method testAddEmployment.

@Test
public void testAddEmployment() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    assertNotNull(summary.getEmployments());
    assertNotNull(summary.getEmployments().getSummaries());
    assertNotNull(summary.getEmployments().getSummaries().get(0));
    assertEquals(4, summary.getEmployments().getSummaries().size());
    response = serviceDelegator.createEmployment(ORCID, (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
    assertNotNull(summaryWithNewElement);
    Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getEmployments());
    Utils.verifyLastModified(summaryWithNewElement.getEmployments().getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getEmployments().getSummaries());
    assertEquals(5, summaryWithNewElement.getEmployments().getSummaries().size());
    boolean haveNew = false;
    for (EmploymentSummary eSummary : summaryWithNewElement.getEmployments().getSummaries()) {
        assertNotNull(eSummary.getPutCode());
        Utils.verifyLastModified(eSummary.getLastModifiedDate());
        if (eSummary.getPutCode().equals(putCode)) {
            assertEquals("My department name", eSummary.getDepartmentName());
            haveNew = true;
        } else {
            assertTrue(summary.getEmployments().getSummaries().contains(eSummary));
        }
    }
    assertTrue(haveNew);
    // Delete new element
    serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with EmploymentSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewEmployments.

@Test
public void testViewEmployments() {
    Response response = serviceDelegator.viewEmployments(ORCID);
    assertNotNull(response);
    Employments employments = (Employments) response.getEntity();
    assertNotNull(employments);
    assertEquals("/0000-0000-0000-0003/employments", employments.getPath());
    assertNotNull(employments.getLastModifiedDate());
    assertNotNull(employments.getLastModifiedDate().getValue());
    assertEquals(1, employments.getSummaries().size());
    EmploymentSummary employment = employments.getSummaries().get(0);
    assertEquals(Long.valueOf(17), employment.getPutCode());
    assertNotNull(employment.getLastModifiedDate());
    assertNotNull(employment.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/employment/17", employment.getPath());
    assertEquals("PUBLIC Department", employment.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), employment.getVisibility().value());
    assertEquals("APP-5555555555555555", employment.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Employments(org.orcid.jaxb.model.v3.dev1.record.summary.Employments) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with EmploymentSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method getEmployments.

private Employments getEmployments(Visibility... vs) {
    Employments e = new Employments();
    for (Visibility v : vs) {
        EmploymentSummary s = new EmploymentSummary();
        s.setVisibility(v);
        e.getSummaries().add(s);
    }
    return e;
}
Also used : Employments(org.orcid.jaxb.model.v3.dev1.record.summary.Employments) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility)

Example 35 with EmploymentSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getEmploymentMapperFacade.

public MapperFacade getEmploymentMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<Employment, OrgAffiliationRelationEntity> classMap = mapperFactory.classMap(Employment.class, OrgAffiliationRelationEntity.class);
    ClassMapBuilder<EmploymentSummary, OrgAffiliationRelationEntity> summaryClassMap = mapperFactory.classMap(EmploymentSummary.class, OrgAffiliationRelationEntity.class);
    return generateMapperFacadeForAffiliation(mapperFactory, classMap, summaryClassMap);
}
Also used : Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Aggregations

EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)55 Test (org.junit.Test)43 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)41 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)40 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)40 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)39 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)37 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)35 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)35 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)35 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)35 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)35 Address (org.orcid.jaxb.model.v3.dev1.record.Address)15 Email (org.orcid.jaxb.model.v3.dev1.record.Email)15 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)15 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)15 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)15 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)15 Name (org.orcid.jaxb.model.v3.dev1.record.Name)14