use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.
the class ValidateV2RC3Identifiers method testFunding.
@Test
public void testFunding() throws SAXException, IOException, JAXBException, ParserConfigurationException {
Funding funding = unmarshallFromPath("/record_2.0_rc3/samples/funding-2.0_rc3.xml", Funding.class);
assertEquals("funding:organization-defined-type", funding.getOrganizationDefinedType().getContent());
assertNotNull(funding.getExternalIdentifiers());
assertNotNull(funding.getExternalIdentifiers().getExternalIdentifier());
Assert.notEmpty(funding.getExternalIdentifiers().getExternalIdentifier());
assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("funding:external-identifier-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals(new Url("http://tempuri.org"), funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
Validator validator = getValidator("funding");
validator.validate(marshall(Funding.class, funding));
validator.validate(marshallToDOM(Funding.class, funding));
}
use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.
the class ValidateV2IdentifiersTest method testFunding.
@Test
public void testFunding() throws SAXException, IOException, JAXBException, ParserConfigurationException {
Funding funding = unmarshallFromPath("/record_2.0/samples/read_samples/funding-2.0.xml", Funding.class);
assertEquals("funding:organization-defined-type", funding.getOrganizationDefinedType().getContent());
assertNotNull(funding.getExternalIdentifiers());
assertNotNull(funding.getExternalIdentifiers().getExternalIdentifier());
Assert.notEmpty(funding.getExternalIdentifiers().getExternalIdentifier());
assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("funding:external-identifier-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals(new Url("http://tempuri.org"), funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
Validator validator = getValidator("funding");
validator.validate(marshall(Funding.class, funding));
validator.validate(marshallToDOM(Funding.class, funding));
}
use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.
the class MemberV2Test method createViewUpdateAndDeleteFunding.
@Test
public void createViewUpdateAndDeleteFunding() throws JSONException, InterruptedException, URISyntaxException {
long time = System.currentTimeMillis();
Funding funding = (Funding) unmarshallFromPath("/record_2.0/samples/read_samples/funding-2.0.xml", Funding.class);
funding.setPutCode(null);
funding.setVisibility(Visibility.PUBLIC);
funding.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID fExtId = new ExternalID();
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setValue("Funding Id " + time);
fExtId.setRelationship(Relationship.SELF);
funding.getExternalIdentifiers().getExternalIdentifier().add(fExtId);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createFundingXml(this.getUser1OrcidId(), funding, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0/" + this.getUser1OrcidId() + "/funding/\\d+"));
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Funding gotFunding = getResponse.getEntity(Funding.class);
assertEquals("common:title", gotFunding.getTitle().getTitle().getContent());
assertEquals("common:translated-title", gotFunding.getTitle().getTranslatedTitle().getContent());
assertEquals("en", gotFunding.getTitle().getTranslatedTitle().getLanguageCode());
//Save the original visibility
Visibility originalVisibility = gotFunding.getVisibility();
Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
//Verify you cant update the visibility
gotFunding.setVisibility(updatedVisibility);
ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotFunding);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
OrcidError error = putResponse.getEntity(OrcidError.class);
assertNotNull(error);
assertEquals(Integer.valueOf(9035), error.getErrorCode());
//Set the visibility again to the initial one
gotFunding.setVisibility(originalVisibility);
gotFunding.getTitle().getTitle().setContent("Updated title");
gotFunding.getTitle().getTranslatedTitle().setContent("Updated translated title");
gotFunding.getTitle().getTranslatedTitle().setLanguageCode("es");
putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotFunding);
assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Funding gotAfterUpdateFunding = getAfterUpdateResponse.getEntity(Funding.class);
assertEquals("Updated title", gotAfterUpdateFunding.getTitle().getTitle().getContent());
assertEquals("Updated translated title", gotAfterUpdateFunding.getTitle().getTranslatedTitle().getContent());
assertEquals("es", gotAfterUpdateFunding.getTitle().getTranslatedTitle().getLanguageCode());
ClientResponse deleteResponse = memberV2ApiClient.deleteFundingXml(this.getUser1OrcidId(), gotFunding.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.
the class OrcidRecordToSolrDocumentTest method test12SameAs20.
@Test
public void test12SameAs20() throws IOException, SolrServerException, JAXBException {
OrcidProfileToSolrDocument v12 = new OrcidProfileToSolrDocument();
OrcidRecordToSolrDocument v20 = new OrcidRecordToSolrDocument(false);
Record record = getRecord("/v20record.xml");
OrcidMessage message = getOrcidMessage();
OrcidSolrDocument v12Doc = v12.convert(message.getOrcidProfile());
OrcidSolrDocument v20Doc = v20.convert(record, new ArrayList<Funding>());
Assert.assertEquals(v12Doc.getOrcid(), v20Doc.getOrcid());
Assert.assertEquals(v12Doc.getFamilyName(), v20Doc.getFamilyName());
Assert.assertEquals(v12Doc.getGivenNames(), v20Doc.getGivenNames());
Assert.assertEquals(v12Doc.getGivenAndFamilyNames(), v20Doc.getGivenAndFamilyNames());
Assert.assertTrue(v12Doc.getDigitalObjectIds().containsAll(v20Doc.getDigitalObjectIds()));
Assert.assertTrue(v20Doc.getDigitalObjectIds().containsAll(v12Doc.getDigitalObjectIds()));
Assert.assertTrue(v12Doc.getWorkTitles().containsAll(v20Doc.getWorkTitles()));
Assert.assertTrue(v20Doc.getWorkTitles().containsAll(v12Doc.getWorkTitles()));
Assert.assertTrue(v12Doc.getCit().containsAll(v20Doc.getCit()));
Assert.assertTrue(v20Doc.getCit().containsAll(v12Doc.getCit()));
Assert.assertTrue(v12Doc.getAgr().containsAll(v20Doc.getAgr()));
Assert.assertTrue(v20Doc.getAgr().containsAll(v12Doc.getAgr()));
Assert.assertEquals(v12Doc.getProfileLastModifiedDate(), v20Doc.getProfileLastModifiedDate());
Assert.assertEquals(v12Doc.getProfileSubmissionDate(), v20Doc.getProfileSubmissionDate());
}
use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.
the class OrcidRecordToSolrDocumentTest method testOrgIDAndGrantNumber.
@Test
public void testOrgIDAndGrantNumber() throws JAXBException {
Record record = getRecord("/v20record.xml");
OrcidRecordToSolrDocument v20 = new OrcidRecordToSolrDocument(false);
OrcidSolrDocument v20Doc = v20.convert(record, new ArrayList<Funding>());
Assert.assertTrue(v20Doc.getOrganisationIds().containsKey("ringgold-org-id"));
Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("5488"));
Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("4925"));
Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("Open University"));
Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("British Library"));
/*
Assert.assertTrue(v20Doc.getOrganisationNames().get("funding-org-name").contains("THOR - Technical and Human Infrastructure for Open Research"));
Assert.assertTrue(v20Doc.getGrantNumbers().contains("H2020-EU.1.4.1.3."));
*/
}
Aggregations