use of nl.knaw.huygens.timbuctoo.rml.TestRow in project timbuctoo by HuygensING.
the class RrTemplateTest method returnsEmptyIfOneValueIsMissing.
@Test
public void returnsEmptyIfOneValueIsMissing() throws Exception {
TestRow row = new TestRow(ImmutableMap.of("foo", ""), ImmutableMap.of(), new ThrowingErrorHandler());
RrTemplate rrTemplate = new RrTemplate("{foo} and {bar}", TermType.Literal, XSD_STRING);
Optional<QuadPart> actual = rrTemplate.generateValue(row);
assertThat(actual, is(Optional.empty()));
}
use of nl.knaw.huygens.timbuctoo.rml.TestRow in project timbuctoo by HuygensING.
the class RrTemplateTest method iriEncodesValueIfResultTypeIsIri.
@Test
public void iriEncodesValueIfResultTypeIsIri() throws Exception {
TestRow row = new TestRow(ImmutableMap.of("foo", "some s\"tring with wéird characters"), ImmutableMap.of(), new ThrowingErrorHandler());
RrTemplate rrTemplate = new RrTemplate("http://{foo}", TermType.IRI, null);
Optional<QuadPart> actual = rrTemplate.generateValue(row);
assertThat(actual, is(Optional.of(new RdfUri("http://some%20s%22tring%20with%20w%C3%A9ird%20characters"))));
}
use of nl.knaw.huygens.timbuctoo.rml.TestRow in project timbuctoo by HuygensING.
the class RrTemplateTest method replacesTemplatesWithEmptyStringIfValueIsEmpty.
@Test
public void replacesTemplatesWithEmptyStringIfValueIsEmpty() throws Exception {
TestRow row = new TestRow(ImmutableMap.of("foo", ""), ImmutableMap.of(), new ThrowingErrorHandler());
RrTemplate rrTemplate = new RrTemplate("start {foo} end", TermType.Literal, XSD_STRING);
Optional<QuadPart> actual = rrTemplate.generateValue(row);
assertThat(actual, is(Optional.of(new RdfValue("start end", "http://www.w3.org/2001/XMLSchema#string"))));
}
Aggregations