Search in sources :

Example 11 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method createInstanceTest2.

@Test
public void createInstanceTest2() throws Exception {
    Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
    Operation resultOperation = Operation.newBuilder().setName("createInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockBigtableInstanceAdmin.addResponse(resultOperation);
    String parent = "parent-995424086";
    String instanceId = "instanceId902024336";
    Instance instance = Instance.newBuilder().build();
    Map<String, Cluster> clusters = new HashMap<>();
    Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance, clusters).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateInstanceRequest actualRequest = ((CreateInstanceRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(instanceId, actualRequest.getInstanceId());
    Assert.assertEquals(instance, actualRequest.getInstance());
    Assert.assertEquals(clusters, actualRequest.getClustersMap());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.bigtable.admin.v2.Instance) HashMap(java.util.HashMap) Cluster(com.google.bigtable.admin.v2.Cluster) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) CreateInstanceRequest(com.google.bigtable.admin.v2.CreateInstanceRequest) Test(org.junit.Test)

Example 12 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method updateInstanceExceptionTest.

@Test
public void updateInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        Instance request = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
        client.updateInstance(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) Instance(com.google.bigtable.admin.v2.Instance) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 13 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method updateInstanceTest.

@Test
public void updateInstanceTest() throws Exception {
    Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    Instance request = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
    Instance actualResponse = client.updateInstance(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    Instance actualRequest = ((Instance) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertEquals(request.getDisplayName(), actualRequest.getDisplayName());
    Assert.assertEquals(request.getState(), actualRequest.getState());
    Assert.assertEquals(request.getType(), actualRequest.getType());
    Assert.assertEquals(request.getLabelsMap(), actualRequest.getLabelsMap());
    Assert.assertEquals(request.getCreateTime(), actualRequest.getCreateTime());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.bigtable.admin.v2.Instance) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 14 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method createInstanceTest.

@Test
public void createInstanceTest() throws Exception {
    Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
    Operation resultOperation = Operation.newBuilder().setName("createInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockBigtableInstanceAdmin.addResponse(resultOperation);
    ProjectName parent = ProjectName.of("[PROJECT]");
    String instanceId = "instanceId902024336";
    Instance instance = Instance.newBuilder().build();
    Map<String, Cluster> clusters = new HashMap<>();
    Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance, clusters).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateInstanceRequest actualRequest = ((CreateInstanceRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(instanceId, actualRequest.getInstanceId());
    Assert.assertEquals(instance, actualRequest.getInstance());
    Assert.assertEquals(clusters, actualRequest.getClustersMap());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.bigtable.admin.v2.Instance) ProjectName(com.google.bigtable.admin.v2.ProjectName) HashMap(java.util.HashMap) Cluster(com.google.bigtable.admin.v2.Cluster) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) CreateInstanceRequest(com.google.bigtable.admin.v2.CreateInstanceRequest) Test(org.junit.Test)

Example 15 with Instance

use of com.google.cloud.redis.v1.Instance in project java-redis by googleapis.

the class ITSystemTest method testGetInstance.

@Test
public void testGetInstance() {
    Instance response = client.getInstance(INSTANCE_NAME);
    assertEquals(TIER, response.getTier());
    assertEquals(INSTANCE_NAME.toString(), response.getName());
}
Also used : Instance(com.google.cloud.redis.v1.Instance) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 Instance (com.google.cloud.compute.v1.Instance)11 InstancesClient (com.google.cloud.compute.v1.InstancesClient)11 Instance (com.google.bigtable.admin.v2.Instance)10 ByteString (com.google.protobuf.ByteString)9 AbstractMessage (com.google.protobuf.AbstractMessage)8 Operation (com.google.cloud.compute.v1.Operation)7 InsertInstanceRequest (com.google.cloud.compute.v1.InsertInstanceRequest)6 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)5 NetworkInterface (com.google.cloud.compute.v1.NetworkInterface)5 Instance (com.google.cloud.redis.v1.Instance)5 HashMap (java.util.HashMap)5 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 Cluster (com.google.bigtable.admin.v2.Cluster)4 Instance (com.google.cloud.redis.v1beta1.Instance)4 FieldMask (com.google.protobuf.FieldMask)4 Instance (com.scaleset.cfbuilder.ec2.Instance)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 Operation (com.google.longrunning.Operation)3 CreateInstanceRequest (com.google.bigtable.admin.v2.CreateInstanceRequest)2