Search in sources :

Example 46 with Employment

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewEmploymentReadPublic.

@Test
public void testViewEmploymentReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEmployment(ORCID, 17L);
    Employment element = (Employment) 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) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 47 with Employment

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testAddEmploymentNoStartDate.

@Test(expected = OrcidValidationException.class)
public void testAddEmploymentNoStartDate() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Employment employment = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
    employment.setStartDate(null);
    serviceDelegator.createEmployment(ORCID, employment);
}
Also used : Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 48 with Employment

use of org.orcid.jaxb.model.v3.dev1.record.Employment 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 49 with Employment

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateEmploymentYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment(ORCID, 23L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    employment.setDepartmentName("Updated department name");
    employment.setRoleTitle("The updated role title");
    serviceDelegator.updateEmployment(ORCID, 23L, employment);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 50 with Employment

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentLeavingVisibilityNullTest.

@Test
public void testUpdateEmploymentLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment(ORCID, 19L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
    employment.setVisibility(null);
    response = serviceDelegator.updateEmployment(ORCID, 19L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)61 Test (org.junit.Test)53 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)20 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)18 Education (org.orcid.jaxb.model.v3.dev1.record.Education)13 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)10 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Day (org.orcid.jaxb.model.v3.dev1.common.Day)8 Month (org.orcid.jaxb.model.v3.dev1.common.Month)8 Year (org.orcid.jaxb.model.v3.dev1.common.Year)8 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)8 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)8 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)7 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)6 Work (org.orcid.jaxb.model.v3.dev1.record.Work)6