Search in sources :

Example 1 with ResultWithContinue

use of org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceCall.ResultWithContinue 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());
}
Also used : ResultWithContinue(org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceCall.ResultWithContinue) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) OutputVariable(org.wikidata.query.rdf.blazegraph.mwapi.ApiTemplate.OutputVariable) Test(org.junit.Test)

Example 2 with ResultWithContinue

use of org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceCall.ResultWithContinue 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", "-||"));
}
Also used : ResultWithContinue(org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceCall.ResultWithContinue) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) OutputVariable(org.wikidata.query.rdf.blazegraph.mwapi.ApiTemplate.OutputVariable) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 Test (org.junit.Test)2 OutputVariable (org.wikidata.query.rdf.blazegraph.mwapi.ApiTemplate.OutputVariable)2 ResultWithContinue (org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceCall.ResultWithContinue)2