use of com.ibm.watson.developer_cloud.conversation.v1.model.Pagination in project java-sdk by watson-developer-cloud.
the class PaginationTypeAdapterTest method testParseTypeAdapter.
/**
* Test parse type adapter.
*
* @throws FileNotFoundException the file not found exception
*/
@Test
public void testParseTypeAdapter() throws FileNotFoundException {
Pagination pagination = loadFixture(FIXTURE, Pagination.class);
assertEquals(pagination.getCursor(), "batman");
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Pagination in project java-sdk by watson-developer-cloud.
the class LogPaginationTypeAdapter method read.
/*
* (non-Javadoc)
* @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
*/
@Override
public LogPagination read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return null;
}
reader.beginObject();
LogPagination pagination = new LogPagination();
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals(NEXT_URL)) {
String nextUrl = reader.nextString();
HttpUrl url = HttpUrl.parse(DEFAULT_ENDPOINT + nextUrl);
pagination.setCursor(url.queryParameter(CURSOR));
pagination.setNextUrl(nextUrl);
} else if (name.equals(MATCHED)) {
pagination.setMatched(reader.nextLong());
} else {
reader.skipValue();
}
}
reader.endObject();
return pagination;
}
Aggregations