use of org.osate.aadl2.Connection in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method listConnectionsTest.
@Test
public void listConnectionsTest() throws Exception {
Connection responsesElement = Connection.newBuilder().build();
ListConnectionsResponse expectedResponse = ListConnectionsResponse.newBuilder().setNextPageToken("").addAllConnections(Arrays.asList(responsesElement)).build();
mockConnectionService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListConnectionsPagedResponse pagedListResponse = client.listConnections(parent);
List<Connection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListConnectionsRequest actualRequest = ((ListConnectionsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.osate.aadl2.Connection in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method getConnectionTest2.
@Test
public void getConnectionTest2() throws Exception {
Connection expectedResponse = Connection.newBuilder().setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString()).setFriendlyName("friendlyName461933014").setDescription("description-1724546052").setCreationTime(1932333101).setLastModifiedTime(-671513446).setHasCredential(true).build();
mockConnectionService.addResponse(expectedResponse);
String name = "name3373707";
Connection actualResponse = client.getConnection(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetConnectionRequest actualRequest = ((GetConnectionRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.osate.aadl2.Connection in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method updateConnectionTest2.
@Test
public void updateConnectionTest2() throws Exception {
Connection expectedResponse = Connection.newBuilder().setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString()).setFriendlyName("friendlyName461933014").setDescription("description-1724546052").setCreationTime(1932333101).setLastModifiedTime(-671513446).setHasCredential(true).build();
mockConnectionService.addResponse(expectedResponse);
String name = "name3373707";
Connection connection = Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Connection actualResponse = client.updateConnection(name, connection, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateConnectionRequest actualRequest = ((UpdateConnectionRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertEquals(connection, actualRequest.getConnection());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.osate.aadl2.Connection in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method listConnectionsTest2.
@Test
public void listConnectionsTest2() throws Exception {
Connection responsesElement = Connection.newBuilder().build();
ListConnectionsResponse expectedResponse = ListConnectionsResponse.newBuilder().setNextPageToken("").addAllConnections(Arrays.asList(responsesElement)).build();
mockConnectionService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListConnectionsPagedResponse pagedListResponse = client.listConnections(parent);
List<Connection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListConnectionsRequest actualRequest = ((ListConnectionsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.osate.aadl2.Connection in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method createConnectionTest.
@Test
public void createConnectionTest() throws Exception {
Connection expectedResponse = Connection.newBuilder().setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString()).setFriendlyName("friendlyName461933014").setDescription("description-1724546052").setCreationTime(1932333101).setLastModifiedTime(-671513446).setHasCredential(true).build();
mockConnectionService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Connection connection = Connection.newBuilder().build();
String connectionId = "connectionId1923106969";
Connection actualResponse = client.createConnection(parent, connection, connectionId);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateConnectionRequest actualRequest = ((CreateConnectionRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(connection, actualRequest.getConnection());
Assert.assertEquals(connectionId, actualRequest.getConnectionId());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations