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));
}
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()));
}
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;
}
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());
}
}
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());
}
Aggregations