Search in sources :

Example 31 with Service

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

the class MemberV3ApiServiceDelegator_ServicesTest method testAddServiceNoStartDate.

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

Example 32 with Service

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

the class MemberV3ApiServiceDelegator_ServicesTest method testViewPublicService.

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

Example 33 with Service

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

the class MemberV3ApiServiceDelegator_ServicesTest method testUpdateServiceDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateServiceDuplicateExternalIDs() {
    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);
    Service service = (Service) Utils.getAffiliation(AffiliationType.SERVICE);
    service.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createService(ORCID, service);
    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)));
    Service another = (Service) Utils.getAffiliation(AffiliationType.SERVICE);
    response = serviceDelegator.createService(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.viewService(ORCID, putCode2);
    another = (Service) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateService(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) Service(org.orcid.jaxb.model.v3.dev1.record.Service) 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 34 with Service

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

the class MemberV3ApiServiceDelegator_ServicesTest method testViewServiceReadPublic.

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

Example 35 with Service

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

the class MemberV3ApiServiceDelegator_ServicesTest method testViewServices.

@Test
public void testViewServices() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewServices(ORCID);
    assertNotNull(r);
    Services services = (Services) r.getEntity();
    assertNotNull(services);
    assertEquals("/0000-0000-0000-0003/services", services.getPath());
    Utils.verifyLastModified(services.getLastModifiedDate());
    assertNotNull(services.getSummaries());
    assertEquals(4, services.getSummaries().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (ServiceSummary summary : services.getSummaries()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        if (Long.valueOf(47).equals(summary.getPutCode())) {
            assertEquals("PUBLIC Department", summary.getDepartmentName());
            found1 = true;
        } else if (Long.valueOf(48).equals(summary.getPutCode())) {
            assertEquals("LIMITED Department", summary.getDepartmentName());
            found2 = true;
        } else if (Long.valueOf(49).equals(summary.getPutCode())) {
            assertEquals("PRIVATE Department", summary.getDepartmentName());
            found3 = true;
        } else if (Long.valueOf(50).equals(summary.getPutCode())) {
            assertEquals("SELF LIMITED Department", summary.getDepartmentName());
            found4 = true;
        } else {
            fail("Invalid service found: " + summary.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Service (org.orcid.jaxb.model.v3.dev1.record.Service)41 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 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 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)7 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)6 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)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 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)4 Services (org.orcid.jaxb.model.v3.dev1.record.summary.Services)4