Search in sources :

Example 41 with Instance

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

the class CloudRedisClientTest method listInstancesTest2.

@Test
public void listInstancesTest2() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockCloudRedis.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
    List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudRedis.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse) Test(org.junit.Test)

Example 42 with Instance

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

the class CloudRedisClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockCloudRedis.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
    List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudRedis.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse) Test(org.junit.Test)

Example 43 with Instance

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

the class ITSystemTest method testListInstances.

@Test
public void testListInstances() {
    List<Instance> instances = Lists.newArrayList(client.listInstances(PARENT).iterateAll());
    for (Instance instance : instances) {
        if (INSTANCE_NAME.toString().equals(instance.getName())) {
            assertEquals(TIER, instance.getTier());
            assertEquals(INSTANCE_NAME.toString(), instance.getName());
        }
    }
}
Also used : Instance(com.google.cloud.redis.v1.Instance) Test(org.junit.Test)

Example 44 with Instance

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

the class ITSystemTest method testUpdateInstance.

@Test
public void testUpdateInstance() throws ExecutionException, InterruptedException {
    int memorySizeGb = 4;
    FieldMask updateMask = FieldMask.newBuilder().addAllPaths(Arrays.asList("memory_size_gb")).build();
    Instance instance = Instance.newBuilder().setName(INSTANCE_NAME.toString()).setMemorySizeGb(memorySizeGb).build();
    UpdateInstanceRequest updateInstanceRequest = UpdateInstanceRequest.newBuilder().setInstance(instance).setUpdateMask(updateMask).build();
    Instance actualInstance = client.updateInstanceAsync(updateInstanceRequest).get();
    assertEquals(memorySizeGb, actualInstance.getMemorySizeGb());
}
Also used : UpdateInstanceRequest(com.google.cloud.redis.v1.UpdateInstanceRequest) Instance(com.google.cloud.redis.v1.Instance) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 45 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)41 Instance (com.google.cloud.redis.v1beta1.Instance)34 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)30 Instance (com.google.cloud.compute.v1.Instance)25 InstancesClient (com.google.cloud.compute.v1.InstancesClient)19 ByteString (com.google.protobuf.ByteString)17 AbstractMessage (com.google.protobuf.AbstractMessage)15 Operation (com.google.cloud.compute.v1.Operation)13 Instance (com.google.spanner.admin.instance.v1.Instance)11 Instance (com.google.bigtable.admin.v2.Instance)10 InsertInstanceRequest (com.google.cloud.compute.v1.InsertInstanceRequest)10 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 Any (com.google.protobuf.Any)7 FieldMask (com.google.protobuf.FieldMask)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 ArrayList (java.util.ArrayList)7 NetworkInterface (com.google.cloud.compute.v1.NetworkInterface)6 Operation (com.google.longrunning.Operation)6