Search in sources :

Example 6 with ResourceOrLiteralType

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

the class ItemExtractorUtilsTest method testExtractLabelResourceWithoutLanguage.

@Test
void testExtractLabelResourceWithoutLanguage() {
    LabelResource label = new LabelResource(null, "value1");
    label.setResource("resource1");
    ResourceOrLiteralType output = ItemExtractorUtils.extractLabelResource(label, ResourceOrLiteralType::new);
    assertNotNull(output);
    assertEquals("value1", output.getString());
    assertNull(output.getLang());
    assertEquals("resource1", output.getResource().getResource());
}
Also used : LabelResource(eu.europeana.enrichment.api.external.model.LabelResource) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 7 with ResourceOrLiteralType

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

the class ItemExtractorUtilsTest method testExtractPartNullResource.

@Test
void testExtractPartNullResource() {
    Part part = new Part(null);
    ResourceOrLiteralType output = ItemExtractorUtils.extractPart(part, ResourceOrLiteralType::new);
    assertNotNull(output);
    assertEquals("", output.getString());
    assertNull(output.getResource());
}
Also used : Part(eu.europeana.enrichment.api.external.model.Part) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 8 with ResourceOrLiteralType

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

the class ItemExtractorUtilsTest method testExtractLabelResourceWithoutResource.

@Test
void testExtractLabelResourceWithoutResource() {
    LabelResource label = new LabelResource("lang1", "value1");
    ResourceOrLiteralType output = ItemExtractorUtils.extractLabelResource(label, ResourceOrLiteralType::new);
    assertNotNull(output);
    assertEquals("value1", output.getString());
    assertEquals("lang1", output.getLang().getLang());
    assertNull(output.getResource());
}
Also used : LabelResource(eu.europeana.enrichment.api.external.model.LabelResource) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 9 with ResourceOrLiteralType

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

the class ItemExtractorUtilsTest method testExtractLabelResource.

@Test
void testExtractLabelResource() {
    LabelResource label = new LabelResource("lang1", "value1");
    label.setResource("resource1");
    ResourceOrLiteralType output = ItemExtractorUtils.extractLabelResource(label, ResourceOrLiteralType::new);
    assertNotNull(output);
    assertEquals("value1", output.getString());
    assertEquals("lang1", output.getLang().getLang());
    assertEquals("resource1", output.getResource().getResource());
}
Also used : LabelResource(eu.europeana.enrichment.api.external.model.LabelResource) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 10 with ResourceOrLiteralType

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

the class LanguageTagStatisticsTest method testAddToStatisticsForChoice.

private <T extends ResourceOrLiteralType> void testAddToStatisticsForChoice(T value, BiConsumer<Choice, T> setter, PropertyType propertyType) {
    final LanguageTagStatistics statistics = spy(new LanguageTagStatistics(null, null, null));
    Choice choice = new Choice();
    setter.accept(choice, value);
    statistics.addToStatistics(choice);
    verify(statistics, times(1)).addToStatistics(value, propertyType);
    verify(statistics, times(1)).addToStatistics(any(ResourceOrLiteralType.class), any());
    verify(statistics, never()).addToStatistics(any(LiteralType.class), any());
}
Also used : Choice(eu.europeana.metis.schema.jibx.EuropeanaType.Choice) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType)

Aggregations

ResourceOrLiteralType (eu.europeana.metis.schema.jibx.ResourceOrLiteralType)21 Test (org.junit.jupiter.api.Test)16 LabelResource (eu.europeana.enrichment.api.external.model.LabelResource)6 Resource (eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 Lang (eu.europeana.metis.schema.jibx.LiteralType.Lang)4 ResourceType (eu.europeana.metis.schema.jibx.ResourceType)4 Part (eu.europeana.enrichment.api.external.model.Part)3 AboutType (eu.europeana.metis.schema.jibx.AboutType)3 Choice (eu.europeana.metis.schema.jibx.EuropeanaType.Choice)3 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)3 Collectors (java.util.stream.Collectors)3 CurrentLocation (eu.europeana.metis.schema.jibx.CurrentLocation)2 LiteralType (eu.europeana.metis.schema.jibx.LiteralType)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Optional (java.util.Optional)2