Search in sources :

Example 31 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewPrivateDistinction.

@Test
public void testViewPrivateDistinction() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewDistinction(ORCID, 29L);
    assertNotNull(response);
    Distinction distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    Utils.verifyLastModified(distinction.getLastModifiedDate());
    assertEquals(Long.valueOf(29L), distinction.getPutCode());
    assertEquals("/0000-0000-0000-0003/distinction/29", distinction.getPath());
    assertEquals("PRIVATE Department", distinction.getDepartmentName());
    assertEquals(Visibility.PRIVATE.value(), distinction.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewPublicDistinction.

@Test
public void testViewPublicDistinction() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewDistinction(ORCID, 27L);
    assertNotNull(response);
    Distinction distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    Utils.verifyLastModified(distinction.getLastModifiedDate());
    assertEquals(Long.valueOf(27L), distinction.getPutCode());
    assertEquals("/0000-0000-0000-0003/distinction/27", distinction.getPath());
    assertEquals("PUBLIC Department", distinction.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), distinction.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewDistinctionReadPublic.

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

Example 34 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testUpdateDistinctionDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateDistinctionDuplicateExternalIDs() {
    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);
    Distinction distinction = (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION);
    distinction.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createDistinction(ORCID, distinction);
    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)));
    Distinction another = (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION);
    response = serviceDelegator.createDistinction(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.viewDistinction(ORCID, putCode2);
    another = (Distinction) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateDistinction(ORCID, putCode2, another);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode1);
        serviceDelegator.deleteAffiliation(ORCID, putCode2);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) List(java.util.List) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) 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 35 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testAddDistinction.

@Test
public void testAddDistinction() {
    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.getDistinctions());
    Utils.verifyLastModified(originalSummary.getDistinctions().getLastModifiedDate());
    assertNotNull(originalSummary.getDistinctions().getSummaries());
    assertNotNull(originalSummary.getDistinctions().getSummaries().get(0));
    Utils.verifyLastModified(originalSummary.getDistinctions().getSummaries().get(0).getLastModifiedDate());
    assertEquals(4, originalSummary.getDistinctions().getSummaries().size());
    response = serviceDelegator.createDistinction(ORCID, (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION));
    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.getDistinctions());
    Utils.verifyLastModified(summaryWithNewElement.getDistinctions().getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getDistinctions().getSummaries());
    assertEquals(5, summaryWithNewElement.getDistinctions().getSummaries().size());
    boolean haveNew = false;
    for (DistinctionSummary distinctionSummary : summaryWithNewElement.getDistinctions().getSummaries()) {
        assertNotNull(distinctionSummary.getPutCode());
        Utils.verifyLastModified(distinctionSummary.getLastModifiedDate());
        if (distinctionSummary.getPutCode().equals(putCode)) {
            assertEquals("My department name", distinctionSummary.getDepartmentName());
            haveNew = true;
        } else {
            assertTrue(originalSummary.getDistinctions().getSummaries().contains(distinctionSummary));
        }
    }
    assertTrue(haveNew);
    // Remove new element
    serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Also used : Response(javax.ws.rs.core.Response) DistinctionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary) List(java.util.List) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)41 Test (org.junit.Test)31 DBUnitTest (org.orcid.test.DBUnitTest)18 Response (javax.ws.rs.core.Response)17 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 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)8 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)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 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 Work (org.orcid.jaxb.model.v3.dev1.record.Work)4 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)3