use of org.orcid.jaxb.model.common_v2.Source in project ORCID-Source by ORCID.
the class ValidateV2IdentifiersTest method testPeerReview.
/** Test both types of identifier here
*
* @throws SAXException
* @throws IOException
* @throws JAXBException
* @throws ParserConfigurationException
*/
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
PeerReview peerReview = unmarshallFromPath("/record_2.0/samples/read_samples/peer-review-2.0.xml", PeerReview.class);
ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
assertEquals("source-work-id", id.getType());
assertEquals("work:external-identifier-id", id.getValue());
assertEquals(new Url("http://orcid.org"), id.getUrl());
assertEquals(Relationship.SELF, id.getRelationship());
ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
assertEquals("doi", subjectid.getType());
assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
assertEquals(Relationship.SELF, subjectid.getRelationship());
Validator validator = getValidator("peer-review");
validator.validate(marshall(PeerReview.class, peerReview));
validator.validate(marshallToDOM(PeerReview.class, peerReview));
//do the full record too
peerReview = unmarshallFromPath("/record_2.0/samples/read_samples/peer-review-full-2.0.xml", PeerReview.class);
id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
assertEquals("source-work-id", id.getType());
assertEquals("work:external-identifier-id", id.getValue());
assertEquals(new Url("http://orcid.org"), id.getUrl());
assertEquals(Relationship.SELF, id.getRelationship());
subjectid = peerReview.getSubjectExternalIdentifier();
assertEquals("doi", subjectid.getType());
assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
assertEquals(Relationship.SELF, subjectid.getRelationship());
}
use of org.orcid.jaxb.model.common_v2.Source in project ORCID-Source by ORCID.
the class AddressForm method toAddress.
public Address toAddress() {
Address address = new Address();
if (this.iso2Country != null && this.iso2Country.getValue() != null) {
Country country = new Country();
country.setValue(this.iso2Country.getValue().value());
address.setCountry(country);
}
if (this.visibility != null && this.visibility.getVisibility() != null) {
address.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(this.getVisibility().getVisibility().value()));
}
if (!PojoUtil.isEmpty(this.getPutCode())) {
address.setPutCode(Long.valueOf(this.getPutCode()));
}
if (displayIndex != null) {
address.setDisplayIndex(displayIndex);
} else {
address.setDisplayIndex(0L);
}
address.setSource(new Source(source));
return address;
}
use of org.orcid.jaxb.model.common_v2.Source in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testEmptyRelationshipOnNotificationItemExternalIds_flagOff.
@Test
public void testEmptyRelationshipOnNotificationItemExternalIds_flagOff() {
Item i = new Item();
Item i2 = new Item();
Items items = new Items();
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
ExternalID id2 = new ExternalID();
id2.setRelationship(null);
id2.setType("source-work-id");
id2.setValue("value2");
id2.setUrl(new Url("http://value1.com"));
i.setExternalIdentifier(id1);
i2.setExternalIdentifier(id2);
items.getItems().add(i);
items.getItems().add(i2);
//both valid
validator.validateNotificationItems(items);
}
use of org.orcid.jaxb.model.common_v2.Source in project ORCID-Source by ORCID.
the class WorkExternalIdentifiersConversionsTest method testConvertFromExternalIDs.
@Test
public void testConvertFromExternalIDs() {
WorkExternalIDsConverter conv = new WorkExternalIDsConverter();
ExternalID id = new ExternalID();
id.setRelationship(Relationship.SELF);
id.setType("doi");
id.setUrl(new Url("http://what.com"));
id.setValue("value");
ExternalID id2 = new ExternalID();
id2.setRelationship(Relationship.PART_OF);
id2.setType("source-work-id");
id2.setUrl(new Url("http://whatnow.com"));
id2.setValue("value2");
ExternalIDs ids = new ExternalIDs();
ids.getExternalIdentifier().add(id);
ids.getExternalIdentifier().add(id2);
String externalIdentifiersAsString = conv.convertTo(ids, null);
assertEquals(expectedIDs, externalIdentifiersAsString);
}
use of org.orcid.jaxb.model.common_v2.Source in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testEmptyRelationshipOnNotificationItemExternalIds_flagOn.
@Test(expected = ActivityIdentifierValidationException.class)
public void testEmptyRelationshipOnNotificationItemExternalIds_flagOn() {
validator.setRequireRelationshipOnExternalIdentifier(true);
Item i = new Item();
Item i2 = new Item();
Items items = new Items();
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
ExternalID id2 = new ExternalID();
id2.setRelationship(null);
id2.setType("source-work-id");
id2.setValue("value2");
id2.setUrl(new Url("http://value1.com"));
i.setExternalIdentifier(id1);
i2.setExternalIdentifier(id2);
items.getItems().add(i);
items.getItems().add(i2);
//both valid
validator.validateNotificationItems(items);
fail("no exception thrown for invalid type");
}
Aggregations