Search in sources :

Example 6 with TransientNonEmptyString

use of org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingWorksTest method testNormalizedGrouping.

@Test
public void testNormalizedGrouping() {
    ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
    List<WorkSummary> sums = new ArrayList<WorkSummary>();
    for (int i = 0; i < 2; i++) {
        String title = "work-" + i;
        WorkSummary work = new WorkSummary();
        // Set title
        WorkTitle workTitle = new WorkTitle();
        workTitle.setTitle(new Title(title));
        work.setTitle(workTitle);
        ExternalIDs wei = new ExternalIDs();
        ExternalID e1 = new ExternalID();
        e1.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.DOI.value());
        e1.setValue("a");
        e1.setNormalized(new TransientNonEmptyString("a"));
        wei.getExternalIdentifier().add(e1);
        work.setExternalIdentifiers(wei);
        sums.add(work);
    }
    sums.get(0).getExternalIdentifiers().getExternalIdentifier().get(0).setValue("A");
    generator.group(sums.get(0));
    generator.group(sums.get(1));
    assertEquals(1, generator.getGroups().size());
    checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(0), sums.get(1));
    for (int i = 2; i < 4; i++) {
        String title = "work-" + i;
        WorkSummary work = new WorkSummary();
        // Set title
        WorkTitle workTitle = new WorkTitle();
        workTitle.setTitle(new Title(title));
        work.setTitle(workTitle);
        ExternalIDs wei = new ExternalIDs();
        ExternalID e1 = new ExternalID();
        e1.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
        e1.setValue("https://dx.doi.org/10/UPPER");
        e1.setNormalized(new TransientNonEmptyString("10/upper"));
        wei.getExternalIdentifier().add(e1);
        work.setExternalIdentifiers(wei);
        sums.add(work);
    }
    sums.get(0).getExternalIdentifiers().getExternalIdentifier().get(0).setValue("http://doi.org/10/upper");
    generator.group(sums.get(2));
    generator.group(sums.get(3));
    assertEquals(2, generator.getGroups().size());
    checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(0), sums.get(1));
    checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(2), sums.get(3));
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 7 with TransientNonEmptyString

use of org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString in project ORCID-Source by ORCID.

the class NormalizationServiceTest method checkISBNAndCaseNormalized.

@Test
public void checkISBNAndCaseNormalized() {
    ExternalID normed = new ExternalID();
    normed.setRelationship(Relationship.SELF);
    normed.setType("isbn");
    normed.setValue("ISBN: 123-456-7-89x junk");
    // everything should normalize to this.
    normed.setNormalized(new TransientNonEmptyString("123456789X"));
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("isbn");
    id1.setValue("ISBN: 123-456-7-89x junk");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(normed, id1);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 8 with TransientNonEmptyString

use of org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString in project ORCID-Source by ORCID.

the class NormalizationServiceTest method checkCaseNormalized.

@Test
public void checkCaseNormalized() {
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("agr");
    id1.setValue("UPPER");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.SELF);
    id2.setType("agr");
    id2.setValue("upper");
    id2.setNormalized(new TransientNonEmptyString("upper"));
    assertEquals(id1, id2);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 9 with TransientNonEmptyString

use of org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString in project ORCID-Source by ORCID.

the class NormalizationServiceTest method checkBibcodeAndCaseNormalized.

@Test
public void checkBibcodeAndCaseNormalized() {
    ExternalID normed = new ExternalID();
    normed.setRelationship(Relationship.SELF);
    normed.setType("bibcode");
    normed.setValue(" 123456789.A23456789 ");
    // everything should normalize to this.
    normed.setNormalized(new TransientNonEmptyString("123456789.A23456789"));
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("bibcode");
    id1.setValue(" 123456789.A23456789 ");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(normed, id1);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 10 with TransientNonEmptyString

use of org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString in project ORCID-Source by ORCID.

the class NormalizationServiceTest method checkDOIAndCaseNormalized.

@Test
public void checkDOIAndCaseNormalized() {
    ExternalID normed = new ExternalID();
    normed.setRelationship(Relationship.SELF);
    normed.setType("doi");
    normed.setValue("10.1/upper");
    // everything should normalize to this.
    normed.setNormalized(new TransientNonEmptyString("10.1/upper"));
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("https://dx.doi.org/10.1/UPPER");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(id1, normed);
    id1.setValue("http://doi.org/10.1/UPPER");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(id1, normed);
    id1.setValue("10.1/UPPER");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(id1, normed);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Aggregations

TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)11 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)11 Test (org.junit.Test)8 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)4 HashMap (java.util.HashMap)2 OrcidDuplicatedActivityException (org.orcid.core.exception.OrcidDuplicatedActivityException)2 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)2 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 JAXBSource (javax.xml.bind.util.JAXBSource)1 Schema (javax.xml.validation.Schema)1 SchemaFactory (javax.xml.validation.SchemaFactory)1 Validator (javax.xml.validation.Validator)1 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)1 JSONWorkExternalIdentifier (org.orcid.core.adapter.jsonidentifier.JSONWorkExternalIdentifier)1