use of org.orcid.jaxb.model.v3.dev1.record.ExternalID 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);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID 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);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID 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);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID 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);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID 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);
}
}
Aggregations