use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ReadRecordTest method testPerson.
private void testPerson(Person p, String orcid) {
// This is more an utility that will work only for 0000-0000-0000-0003
assertEquals("0000-0000-0000-0003", orcid);
assertNotNull(p);
assertEquals("/0000-0000-0000-0003/person", p.getPath());
Utils.verifyLastModified(p.getLastModifiedDate());
// Address
assertNotNull(p.getAddresses());
Addresses a = p.getAddresses();
assertNotNull(a);
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(3, a.getAddress().size());
boolean found1 = false, found2 = false, found3 = false;
for (Address element : a.getAddress()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
found1 = true;
} else if (element.getPutCode() == 10) {
found2 = true;
} else if (element.getPutCode() == 11) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Biography
assertNotNull(p.getBiography());
Biography b = p.getBiography();
assertNotNull(b);
Utils.verifyLastModified(b.getLastModifiedDate());
assertEquals("Biography for 0000-0000-0000-0003", b.getContent());
// Email
assertNotNull(p.getEmails());
Emails email = p.getEmails();
assertNotNull(email);
Utils.verifyLastModified(email.getLastModifiedDate());
assertEquals(3, email.getEmails().size());
assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmails().get(0).getEmail());
found1 = false;
found2 = false;
found3 = false;
for (Email element : email.getEmails()) {
if (element.getEmail().equals("public_0000-0000-0000-0003@test.orcid.org")) {
found1 = true;
} else if (element.getEmail().equals("limited_0000-0000-0000-0003@test.orcid.org")) {
found2 = true;
} else if (element.getEmail().equals("private_0000-0000-0000-0003@test.orcid.org")) {
found3 = true;
} else {
fail("Invalid email " + element.getEmail());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// External identifiers
assertNotNull(p.getExternalIdentifiers());
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(3, extIds.getExternalIdentifiers().size());
found1 = false;
found2 = false;
found3 = false;
for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Keywords
assertNotNull(p.getKeywords());
Keywords k = p.getKeywords();
assertNotNull(k);
Utils.verifyLastModified(k.getLastModifiedDate());
assertEquals(3, k.getKeywords().size());
found1 = false;
found2 = false;
found3 = false;
for (Keyword element : k.getKeywords()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
found1 = true;
} else if (element.getPutCode() == 10) {
found2 = true;
} else if (element.getPutCode() == 11) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Name
assertNotNull(p.getName());
assertEquals("Credit Name", p.getName().getCreditName().getContent());
assertEquals("Given Names", p.getName().getGivenNames().getContent());
assertEquals("Family Name", p.getName().getFamilyName().getContent());
// Other names
assertNotNull(p.getOtherNames());
OtherNames o = p.getOtherNames();
assertNotNull(o);
Utils.verifyLastModified(o.getLastModifiedDate());
assertEquals(3, o.getOtherNames().size());
found1 = false;
found2 = false;
found3 = false;
for (OtherName element : o.getOtherNames()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Researcher urls
assertNotNull(p.getResearcherUrls());
ResearcherUrls ru = p.getResearcherUrls();
assertNotNull(ru);
Utils.verifyLastModified(ru.getLastModifiedDate());
assertEquals(3, ru.getResearcherUrls().size());
found1 = false;
found2 = false;
found3 = false;
for (ResearcherUrl element : ru.getResearcherUrls()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertNotNull(p.getPath());
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ReadRecordTest method testActivities.
private void testActivities(ActivitiesSummary as, String orcid) {
boolean found1 = false, found2 = false, found3 = false;
// This is more an utility that will work only for 0000-0000-0000-0003
assertEquals("0000-0000-0000-0003", orcid);
assertNotNull(as);
assertEquals("/0000-0000-0000-0003/activities", as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
assertNotNull(as.getEducations());
assertEquals(3, as.getEducations().getSummaries().size());
for (EducationSummary element : as.getEducations().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(20))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(21))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(22))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getEmployments());
assertEquals(3, as.getEmployments().getSummaries().size());
for (EmploymentSummary element : as.getEmployments().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(17))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(18))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(19))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getFundings());
assertEquals(3, as.getFundings().getFundingGroup().size());
for (FundingGroup group : as.getFundings().getFundingGroup()) {
assertEquals(1, group.getFundingSummary().size());
FundingSummary element = group.getFundingSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(10))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getPeerReviews());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
assertEquals(1, group.getPeerReviewSummary().size());
PeerReviewSummary element = group.getPeerReviewSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(9))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(10))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getWorks());
assertEquals(3, as.getWorks().getWorkGroup().size());
for (WorkGroup group : as.getWorks().getWorkGroup()) {
assertEquals(1, group.getWorkSummary().size());
WorkSummary element = group.getWorkSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(11))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(13))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testViewWorkSummaryReadPublic.
@Test
public void testViewWorkSummaryReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewWorkSummary(ORCID, 11L);
WorkSummary element = (WorkSummary) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/work/11", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testViewPrivateWork.
@Test
public void testViewPrivateWork() {
// Use the smallest scope in the pyramid to verify that you can read
// your own limited and protected data
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewWork("4444-4444-4444-4446", 7L);
assertNotNull(response);
Work work = (Work) response.getEntity();
Utils.verifyLastModified(work.getLastModifiedDate());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertEquals("Journal article C", work.getWorkTitle().getTitle().getContent());
assertEquals(Long.valueOf(7), work.getPutCode());
assertEquals("/4444-4444-4444-4446/work/7", work.getPath());
assertEquals(WorkType.JOURNAL_ARTICLE, work.getWorkType());
assertEquals(Visibility.PRIVATE.value(), work.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testUpdateWorkYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateWorkYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewWork("4444-4444-4444-4443", 2L);
assertNotNull(response);
Work work = (Work) response.getEntity();
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertEquals(Long.valueOf(2), work.getPutCode());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertEquals("Another day in the life", work.getWorkTitle().getTitle().getContent());
assertEquals(WorkType.BOOK, work.getWorkType());
work.setWorkType(WorkType.EDITED_BOOK);
work.getWorkTitle().getTitle().setContent("Updated work title");
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.PART_OF);
extId.setType(WorkExternalIdentifierType.AGR.value());
extId.setValue("ext-id-" + System.currentTimeMillis());
extId.setUrl(new Url("http://thisIsANewUrl.com"));
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
serviceDelegator.updateWork("4444-4444-4444-4443", 2L, work);
fail();
}
Aggregations