use of com.bigdata.rdf.internal.impl.literal.XSDNumericIV in project wikidata-query-rdf by wikimedia.
the class WikibaseDateExtension method datePlusDuration.
/**
* Add Duration to date.
* @param iv
* @param d
* @param vf
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private IV datePlusDuration(LiteralExtensionIV iv, Duration d, BigdataValueFactory vf) {
long ts = iv.getDelegate().longValue();
WikibaseDate newdate = WikibaseDate.fromSecondsSinceEpoch(ts).addDuration(d);
LiteralExtensionIV result = new LiteralExtensionIV(new XSDNumericIV(newdate.secondsSinceEpoch()), iv.getExtensionIV());
result.setValue(safeAsValue(result, vf, getDataType(iv)));
return result;
}
use of com.bigdata.rdf.internal.impl.literal.XSDNumericIV in project wikidata-query-rdf by wikimedia.
the class MWApiServiceCallUnitTest method testResults.
@Test
public void testResults() throws Exception {
List<OutputVariable> outputVars = ImmutableList.of(new OutputVariable(makeVariable("var"), "@name"), new OutputVariable(makeVariable("header"), "/api/header/@value"), new OutputVariable(OutputVariable.Type.ITEM, makeVariable("item"), "@id"), new OutputVariable(OutputVariable.Type.ORDINAL, makeVariable("num"), "@id"));
when(template.getItemsPath()).thenReturn("/api/result");
InputStream responseStream = new ByteArrayInputStream("<api><header value=\"heading\"></header><result name=\"result1\" id=\"Q1\"></result><result name=\"result2\"></result></api>".getBytes("UTF-8"));
Iterator<IBindingSet> results = createCall(outputVars).parseResponse(responseStream, binding, 3).getResultIterator();
assertTrue(results.hasNext());
IBindingSet result = results.next();
assertThat(result, binds("var", "result1"));
assertThat(result, binds("header", "heading"));
assertThat(result, bindsItem("item", "Q1"));
assertThat(result, binds("num", new XSDNumericIV<>(3)));
result = results.next();
assertThat(result, binds("var", "result2"));
assertThat(result, binds("header", "heading"));
assertThat(result, binds("num", new XSDNumericIV<>(4)));
assertFalse(results.hasNext());
}
Aggregations