Search in sources :

Example 26 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testDeleteQualification.

@Test
public void testDeleteQualification() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewQualification("0000-0000-0000-0002", 1005L);
    assertNotNull(response);
    Qualification qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1005L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    try {
        serviceDelegator.viewQualification("0000-0000-0000-0002", 1005L);
        fail();
    } catch (NoResultException nre) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) NoResultException(javax.persistence.NoResultException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 27 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualificationYouAreNotTheSourceOf.

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

Example 28 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testViewQualificationReadPublic.

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

Example 29 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testAddQualification.

@Test
public void testAddQualification() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
    assertNotNull(originalSummary);
    Utils.verifyLastModified(originalSummary.getLastModifiedDate());
    assertNotNull(originalSummary.getQualifications());
    Utils.verifyLastModified(originalSummary.getQualifications().getLastModifiedDate());
    assertNotNull(originalSummary.getQualifications().getSummaries());
    assertNotNull(originalSummary.getQualifications().getSummaries().get(0));
    Utils.verifyLastModified(originalSummary.getQualifications().getSummaries().get(0).getLastModifiedDate());
    assertEquals(4, originalSummary.getQualifications().getSummaries().size());
    response = serviceDelegator.createQualification(ORCID, (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION));
    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.getQualifications());
    Utils.verifyLastModified(summaryWithNewElement.getQualifications().getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getQualifications().getSummaries());
    assertEquals(5, summaryWithNewElement.getQualifications().getSummaries().size());
    boolean haveNew = false;
    for (QualificationSummary qualificationSummary : summaryWithNewElement.getQualifications().getSummaries()) {
        assertNotNull(qualificationSummary.getPutCode());
        Utils.verifyLastModified(qualificationSummary.getLastModifiedDate());
        if (qualificationSummary.getPutCode().equals(putCode)) {
            assertEquals("My department name", qualificationSummary.getDepartmentName());
            haveNew = true;
        } else {
            assertTrue(originalSummary.getQualifications().getSummaries().contains(qualificationSummary));
        }
    }
    assertTrue(haveNew);
    // Remove new element
    serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Also used : Response(javax.ws.rs.core.Response) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) QualificationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 30 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualificationChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateQualificationChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewQualification(ORCID, 43L);
    assertNotNull(response);
    Qualification qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    assertEquals(Visibility.LIMITED, qualification.getVisibility());
    qualification.setVisibility(Visibility.PUBLIC);
    response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)40 Test (org.junit.Test)31 DBUnitTest (org.orcid.test.DBUnitTest)18 Response (javax.ws.rs.core.Response)17 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Education (org.orcid.jaxb.model.v3.dev1.record.Education)11 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)10 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)10 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)8 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)7 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)6 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 Work (org.orcid.jaxb.model.v3.dev1.record.Work)4 Qualifications (org.orcid.jaxb.model.v3.dev1.record.summary.Qualifications)4