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()));
}
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()));
}
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);
}
}
Aggregations