use of com.google.cloud.dialogflow.v2beta1.VersionsClient.ListVersionsPagedResponse in project java-dialogflow by googleapis.
the class VersionsClientTest method listVersionsTest.
@Test
public void listVersionsTest() throws Exception {
Version responsesElement = Version.newBuilder().build();
ListVersionsResponse expectedResponse = ListVersionsResponse.newBuilder().setNextPageToken("").addAllVersions(Arrays.asList(responsesElement)).build();
mockVersions.addResponse(expectedResponse);
AgentName parent = AgentName.ofProjectName("[PROJECT]");
ListVersionsPagedResponse pagedListResponse = client.listVersions(parent);
List<Version> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockVersions.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListVersionsRequest actualRequest = ((ListVersionsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2beta1.VersionsClient.ListVersionsPagedResponse in project java-dialogflow-cx by googleapis.
the class VersionsClientTest method listVersionsTest2.
@Test
public void listVersionsTest2() throws Exception {
Version responsesElement = Version.newBuilder().build();
ListVersionsResponse expectedResponse = ListVersionsResponse.newBuilder().setNextPageToken("").addAllVersions(Arrays.asList(responsesElement)).build();
mockVersions.addResponse(expectedResponse);
String parent = "parent-995424086";
ListVersionsPagedResponse pagedListResponse = client.listVersions(parent);
List<Version> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockVersions.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListVersionsRequest actualRequest = ((ListVersionsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2beta1.VersionsClient.ListVersionsPagedResponse in project java-dialogflow-cx by googleapis.
the class VersionsClientTest method listVersionsTest.
@Test
public void listVersionsTest() throws Exception {
Version responsesElement = Version.newBuilder().build();
ListVersionsResponse expectedResponse = ListVersionsResponse.newBuilder().setNextPageToken("").addAllVersions(Arrays.asList(responsesElement)).build();
mockVersions.addResponse(expectedResponse);
FlowName parent = FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]");
ListVersionsPagedResponse pagedListResponse = client.listVersions(parent);
List<Version> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockVersions.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListVersionsRequest actualRequest = ((ListVersionsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations