use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testViewResearcherUrls.
@Test
public void testViewResearcherUrls() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewResearcherUrls("4444-4444-4444-4443");
assertNotNull(response);
ResearcherUrls researcherUrls = (ResearcherUrls) response.getEntity();
assertNotNull(researcherUrls);
Utils.verifyLastModified(researcherUrls.getLastModifiedDate());
assertEquals("/4444-4444-4444-4443/researcher-urls", researcherUrls.getPath());
assertNotNull(researcherUrls.getResearcherUrls());
assertEquals(5, researcherUrls.getResearcherUrls().size());
for (ResearcherUrl rUrl : researcherUrls.getResearcherUrls()) {
assertThat(rUrl.getPutCode(), anyOf(equalTo(Long.valueOf(2)), equalTo(Long.valueOf(3)), equalTo(Long.valueOf(5)), equalTo(Long.valueOf(7)), equalTo(Long.valueOf(8))));
Utils.verifyLastModified(researcherUrls.getLastModifiedDate());
assertNotNull(rUrl.getSource());
assertFalse(PojoUtil.isEmpty(rUrl.getSource().retrieveSourcePath()));
assertNotNull(rUrl.getUrl());
assertNotNull(rUrl.getUrlName());
assertNotNull(rUrl.getVisibility());
if (rUrl.getPutCode().equals(Long.valueOf(5)) || rUrl.getPutCode().equals(Long.valueOf(7))) {
assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
}
}
}
use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testReadPublicScope_ResearcherUrls.
@Test
public void testReadPublicScope_ResearcherUrls() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewResearcherUrls(ORCID);
assertNotNull(r);
ResearcherUrls ru = (ResearcherUrls) r.getEntity();
assertNotNull(ru);
assertEquals("/0000-0000-0000-0003/researcher-urls", ru.getPath());
Utils.verifyLastModified(ru.getLastModifiedDate());
assertEquals(3, ru.getResearcherUrls().size());
boolean found13 = false, found14 = false, found15 = false;
for (ResearcherUrl element : ru.getResearcherUrls()) {
if (element.getPutCode() == 13) {
found13 = true;
} else if (element.getPutCode() == 14) {
found14 = true;
} else if (element.getPutCode() == 15) {
found15 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found13);
assertTrue(found14);
assertTrue(found15);
r = serviceDelegator.viewResearcherUrl(ORCID, 13L);
assertNotNull(r);
assertEquals(ResearcherUrl.class.getName(), r.getEntity().getClass().getName());
// Limited am the source of should work
serviceDelegator.viewResearcherUrl(ORCID, 14L);
// Limited am not the source of should fail
try {
serviceDelegator.viewResearcherUrl(ORCID, 16L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private am the source of should work
serviceDelegator.viewResearcherUrl(ORCID, 15L);
// Private am not the source of should fail
try {
serviceDelegator.viewResearcherUrl(ORCID, 17L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls in project ORCID-Source by ORCID.
the class WebsitesForm method toResearcherUrls.
public ResearcherUrls toResearcherUrls() {
ResearcherUrls researcherUrls = new ResearcherUrls();
List<ResearcherUrl> ruList = new ArrayList<ResearcherUrl>();
for (WebsiteForm website : websites) {
ruList.add(website.toResearcherUrl());
}
researcherUrls.setResearcherUrls(ruList);
return researcherUrls;
}
use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls in project ORCID-Source by ORCID.
the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(ResearcherUrls researcherUrls) {
if (researcherUrls != null && researcherUrls.getResearcherUrls() != null && !researcherUrls.getResearcherUrls().isEmpty()) {
LastModifiedDate latest = null;
for (ResearcherUrl researcherUrl : researcherUrls.getResearcherUrls()) {
if (researcherUrl.getLastModifiedDate() != null && researcherUrl.getLastModifiedDate().after(latest)) {
latest = researcherUrl.getLastModifiedDate();
}
}
researcherUrls.setLastModifiedDate(latest);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls in project ORCID-Source by ORCID.
the class JpaJaxbResearcherUrlAdapterTest method testToResearcherUrlEntity.
@Test
public void testToResearcherUrlEntity() throws JAXBException {
ResearcherUrls rUrls = getResearcherUrls();
assertNotNull(rUrls);
assertNotNull(rUrls.getResearcherUrls());
assertEquals(1, rUrls.getResearcherUrls().size());
ResearcherUrlEntity entity = jpaJaxbResearcherUrlAdapter.toResearcherUrlEntity(rUrls.getResearcherUrls().get(0));
assertNotNull(entity);
// General info
assertEquals(Long.valueOf(1248), entity.getId());
assertEquals(Visibility.PUBLIC.value(), entity.getVisibility().value());
assertEquals("http://site1.com/", entity.getUrl());
assertEquals("Site # 1", entity.getUrlName());
// Source
assertNull(entity.getSourceId());
assertNull(entity.getClientSourceId());
assertNull(entity.getElementSourceId());
}
Aggregations