Search in sources :

Example 11 with Pagination

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");
}
Also used : Pagination(com.ibm.watson.developer_cloud.assistant.v1.model.Pagination) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 12 with Pagination

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;
}
Also used : LogPagination(com.ibm.watson.developer_cloud.conversation.v1.model.LogPagination) HttpUrl(okhttp3.HttpUrl)

Aggregations

Test (org.junit.Test)9 NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)5 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)4 Pagination (com.ibm.watson.developer_cloud.assistant.v1.model.Pagination)3 CreateEntityOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions)3 Pagination (com.ibm.watson.developer_cloud.conversation.v1.model.Pagination)3 HttpUrl (okhttp3.HttpUrl)3 CreateValueOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateValueOptions)2 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)2 Ignore (org.junit.Ignore)2 CreateDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions)1 CreateSynonymOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateSynonymOptions)1 DeleteDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteDialogNodeOptions)1 DeleteEntityOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteEntityOptions)1 DeleteSynonymOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteSynonymOptions)1 DeleteValueOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteValueOptions)1 DialogNodeCollection (com.ibm.watson.developer_cloud.conversation.v1.model.DialogNodeCollection)1 EntityCollection (com.ibm.watson.developer_cloud.conversation.v1.model.EntityCollection)1 EntityExport (com.ibm.watson.developer_cloud.conversation.v1.model.EntityExport)1 ListDialogNodesOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListDialogNodesOptions)1