Search in sources :

Example 1 with TestRow

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()));
}
Also used : TestRow(nl.knaw.huygens.timbuctoo.rml.TestRow) ThrowingErrorHandler(nl.knaw.huygens.timbuctoo.rml.ThrowingErrorHandler) QuadPart(nl.knaw.huygens.timbuctoo.rml.dto.QuadPart) Test(org.junit.Test)

Example 2 with TestRow

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"))));
}
Also used : RdfUri(nl.knaw.huygens.timbuctoo.rml.dto.RdfUri) TestRow(nl.knaw.huygens.timbuctoo.rml.TestRow) ThrowingErrorHandler(nl.knaw.huygens.timbuctoo.rml.ThrowingErrorHandler) QuadPart(nl.knaw.huygens.timbuctoo.rml.dto.QuadPart) Test(org.junit.Test)

Example 3 with TestRow

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"))));
}
Also used : TestRow(nl.knaw.huygens.timbuctoo.rml.TestRow) ThrowingErrorHandler(nl.knaw.huygens.timbuctoo.rml.ThrowingErrorHandler) RdfValue(nl.knaw.huygens.timbuctoo.rml.dto.RdfValue) QuadPart(nl.knaw.huygens.timbuctoo.rml.dto.QuadPart) Test(org.junit.Test)

Aggregations

TestRow (nl.knaw.huygens.timbuctoo.rml.TestRow)3 ThrowingErrorHandler (nl.knaw.huygens.timbuctoo.rml.ThrowingErrorHandler)3 QuadPart (nl.knaw.huygens.timbuctoo.rml.dto.QuadPart)3 Test (org.junit.Test)3 RdfUri (nl.knaw.huygens.timbuctoo.rml.dto.RdfUri)1 RdfValue (nl.knaw.huygens.timbuctoo.rml.dto.RdfValue)1