|
| 1 | +/* |
| 2 | + * Copyright 2020 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package dialogflow.cx; |
| 18 | + |
| 19 | +// [START dialogflow_cx_list_testcase_result_sample] |
| 20 | + |
| 21 | +import com.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest; |
| 22 | +import com.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest.Builder; |
| 23 | +import com.google.cloud.dialogflow.cx.v3.TestCaseResult; |
| 24 | +import com.google.cloud.dialogflow.cx.v3.TestCasesClient; |
| 25 | +import com.google.cloud.dialogflow.cx.v3.TestCasesSettings; |
| 26 | +import java.io.IOException; |
| 27 | + |
| 28 | +public class ListTestCaseResults { |
| 29 | + |
| 30 | + public static void main(String[] args) throws IOException { |
| 31 | + // TODO(developer): Replace these variables before running the sample. |
| 32 | + String projectId = "my-project-id"; |
| 33 | + String agentId = "my-agent-id"; |
| 34 | + String testId = "my-test-id"; |
| 35 | + String location = "my-location"; |
| 36 | + listTestCaseResults(projectId, agentId, testId, location); |
| 37 | + } |
| 38 | + |
| 39 | + public static void listTestCaseResults( |
| 40 | + String projectId, String agentId, String testId, String location) throws IOException { |
| 41 | + String parent = |
| 42 | + "projects/" |
| 43 | + + projectId |
| 44 | + + "/locations/" |
| 45 | + + location |
| 46 | + + "/agents/" |
| 47 | + + agentId |
| 48 | + + "/testCases/" |
| 49 | + + testId; |
| 50 | + |
| 51 | + Builder req = ListTestCaseResultsRequest.newBuilder(); |
| 52 | + |
| 53 | + req.setParent(parent); |
| 54 | + req.setFilter("environment=draft"); |
| 55 | + |
| 56 | + TestCasesSettings testCasesSettings = |
| 57 | + TestCasesSettings.newBuilder() |
| 58 | + .setEndpoint(location + "-dialogflow.googleapis.com:443") |
| 59 | + .build(); |
| 60 | + TestCasesClient client = TestCasesClient.create(testCasesSettings); |
| 61 | + |
| 62 | + for (TestCaseResult element : client.listTestCaseResults(req.build()).iterateAll()) { |
| 63 | + System.out.println(element); |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | +// [END dialogflow_cx_list_testcase_result_sample] |
0 commit comments