Search in sources :

Example 1 with LogExport

use of com.ibm.watson.developer_cloud.conversation.v1.model.LogExport in project java-sdk by watson-developer-cloud.

the class AssistantServiceIT method testListLogsWithPaging.

/**
 * Test listLogs with pagination.
 */
@Test
@Ignore("To be run locally until we fix the Rate limitation issue")
public void testListLogsWithPaging() {
    try {
        ListLogsOptions.Builder listOptionsBuilder = new ListLogsOptions.Builder(workspaceId);
        listOptionsBuilder.sort("-request_timestamp");
        listOptionsBuilder.filter("request.intents:intent:off_topic");
        listOptionsBuilder.pageLimit(1L);
        LogCollection response = service.listLogs(listOptionsBuilder.build()).execute();
        assertNotNull(response);
        assertNotNull(response.getLogs());
        assertNotNull(response.getPagination());
        // Empirically -- no refresh_url in pagination of listLogs
        // assertNotNull(response.getPagination().getRefreshUrl());
        assertNotNull(response.getPagination().getNextUrl());
        assertNotNull(response.getPagination().getCursor());
        assertTrue(response.getLogs().size() == 1);
        LogExport logEntry1 = response.getLogs().get(0);
        String cursor = response.getPagination().getCursor();
        response = service.listLogs(listOptionsBuilder.cursor(cursor).build()).execute();
        assertNotNull(response.getLogs());
        assertTrue(response.getLogs().size() == 1);
        LogExport logEntry2 = response.getLogs().get(0);
        Date requestDate1 = isoDateFormat.parse(logEntry1.getRequestTimestamp());
        Date requestDate2 = isoDateFormat.parse(logEntry2.getRequestTimestamp());
        assertTrue(requestDate2.before(requestDate1));
    } catch (Exception ex) {
        fail(ex.getMessage());
    }
}
Also used : ListLogsOptions(com.ibm.watson.developer_cloud.assistant.v1.model.ListLogsOptions) LogCollection(com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection) LogExport(com.ibm.watson.developer_cloud.assistant.v1.model.LogExport) Date(java.util.Date) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with LogExport

use of com.ibm.watson.developer_cloud.conversation.v1.model.LogExport in project java-sdk by watson-developer-cloud.

the class ConversationServiceIT method testListLogsWithPaging.

/**
 * Test listLogs with pagination.
 */
@Test
@Ignore("To be run locally until we fix the Rate limitation issue")
public void testListLogsWithPaging() {
    try {
        ListLogsOptions.Builder listOptionsBuilder = new ListLogsOptions.Builder(workspaceId);
        listOptionsBuilder.sort("-request_timestamp");
        listOptionsBuilder.filter("request.intents:intent:off_topic");
        listOptionsBuilder.pageLimit(1L);
        LogCollection response = service.listLogs(listOptionsBuilder.build()).execute();
        assertNotNull(response);
        assertNotNull(response.getLogs());
        assertNotNull(response.getPagination());
        // Empirically -- no refresh_url in pagination of listLogs
        // assertNotNull(response.getPagination().getRefreshUrl());
        assertNotNull(response.getPagination().getNextUrl());
        assertNotNull(response.getPagination().getCursor());
        assertTrue(response.getLogs().size() == 1);
        LogExport logEntry1 = response.getLogs().get(0);
        String cursor = response.getPagination().getCursor();
        response = service.listLogs(listOptionsBuilder.cursor(cursor).build()).execute();
        assertNotNull(response.getLogs());
        assertTrue(response.getLogs().size() == 1);
        LogExport logEntry2 = response.getLogs().get(0);
        Date requestDate1 = isoDateFormat.parse(logEntry1.getRequestTimestamp());
        Date requestDate2 = isoDateFormat.parse(logEntry2.getRequestTimestamp());
        assertTrue(requestDate2.before(requestDate1));
    } catch (Exception ex) {
        fail(ex.getMessage());
    }
}
Also used : ListLogsOptions(com.ibm.watson.developer_cloud.conversation.v1.model.ListLogsOptions) LogCollection(com.ibm.watson.developer_cloud.conversation.v1.model.LogCollection) LogExport(com.ibm.watson.developer_cloud.conversation.v1.model.LogExport) Date(java.util.Date) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)2 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)2 Date (java.util.Date)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 ListLogsOptions (com.ibm.watson.developer_cloud.assistant.v1.model.ListLogsOptions)1 LogCollection (com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection)1 LogExport (com.ibm.watson.developer_cloud.assistant.v1.model.LogExport)1 ListLogsOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListLogsOptions)1 LogCollection (com.ibm.watson.developer_cloud.conversation.v1.model.LogCollection)1 LogExport (com.ibm.watson.developer_cloud.conversation.v1.model.LogExport)1