use of com.google.cloud.redis.v1beta1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method listAppProfilesTest.
@Test
public void listAppProfilesTest() throws Exception {
AppProfile responsesElement = AppProfile.newBuilder().build();
ListAppProfilesResponse expectedResponse = ListAppProfilesResponse.newBuilder().setNextPageToken("").addAllAppProfiles(Arrays.asList(responsesElement)).build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
ListAppProfilesPagedResponse pagedListResponse = client.listAppProfiles(parent);
List<AppProfile> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getAppProfilesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAppProfilesRequest actualRequest = ((ListAppProfilesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method deleteInstanceTest.
@Test
public void deleteInstanceTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
client.deleteInstance(name);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteInstanceRequest actualRequest = ((DeleteInstanceRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createAppProfileTest.
@Test
public void createAppProfileTest() throws Exception {
AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String appProfileId = "appProfileId704923523";
AppProfile appProfile = AppProfile.newBuilder().build();
AppProfile actualResponse = client.createAppProfile(parent, appProfileId, appProfile);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateAppProfileRequest actualRequest = ((CreateAppProfileRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(appProfileId, actualRequest.getAppProfileId());
Assert.assertEquals(appProfile, actualRequest.getAppProfile());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method listClustersTest.
@Test
public void listClustersTest() throws Exception {
ListClustersResponse expectedResponse = ListClustersResponse.newBuilder().addAllClusters(new ArrayList<Cluster>()).addAllFailedLocations(new ArrayList<String>()).setNextPageToken("nextPageToken-1386094857").build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
ListClustersResponse actualResponse = client.listClusters(parent);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListClustersRequest actualRequest = ((ListClustersRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method deleteInstanceExceptionTest.
@Test
public void deleteInstanceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
client.deleteInstance(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations