Search in sources :

Example 1 with TestCaseResult

use of com.google.cloud.dialogflow.cx.v3.TestCaseResult in project java-dialogflow-cx by googleapis.

the class TestCasesClientTest method listTestCaseResultsTest.

@Test
public void listTestCaseResultsTest() throws Exception {
    TestCaseResult responsesElement = TestCaseResult.newBuilder().build();
    ListTestCaseResultsResponse expectedResponse = ListTestCaseResultsResponse.newBuilder().setNextPageToken("").addAllTestCaseResults(Arrays.asList(responsesElement)).build();
    mockTestCases.addResponse(expectedResponse);
    TestCaseName parent = TestCaseName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[TEST_CASE]");
    ListTestCaseResultsPagedResponse pagedListResponse = client.listTestCaseResults(parent);
    List<TestCaseResult> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTestCaseResultsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockTestCases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTestCaseResultsRequest actualRequest = ((ListTestCaseResultsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListTestCaseResultsPagedResponse(com.google.cloud.dialogflow.cx.v3.TestCasesClient.ListTestCaseResultsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with TestCaseResult

use of com.google.cloud.dialogflow.cx.v3.TestCaseResult in project java-dialogflow-cx by googleapis.

the class TestCasesClientTest method listTestCaseResultsTest2.

@Test
public void listTestCaseResultsTest2() throws Exception {
    TestCaseResult responsesElement = TestCaseResult.newBuilder().build();
    ListTestCaseResultsResponse expectedResponse = ListTestCaseResultsResponse.newBuilder().setNextPageToken("").addAllTestCaseResults(Arrays.asList(responsesElement)).build();
    mockTestCases.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListTestCaseResultsPagedResponse pagedListResponse = client.listTestCaseResults(parent);
    List<TestCaseResult> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTestCaseResultsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockTestCases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTestCaseResultsRequest actualRequest = ((ListTestCaseResultsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListTestCaseResultsPagedResponse(com.google.cloud.dialogflow.cx.v3.TestCasesClient.ListTestCaseResultsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 3 with TestCaseResult

use of com.google.cloud.dialogflow.cx.v3.TestCaseResult in project java-dialogflow-cx by googleapis.

the class ListTestCaseResults method listTestCaseResults.

public static void listTestCaseResults(String projectId, String agentId, String testId, String location) throws IOException {
    String parent = "projects/" + projectId + "/locations/" + location + "/agents/" + agentId + "/testCases/" + testId;
    Builder req = ListTestCaseResultsRequest.newBuilder();
    req.setParent(parent);
    req.setFilter("environment=draft");
    TestCasesSettings testCasesSettings = TestCasesSettings.newBuilder().setEndpoint(location + "-dialogflow.googleapis.com:443").build();
    TestCasesClient client = TestCasesClient.create(testCasesSettings);
    for (TestCaseResult element : client.listTestCaseResults(req.build()).iterateAll()) {
        System.out.println(element);
    }
}
Also used : TestCasesSettings(com.google.cloud.dialogflow.cx.v3.TestCasesSettings) TestCaseResult(com.google.cloud.dialogflow.cx.v3.TestCaseResult) Builder(com.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest.Builder) TestCasesClient(com.google.cloud.dialogflow.cx.v3.TestCasesClient)

Aggregations

ListTestCaseResultsPagedResponse (com.google.cloud.dialogflow.cx.v3.TestCasesClient.ListTestCaseResultsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 Builder (com.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest.Builder)1 TestCaseResult (com.google.cloud.dialogflow.cx.v3.TestCaseResult)1 TestCasesClient (com.google.cloud.dialogflow.cx.v3.TestCasesClient)1 TestCasesSettings (com.google.cloud.dialogflow.cx.v3.TestCasesSettings)1