Search in sources :

Example 11 with TransientNonEmptyString

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

the class ActivityValidatorTest method checkDupesNormalized.

// validate normalization is being used
@Test(expected = OrcidDuplicatedActivityException.class)
public void checkDupesNormalized() {
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("agr");
    id1.setValue("UPPER");
    ExternalIDs ids1 = new ExternalIDs();
    ids1.getExternalIdentifier().add(id1);
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.SELF);
    id2.setType("agr");
    id2.setValue("upper");
    id2.setNormalized(new TransientNonEmptyString("upper"));
    ExternalIDs ids2 = new ExternalIDs();
    ids2.getExternalIdentifier().add(id2);
    SourceEntity source1 = mock(SourceEntity.class);
    when(source1.getSourceName()).thenReturn("source name");
    when(source1.getSourceId()).thenReturn("APP-00000000000000");
    SourceClientId sourceClientId = new SourceClientId();
    sourceClientId.setPath("APP-00000000000000");
    Source source2 = mock(Source.class);
    when(source2.getSourceName()).thenReturn(new SourceName("source name"));
    when(source2.getSourceClientId()).thenReturn(sourceClientId);
    activityValidator.checkExternalIdentifiersForDuplicates(ids1, ids2, source2, source1);
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) SourceClientId(org.orcid.jaxb.model.v3.dev1.common.SourceClientId) SourceName(org.orcid.jaxb.model.v3.dev1.common.SourceName) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Source(org.orcid.jaxb.model.v3.dev1.common.Source) 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