use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class WorksTest method testGroupingNormalized.
@Test
public void testGroupingNormalized() throws InterruptedException, JSONException {
long time = System.currentTimeMillis();
String accessTokenForClient1 = getAccessToken();
String accessTokenForClient2 = getAccessToken(getUser1OrcidId(), getUser1Password(), getScopes(ScopePathType.ACTIVITIES_UPDATE, ScopePathType.ACTIVITIES_READ_LIMITED), getClient2ClientId(), getClient2ClientSecret(), getClient2RedirectUri());
// should result in two groups
Work work1 = (Work) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/work-3.0_dev1.xml", Work.class);
work1.setPutCode(null);
work1.setSource(null);
work1.setVisibility(Visibility.PUBLIC);
work1.getExternalIdentifiers().getExternalIdentifier().clear();
org.orcid.jaxb.model.v3.dev1.record.WorkTitle title1 = new org.orcid.jaxb.model.v3.dev1.record.WorkTitle();
title1.setTitle(new Title("Work # 1" + time));
work1.setWorkTitle(title1);
ExternalID wExtId1 = new ExternalID();
wExtId1.setValue("VALUE" + time);
wExtId1.setType(WorkExternalIdentifierType.AGR.value());
wExtId1.setRelationship(Relationship.SELF);
wExtId1.setUrl(new Url("http://orcid.org/work#1"));
work1.getExternalIdentifiers().getExternalIdentifier().clear();
work1.getExternalIdentifiers().getExternalIdentifier().add(wExtId1);
Work work2 = (Work) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/work-3.0_dev1.xml", Work.class);
work2.setPutCode(null);
work2.setSource(null);
work2.setVisibility(Visibility.PUBLIC);
org.orcid.jaxb.model.v3.dev1.record.WorkTitle title2 = new org.orcid.jaxb.model.v3.dev1.record.WorkTitle();
title2.setTitle(new Title("Work # 2" + time));
work2.setWorkTitle(title2);
work2.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId2 = new ExternalID();
wExtId2.setValue("value" + time);
wExtId2.setType(WorkExternalIdentifierType.AGR.value());
wExtId2.setRelationship(Relationship.SELF);
wExtId2.setUrl(new Url("http://orcid.org/work#2"));
work2.getExternalIdentifiers().getExternalIdentifier().clear();
work2.getExternalIdentifiers().getExternalIdentifier().add(wExtId2);
Work work3 = (Work) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/work-3.0_dev1.xml", Work.class);
work3.setPutCode(null);
work3.setSource(null);
work3.setVisibility(Visibility.PUBLIC);
org.orcid.jaxb.model.v3.dev1.record.WorkTitle title3 = new org.orcid.jaxb.model.v3.dev1.record.WorkTitle();
title3.setTitle(new Title("Work # 3" + time));
work3.setWorkTitle(title3);
work3.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId3 = new ExternalID();
wExtId3.setValue("OtherValue" + time);
wExtId3.setType(WorkExternalIdentifierType.AGR.value());
wExtId3.setRelationship(Relationship.SELF);
wExtId3.setUrl(new Url("http://orcid.org/work#3"));
work3.getExternalIdentifiers().getExternalIdentifier().clear();
work3.getExternalIdentifiers().getExternalIdentifier().add(wExtId3);
// Add the three works
ClientResponse postResponse = memberV3Dev1ApiClient.createWorkXml(this.getUser1OrcidId(), work1, accessTokenForClient1);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
Long putCode1 = getPutCodeFromResponse(postResponse);
postResponse = memberV3Dev1ApiClient.createWorkXml(this.getUser1OrcidId(), work2, accessTokenForClient2);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
Long putCode2 = getPutCodeFromResponse(postResponse);
postResponse = memberV3Dev1ApiClient.createWorkXml(this.getUser1OrcidId(), work3, accessTokenForClient2);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
Long putCode3 = getPutCodeFromResponse(postResponse);
ClientResponse activitiesResponse = memberV3Dev1ApiClient.viewActivities(this.getUser1OrcidId(), accessTokenForClient1);
assertEquals(Response.Status.OK.getStatusCode(), activitiesResponse.getStatus());
ActivitiesSummary activities = activitiesResponse.getEntity(ActivitiesSummary.class);
assertNotNull(activities);
assertFalse(activities.getWorks().getWorkGroup().isEmpty());
WorkGroup work1Group = null;
WorkGroup work2Group = null;
WorkGroup work3Group = null;
boolean work1found = false;
boolean work2found = false;
boolean work3found = false;
for (WorkGroup group : activities.getWorks().getWorkGroup()) {
for (ExternalID id : group.getIdentifiers().getExternalIdentifier()) {
// If it is the ID is the one we are looking for
if (id.getNormalized().getValue().equals("value" + time)) {
for (WorkSummary summary : group.getWorkSummary()) {
String title = summary.getTitle().getTitle().getContent();
if (("Work # 1" + time).equals(title)) {
work1found = true;
work1Group = group;
assertEquals(2, group.getActivities().size());
} else if (("Work # 2" + time).equals(title)) {
work2found = true;
work2Group = group;
assertEquals(2, group.getActivities().size());
} else
fail();
}
} else if (id.getNormalized().getValue().equals("othervalue" + time)) {
for (WorkSummary summary : group.getWorkSummary()) {
String title = summary.getTitle().getTitle().getContent();
if (("Work # 3" + time).equals(title)) {
work3found = true;
work3Group = group;
assertEquals(1, group.getActivities().size());
} else
fail();
}
}
}
}
assertTrue(work1found);
assertTrue(work2found);
assertTrue(work3found);
// Check that work # 1 and Work # 2 are in the same work
assertEquals(work1Group, work2Group);
// Check that work # 3 is not in the same group than group # 1
assertThat(work3Group, not(work1Group));
// Remove all created works
ClientResponse deleteResponse = memberV3Dev1ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode1, accessTokenForClient1);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
deleteResponse = memberV3Dev1ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode2, accessTokenForClient2);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
deleteResponse = memberV3Dev1ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode3, accessTokenForClient2);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class PersonTest method createExternalIdentifier.
/**
* EXTERNAL IDENTIFIERS
*
* External identifiers can't be added through the UI
*/
public Long createExternalIdentifier(String value, String userOrcid, String accessToken) {
PersonExternalIdentifier e = new PersonExternalIdentifier();
e.setValue(value);
e.setType("test");
e.setUrl(new Url("http://test.orcid.org"));
e.setRelationship(Relationship.SELF);
ClientResponse response = memberV3Dev1ApiClientImpl.createExternalIdentifier(userOrcid, e, accessToken);
assertNotNull(response);
assertEquals(ClientResponse.Status.CREATED.getStatusCode(), response.getStatus());
return getPutCodeFromResponse(response);
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class JSONExternalIdentifiersConverterV3Test method testConvertTo.
@Test
public void testConvertTo() throws JAXBException {
Education education = getEducation();
assertEquals("{\"externalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", converter.convertTo(education.getExternalIdentifiers(), null));
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class JSONPeerReviewWorkExternalIdentifierConverterV3Test method testConvertTo.
@Test
public void testConvertTo() throws JAXBException {
PeerReview peerReview = getPeerReview();
assertEquals("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"DOI\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}", converter.convertTo(peerReview.getSubjectExternalIdentifier(), null));
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class JSONWorkExternalIdentifiersConverterV3Test method testConvertTo.
@Test
public void testConvertTo() throws JAXBException {
Work work = getWork();
assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"AGR\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", converter.convertTo(work.getExternalIdentifiers(), null));
}
Aggregations