Search in sources :

Example 1 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testAddDistinctionsDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddDistinctionsDuplicateExternalIDs() {
    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 putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    try {
        Distinction duplicate = (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION);
        duplicate.setExternalIDs(externalIDs);
        serviceDelegator.createDistinction(ORCID, duplicate);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode);
    }
}
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 2 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_EducationsTest method testAddEducationsDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddEducationsDuplicateExternalIDs() {
    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);
    Education education = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
    education.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createEducation(ORCID, education);
    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 putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    try {
        Education duplicate = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
        duplicate.setExternalIDs(externalIDs);
        serviceDelegator.createEducation(ORCID, duplicate);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) Education(org.orcid.jaxb.model.v3.dev1.record.Education) 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 3 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducationDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateEducationDuplicateExternalIDs() {
    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);
    Education education = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
    education.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createEducation(ORCID, education);
    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)));
    Education another = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
    response = serviceDelegator.createEducation(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.viewEducation(ORCID, putCode2);
    another = (Education) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateEducation(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) Education(org.orcid.jaxb.model.v3.dev1.record.Education) 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 4 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateEmploymentDuplicateExternalIDs() {
    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);
    Employment employment = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
    employment.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createEmployment(ORCID, employment);
    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)));
    Employment another = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
    response = serviceDelegator.createEmployment(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.viewEmployment(ORCID, putCode2);
    another = (Employment) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateEmployment(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) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) 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 ExternalIDs

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testAddEmploymentsDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddEmploymentsDuplicateExternalIDs() {
    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);
    Employment employment = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
    employment.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createEmployment(ORCID, employment);
    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 putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    try {
        Employment duplicate = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
        duplicate.setExternalIDs(externalIDs);
        serviceDelegator.createEmployment(ORCID, duplicate);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) 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)

Aggregations

ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)75 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)72 Url (org.orcid.jaxb.model.v3.dev1.common.Url)49 Test (org.junit.Test)45 Title (org.orcid.jaxb.model.v3.dev1.common.Title)23 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)22 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)19 List (java.util.List)15 Work (org.orcid.jaxb.model.v3.dev1.record.Work)14 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)8 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)8 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)7 BaseTest (org.orcid.core.BaseTest)6 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)6 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)6 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)6 OrganizationAddress (org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress)6 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)6