Search in sources :

Example 1 with WorkExternalIDsConverter

use of org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter in project ORCID-Source by ORCID.

the class WorkExternalIdentifiersConversionsTest method testConvertToExternalIDs.

@Test
public void testConvertToExternalIDs() {
    WorkExternalIDsConverter conv = new WorkExternalIDsConverter();
    String externalIdentifiersAsString = expectedIDs;
    ExternalIDs ids = conv.convertFrom(externalIdentifiersAsString, null);
    assertEquals(Relationship.SELF, ids.getExternalIdentifier().get(0).getRelationship());
    assertEquals(new Url("http://what.com"), ids.getExternalIdentifier().get(0).getUrl());
    assertEquals("doi", ids.getExternalIdentifier().get(0).getType());
    assertEquals("value", ids.getExternalIdentifier().get(0).getValue());
    assertEquals(Relationship.PART_OF, ids.getExternalIdentifier().get(1).getRelationship());
    assertEquals(new Url("http://whatnow.com"), ids.getExternalIdentifier().get(1).getUrl());
    assertEquals("source-work-id", ids.getExternalIdentifier().get(1).getType());
    assertEquals("value2", ids.getExternalIdentifier().get(1).getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkExternalIDsConverter(org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 2 with WorkExternalIDsConverter

use of org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter 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);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkExternalIDsConverter(org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 WorkExternalIDsConverter (org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter)2 Url (org.orcid.jaxb.model.common_v2.Url)2 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)2 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)1