Search in sources :

Example 1 with LiteralType

use of eu.europeana.metis.schema.jibx.LiteralType in project metis-framework by europeana.

the class ContextualClassesBreakdownClassifierTest method testHasProperty.

@Test
void testHasProperty() {
    final ContextualClassesClassifier classifier = new ContextualClassesClassifier();
    // Test for literals
    assertFalse(classifier.hasProperty((LiteralType) null));
    final LiteralType literal = new LiteralType();
    literal.setString(null);
    assertFalse(classifier.hasProperty(literal));
    literal.setString(" ");
    assertFalse(classifier.hasProperty(literal));
    literal.setString("test 1");
    assertTrue(classifier.hasProperty(literal));
    // Test for resources
    assertFalse(classifier.hasProperty((ResourceType) null));
    final ResourceType resource = new ResourceType();
    resource.setResource(null);
    assertFalse(classifier.hasProperty(resource));
    resource.setResource(" ");
    assertFalse(classifier.hasProperty(resource));
    resource.setResource("test 2");
    assertTrue(classifier.hasProperty(resource));
    // Test for resource/literal objects
    assertFalse(classifier.hasProperty((ResourceOrLiteralType) null));
    final ResourceOrLiteralType object = new ResourceOrLiteralType();
    object.setResource(null);
    object.setString(null);
    assertFalse(classifier.hasProperty(object));
    object.setString(" ");
    assertFalse(classifier.hasProperty(object));
    object.setString("test");
    assertTrue(classifier.hasProperty(object));
    object.setString(null);
    object.setResource(new Resource());
    object.getResource().setResource(null);
    assertFalse(classifier.hasProperty(object));
    object.getResource().setResource(" ");
    assertFalse(classifier.hasProperty(object));
    object.getResource().setResource("test 3");
    assertTrue(classifier.hasProperty(object));
}
Also used : Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) ResourceType(eu.europeana.metis.schema.jibx.ResourceType) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 2 with LiteralType

use of eu.europeana.metis.schema.jibx.LiteralType in project metis-framework by europeana.

the class FieldInputUtilsTest method testCreateLiteralMapFromObject.

@Test
void testCreateLiteralMapFromObject() {
    LiteralType obj = new LiteralType();
    Lang lang = new Lang();
    lang.setLang("en");
    obj.setLang(lang);
    obj.setString("str");
    Map<String, List<String>> testMap = FieldInputUtils.createLiteralMapFromString(obj);
    assertNotNull(testMap);
    assertEquals(1, testMap.size());
    assertEquals("en", testMap.keySet().iterator().next());
    assertEquals("str", testMap.get("en").get(0));
    assertNull(FieldInputUtils.createLiteralMapFromString(null));
    assertNull(FieldInputUtils.createLiteralMapFromString(new LiteralType()));
}
Also used : ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) Lang(eu.europeana.metis.schema.jibx.LiteralType.Lang) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 3 with LiteralType

use of eu.europeana.metis.schema.jibx.LiteralType in project metis-framework by europeana.

the class LanguageTagStatisticsTest method createLiteralType.

private LiteralType createLiteralType(String language, String value) {
    final LiteralType result = new LiteralType();
    result.setString(value);
    result.setLang(createLang(language));
    return result;
}
Also used : ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) LiteralType(eu.europeana.metis.schema.jibx.LiteralType)

Example 4 with LiteralType

use of eu.europeana.metis.schema.jibx.LiteralType in project metis-framework by europeana.

the class ItemExtractorUtilsTest method testExtractLabels.

@Test
void testExtractLabels() {
    List<Label> labels = new ArrayList<>();
    Label label1 = new Label("lang1", "value1");
    Label label2 = new Label("lang2", "value2");
    Label label3 = new Label("lang3", "value3");
    labels.add(label1);
    labels.add(label2);
    labels.add(label3);
    List<LiteralType> output = ItemExtractorUtils.extractLabels(labels, LiteralType::new);
    for (Label label : labels) {
        List<LiteralType> result = output.stream().filter(x -> x.getString().equals(label.getValue())).collect(Collectors.toList());
        assertEquals(1, result.size());
        assertEquals(label.getLang(), result.get(0).getLang().getLang());
    }
}
Also used : Label(eu.europeana.enrichment.api.external.model.Label) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) EnrichmentBase(eu.europeana.enrichment.api.external.model.EnrichmentBase) Lang(eu.europeana.metis.schema.jibx.LiteralType.Lang) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) Collectors(java.util.stream.Collectors) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) ArrayList(java.util.ArrayList) ResourceType(eu.europeana.metis.schema.jibx.ResourceType) Test(org.junit.jupiter.api.Test) AboutType(eu.europeana.metis.schema.jibx.AboutType) List(java.util.List) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) Part(eu.europeana.enrichment.api.external.model.Part) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Agent(eu.europeana.enrichment.api.external.model.Agent) LabelResource(eu.europeana.enrichment.api.external.model.LabelResource) Resource(eu.europeana.enrichment.api.external.model.Resource) Label(eu.europeana.enrichment.api.external.model.Label) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) ArrayList(java.util.ArrayList) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) Test(org.junit.jupiter.api.Test)

Example 5 with LiteralType

use of eu.europeana.metis.schema.jibx.LiteralType in project metis-framework by europeana.

the class ItemExtractorUtilsTest method testExtractLabel.

@Test
void testExtractLabel() {
    Label label = new Label("lang1", "value1");
    LiteralType output = ItemExtractorUtils.extractLabel(label, LiteralType::new);
    assertNotNull(output);
    assertEquals("value1", output.getString());
    assertEquals("lang1", output.getLang().getLang());
}
Also used : Label(eu.europeana.enrichment.api.external.model.Label) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) Test(org.junit.jupiter.api.Test)

Aggregations

LiteralType (eu.europeana.metis.schema.jibx.LiteralType)14 ResourceOrLiteralType (eu.europeana.metis.schema.jibx.ResourceOrLiteralType)13 Test (org.junit.jupiter.api.Test)12 Label (eu.europeana.enrichment.api.external.model.Label)6 AltLabel (eu.europeana.metis.schema.jibx.AltLabel)6 ArrayList (java.util.ArrayList)5 Lang (eu.europeana.metis.schema.jibx.LiteralType.Lang)3 List (java.util.List)3 ResourceType (eu.europeana.metis.schema.jibx.ResourceType)2 FullBeanImpl (eu.europeana.corelib.solr.bean.impl.FullBeanImpl)1 Agent (eu.europeana.enrichment.api.external.model.Agent)1 EnrichmentBase (eu.europeana.enrichment.api.external.model.EnrichmentBase)1 LabelResource (eu.europeana.enrichment.api.external.model.LabelResource)1 Part (eu.europeana.enrichment.api.external.model.Part)1 Resource (eu.europeana.enrichment.api.external.model.Resource)1 AboutType (eu.europeana.metis.schema.jibx.AboutType)1 Choice (eu.europeana.metis.schema.jibx.Concept.Choice)1 EuropeanaAggregationType (eu.europeana.metis.schema.jibx.EuropeanaAggregationType)1 Resource (eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource)1 Collectors (java.util.stream.Collectors)1