use of org.wikidata.query.rdf.blazegraph.mwapi.ApiTemplate.OutputVariable in project wikidata-query-rdf by wikimedia.
the class MWApiServiceCallUnitTest method testResultsBadXML.
@Test(expected = SAXException.class)
public void testResultsBadXML() throws Exception {
List<OutputVariable> outputVars = ImmutableList.of(new OutputVariable(makeVariable("var"), "@test"));
InputStream responseStream = new ByteArrayInputStream("Fatal error: I am a teapot".getBytes("UTF-8"));
when(template.getItemsPath()).thenReturn("/api/result");
Object results = createCall(outputVars).parseResponse(responseStream, binding);
}
use of org.wikidata.query.rdf.blazegraph.mwapi.ApiTemplate.OutputVariable in project wikidata-query-rdf by wikimedia.
the class MWApiServiceCallUnitTest method testEmptyResult.
@Test
public void testEmptyResult() throws Exception {
List<OutputVariable> outputVars = ImmutableList.of(new OutputVariable(makeVariable("var"), "@test"));
InputStream responseStream = new ByteArrayInputStream("<result></result>".getBytes("UTF-8"));
when(template.getItemsPath()).thenReturn("/api/result");
Object results = createCall(outputVars).parseResponse(responseStream, binding);
assertNull(results);
}
use of org.wikidata.query.rdf.blazegraph.mwapi.ApiTemplate.OutputVariable in project wikidata-query-rdf by wikimedia.
the class MWApiServiceCallUnitTest method testResultsNoContinue.
@Test
public void testResultsNoContinue() throws Exception {
List<OutputVariable> outputVars = ImmutableList.of(new OutputVariable(makeVariable("var"), "@name"));
when(template.getItemsPath()).thenReturn("/api/result");
InputStream responseStream = new ByteArrayInputStream("<api><header value=\"heading\"></header><result name=\"result1\">datadata</result></api>".getBytes("UTF-8"));
ResultWithContinue results = createCall(outputVars).parseResponse(responseStream, binding);
assertNull(results.getContinue());
}
use of org.wikidata.query.rdf.blazegraph.mwapi.ApiTemplate.OutputVariable in project wikidata-query-rdf by wikimedia.
the class MWApiServiceCallUnitTest method testResultsWithContinue.
@Test
public void testResultsWithContinue() throws Exception {
List<OutputVariable> outputVars = ImmutableList.of(new OutputVariable(makeVariable("var"), "@name"));
when(template.getItemsPath()).thenReturn("/api/result");
InputStream responseStream = new ByteArrayInputStream("<api><continue sroffset=\"5\" continue=\"-||\"></continue><header value=\"heading\"></header><result name=\"result1\">datadata</result></api>".getBytes("UTF-8"));
ResultWithContinue results = createCall(outputVars).parseResponse(responseStream, binding);
Map<String, String> continueMap = results.getContinue();
assertThat(continueMap.keySet(), containsInAnyOrder("sroffset", "continue"));
assertThat(continueMap, hasEntry("sroffset", "5"));
assertThat(continueMap, hasEntry("continue", "-||"));
}
Aggregations