use of com.google.cloud.redis.v1beta1.InstanceName in project java-spanner by googleapis.
the class DatabaseAdminClientTest method createDatabaseTest.
@Test
public void createDatabaseTest() throws Exception {
Database expectedResponse = Database.newBuilder().setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()).setCreateTime(Timestamp.newBuilder().build()).setRestoreInfo(RestoreInfo.newBuilder().build()).setEncryptionConfig(EncryptionConfig.newBuilder().build()).addAllEncryptionInfo(new ArrayList<EncryptionInfo>()).setVersionRetentionPeriod("versionRetentionPeriod-629783929").setEarliestVersionTime(Timestamp.newBuilder().build()).setDefaultLeader("defaultLeader759009962").setDatabaseDialect(DatabaseDialect.forNumber(0)).build();
Operation resultOperation = Operation.newBuilder().setName("createDatabaseTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockDatabaseAdmin.addResponse(resultOperation);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String createStatement = "createStatement744686547";
Database actualResponse = client.createDatabaseAsync(parent, createStatement).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDatabaseRequest actualRequest = ((CreateDatabaseRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(createStatement, actualRequest.getCreateStatement());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.InstanceName in project java-spanner by googleapis.
the class InstanceAdminClientTest method deleteInstanceExceptionTest.
@Test
public void deleteInstanceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockInstanceAdmin.addException(exception);
try {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
client.deleteInstance(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.redis.v1beta1.InstanceName in project java-spanner by googleapis.
the class InstanceAdminClientTest method deleteInstanceTest.
@Test
public void deleteInstanceTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockInstanceAdmin.addResponse(expectedResponse);
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
client.deleteInstance(name);
List<AbstractMessage> actualRequests = mockInstanceAdmin.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 gapic-generator-java by googleapis.
the class SyncDeleteInstanceInstancename method syncDeleteInstanceInstancename.
public static void syncDeleteInstanceInstancename() throws Exception {
// It may require modifications to work in your environment.
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
cloudRedisClient.deleteInstanceAsync(name).get();
}
}
use of com.google.cloud.redis.v1beta1.InstanceName in project gapic-generator-java by googleapis.
the class SyncGetInstanceInstancename method syncGetInstanceInstancename.
public static void syncGetInstanceInstancename() throws Exception {
// It may require modifications to work in your environment.
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
Instance response = cloudRedisClient.getInstance(name);
}
}
Aggregations