use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_FundingTest method testViewFundings.
@Test
public void testViewFundings() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewFundings(ORCID);
assertNotNull(r);
Fundings fundings = (Fundings) r.getEntity();
assertNotNull(fundings);
assertEquals("/0000-0000-0000-0003/fundings", fundings.getPath());
assertNotNull(fundings.getPath());
Utils.verifyLastModified(fundings.getLastModifiedDate());
assertNotNull(fundings.getFundingGroup());
assertEquals(4, fundings.getFundingGroup().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (FundingGroup fundingGroup : fundings.getFundingGroup()) {
Utils.verifyLastModified(fundingGroup.getLastModifiedDate());
assertNotNull(fundingGroup.getIdentifiers());
assertNotNull(fundingGroup.getIdentifiers().getExternalIdentifier());
assertEquals(1, fundingGroup.getIdentifiers().getExternalIdentifier().size());
assertNotNull(fundingGroup.getFundingSummary());
assertEquals(1, fundingGroup.getFundingSummary().size());
FundingSummary summary = fundingGroup.getFundingSummary().get(0);
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getTitle());
assertNotNull(summary.getTitle().getTitle());
switch(fundingGroup.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
case "1":
assertEquals("PUBLIC", summary.getTitle().getTitle().getContent());
assertEquals(Long.valueOf(10), summary.getPutCode());
found1 = true;
break;
case "2":
assertEquals("LIMITED", summary.getTitle().getTitle().getContent());
assertEquals(Long.valueOf(11), summary.getPutCode());
found2 = true;
break;
case "3":
assertEquals("PRIVATE", summary.getTitle().getTitle().getContent());
assertEquals(Long.valueOf(12), summary.getPutCode());
found3 = true;
break;
case "4":
assertEquals("SELF LIMITED", summary.getTitle().getTitle().getContent());
assertEquals(Long.valueOf(13), summary.getPutCode());
found4 = true;
break;
default:
fail("Invalid external id found: " + fundingGroup.getIdentifiers().getExternalIdentifier().get(0).getValue());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testViewFundings.
@Test
public void testViewFundings() {
Response response = serviceDelegator.viewFundings(ORCID);
assertNotNull(response);
Fundings fundings = (Fundings) response.getEntity();
assertNotNull(fundings);
assertEquals("/0000-0000-0000-0003/fundings", fundings.getPath());
assertNotNull(fundings.getLastModifiedDate());
assertNotNull(fundings.getLastModifiedDate().getValue());
assertEquals(1, fundings.getFundingGroup().size());
assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
FundingSummary funding = fundings.getFundingGroup().get(0).getFundingSummary().get(0);
assertNotNull(funding.getTitle());
assertNotNull(funding.getTitle().getTitle());
assertEquals(Long.valueOf(10), funding.getPutCode());
assertNotNull(funding.getLastModifiedDate());
assertNotNull(funding.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/funding/10", funding.getPath());
assertEquals("PUBLIC", funding.getTitle().getTitle().getContent());
assertEquals(Visibility.PUBLIC.value(), funding.getVisibility().value());
assertEquals("APP-5555555555555555", funding.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicFundings.
@Test
public void testGetPublicFundings() {
Response r = serviceDelegator.viewFundings(ORCID);
assertNotNull(r);
Fundings fundings = (Fundings) r.getEntity();
assertNotNull(fundings);
assertNotNull(fundings.getLastModifiedDate());
assertNotNull(fundings.getLastModifiedDate().getValue());
assertNotNull(fundings.getFundingGroup());
assertEquals(1, fundings.getFundingGroup().size());
assertNotNull(fundings.getFundingGroup().get(0).getIdentifiers());
assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("http://test.orcid.org/1.com", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertNotNull(fundings.getFundingGroup().get(0).getFundingSummary());
assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
assertEquals(Long.valueOf(10), fundings.getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertNotNull(fundings.getFundingGroup().get(0).getFundingSummary().get(0).getLastModifiedDate());
assertNotNull(fundings.getFundingGroup().get(0).getFundingSummary().get(0).getLastModifiedDate().getValue());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getFundings.
private Fundings getFundings(Visibility... vs) {
Fundings fundings = new Fundings();
for (Visibility v : vs) {
FundingGroup g = new FundingGroup();
FundingSummary s = new FundingSummary();
s.setVisibility(v);
g.getFundingSummary().add(s);
fundings.getFundingGroup().add(g);
}
return fundings;
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class ProfileFundingManagerReadOnlyImpl method groupFundings.
/**
* Generate a grouped list of funding with the given list of funding
*
* @param fundings
* The list of fundings to group
* @param justPublic
* Specify if we want to group only the public elements in the given list
* @return Fundings element with the FundingSummary elements grouped
*/
@Override
public Fundings groupFundings(List<FundingSummary> fundings, boolean justPublic) {
ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
Fundings result = new Fundings();
for (FundingSummary funding : fundings) {
if (justPublic && !funding.getVisibility().equals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC)) {
// If it is just public and the funding is not public, just
// ignore it
} else {
groupGenerator.group(funding);
}
}
List<ActivitiesGroup> groups = groupGenerator.getGroups();
for (ActivitiesGroup group : groups) {
Set<GroupAble> externalIdentifiers = group.getGroupKeys();
Set<GroupableActivity> activities = group.getActivities();
FundingGroup fundingGroup = new FundingGroup();
// Fill the funding groups with the external identifiers
if (externalIdentifiers == null || externalIdentifiers.isEmpty()) {
// Initialize the ids as an empty list
fundingGroup.getIdentifiers().getExternalIdentifier();
} else {
for (GroupAble extId : externalIdentifiers) {
ExternalID fundingExtId = (ExternalID) extId;
fundingGroup.getIdentifiers().getExternalIdentifier().add(fundingExtId.clone());
}
}
// Fill the funding group with the list of activities
for (GroupableActivity activity : activities) {
FundingSummary fundingSummary = (FundingSummary) activity;
fundingGroup.getFundingSummary().add(fundingSummary);
}
// Sort the fundings
Collections.sort(fundingGroup.getFundingSummary(), new GroupableActivityComparator());
result.getFundingGroup().add(fundingGroup);
}
return result;
}
Aggregations