Search in sources :

Example 1 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualification.

@Test
public void testUpdateQualification() {
    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("LIMITED Department", qualification.getDepartmentName());
    assertEquals("LIMITED", qualification.getRoleTitle());
    Utils.verifyLastModified(qualification.getLastModifiedDate());
    LastModifiedDate before = qualification.getLastModifiedDate();
    qualification.setDepartmentName("Updated department name");
    qualification.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    qualification.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewQualification(ORCID, 43L);
    assertNotNull(response);
    qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    Utils.verifyLastModified(qualification.getLastModifiedDate());
    assertTrue(qualification.getLastModifiedDate().after(before));
    assertEquals("Updated department name", qualification.getDepartmentName());
    assertEquals("The updated role title", qualification.getRoleTitle());
    // Rollback changes
    qualification.setDepartmentName("LIMITED Department");
    qualification.setRoleTitle("QUALIFICATION");
    response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testAddQualificationNoStartDate.

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

Example 3 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testViewLimitedQualification.

@Test
public void testViewLimitedQualification() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewQualification(ORCID, 45L);
    assertNotNull(response);
    Qualification qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    Utils.verifyLastModified(qualification.getLastModifiedDate());
    assertEquals(Long.valueOf(45L), qualification.getPutCode());
    assertEquals("/0000-0000-0000-0003/qualification/45", qualification.getPath());
    assertEquals("SELF LIMITED Department", qualification.getDepartmentName());
    assertEquals(Visibility.LIMITED.value(), qualification.getVisibility().value());
}
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 4 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualificationDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateQualificationDuplicateExternalIDs() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    ExternalID e1 = new ExternalID();
    e1.setRelationship(Relationship.SELF);
    e1.setType("erm");
    e1.setUrl(new Url("https://orcid.org"));
    e1.setValue("err");
    ExternalID e2 = new ExternalID();
    e2.setRelationship(Relationship.SELF);
    e2.setType("err");
    e2.setUrl(new Url("http://bbc.co.uk"));
    e2.setValue("erm");
    ExternalIDs externalIDs = new ExternalIDs();
    externalIDs.getExternalIdentifier().add(e1);
    externalIDs.getExternalIdentifier().add(e2);
    Qualification qualification = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
    qualification.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createQualification(ORCID, qualification);
    assertNotNull(response);
    assertEquals(HttpStatus.SC_CREATED, response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    Qualification another = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
    response = serviceDelegator.createQualification(ORCID, another);
    map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    resultWithPutCode = (List<?>) map.get("Location");
    Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewQualification(ORCID, putCode2);
    another = (Qualification) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateQualification(ORCID, putCode2, another);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode1);
        serviceDelegator.deleteAffiliation(ORCID, putCode2);
    }
}
Also used : Response(javax.ws.rs.core.Response) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) List(java.util.List) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with Qualification

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testViewQualifications.

@Test
public void testViewQualifications() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewQualifications(ORCID);
    assertNotNull(r);
    Qualifications qualifications = (Qualifications) r.getEntity();
    assertNotNull(qualifications);
    assertEquals("/0000-0000-0000-0003/qualifications", qualifications.getPath());
    Utils.verifyLastModified(qualifications.getLastModifiedDate());
    assertNotNull(qualifications.getSummaries());
    assertEquals(4, qualifications.getSummaries().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (QualificationSummary summary : qualifications.getSummaries()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        if (Long.valueOf(42).equals(summary.getPutCode())) {
            assertEquals("PUBLIC Department", summary.getDepartmentName());
            found1 = true;
        } else if (Long.valueOf(43).equals(summary.getPutCode())) {
            assertEquals("LIMITED Department", summary.getDepartmentName());
            found2 = true;
        } else if (Long.valueOf(44).equals(summary.getPutCode())) {
            assertEquals("PRIVATE Department", summary.getDepartmentName());
            found3 = true;
        } else if (Long.valueOf(45).equals(summary.getPutCode())) {
            assertEquals("SELF LIMITED Department", summary.getDepartmentName());
            found4 = true;
        } else {
            fail("Invalid qualification found: " + summary.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) QualificationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary) Qualifications(org.orcid.jaxb.model.v3.dev1.record.summary.Qualifications) 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