Search in sources :

Example 81 with Instance

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

the class ITNotebookServiceClientTest method testListInstances.

@Test
public void testListInstances() {
    ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(PARENT).build();
    for (Instance element : client.listInstances(request).iterateAll()) {
        if (element.getName().equals(NOTEBOOK_INSTANCE_ID)) {
            assertEquals(expectedNotebookInstance.getContainerImage(), element.getContainerImage());
            assertEquals(expectedNotebookInstance.getName(), element.getName());
            assertEquals(expectedNotebookInstance.getMachineType(), element.getMachineType());
            assertEquals(expectedNotebookInstance.getNetwork(), element.getNetwork());
            assertEquals(expectedNotebookInstance.getSubnet(), element.getSubnet());
        }
    }
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) ListInstancesRequest(com.google.cloud.notebooks.v1beta1.ListInstancesRequest) Test(org.junit.Test)

Example 82 with Instance

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

the class SpannerThreadsTest method mockGetInstanceResponse.

private void mockGetInstanceResponse() {
    InstanceName name2 = InstanceName.of("[PROJECT]", "[INSTANCE]");
    InstanceConfigName config = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
    String displayName = "displayName1615086568";
    int nodeCount = 1539922066;
    Instance expectedResponse = Instance.newBuilder().setName(name2.toString()).setConfig(config.toString()).setDisplayName(displayName).setNodeCount(nodeCount).build();
    mockInstanceAdmin.addResponse(expectedResponse);
}
Also used : InstanceName(com.google.spanner.admin.instance.v1.InstanceName) Instance(com.google.spanner.admin.instance.v1.Instance) InstanceConfigName(com.google.spanner.admin.instance.v1.InstanceConfigName)

Example 83 with Instance

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

the class InstanceAdminClientTest method createInstanceTest2.

@Test
public void createInstanceTest2() throws Exception {
    Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setConfig(InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]").toString()).setDisplayName("displayName1714148973").setNodeCount(1539922066).setProcessingUnits(-329117885).putAllLabels(new HashMap<String, String>()).addAllEndpointUris(new ArrayList<String>()).build();
    Operation resultOperation = Operation.newBuilder().setName("createInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockInstanceAdmin.addResponse(resultOperation);
    String parent = "parent-995424086";
    String instanceId = "instanceId902024336";
    Instance instance = Instance.newBuilder().build();
    Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockInstanceAdmin.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.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.spanner.admin.instance.v1.Instance) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) CreateInstanceRequest(com.google.spanner.admin.instance.v1.CreateInstanceRequest) Test(org.junit.Test)

Example 84 with Instance

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

the class InstanceAdminClientTest method createInstanceExceptionTest.

@Test
public void createInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockInstanceAdmin.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        String instanceId = "instanceId902024336";
        Instance instance = Instance.newBuilder().build();
        client.createInstanceAsync(parent, instanceId, instance).get();
        Assert.fail("No exception raised");
    } catch (ExecutionException e) {
        Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
        InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
        Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.spanner.admin.instance.v1.ProjectName) Instance(com.google.spanner.admin.instance.v1.Instance) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 85 with Instance

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

the class InstanceAdminClientTest method getInstanceTest.

@Test
public void getInstanceTest() throws Exception {
    Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setConfig(InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]").toString()).setDisplayName("displayName1714148973").setNodeCount(1539922066).setProcessingUnits(-329117885).putAllLabels(new HashMap<String, String>()).addAllEndpointUris(new ArrayList<String>()).build();
    mockInstanceAdmin.addResponse(expectedResponse);
    InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
    Instance actualResponse = client.getInstance(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetInstanceRequest actualRequest = ((GetInstanceRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : InstanceName(com.google.spanner.admin.instance.v1.InstanceName) AbstractMessage(com.google.protobuf.AbstractMessage) GetInstanceRequest(com.google.spanner.admin.instance.v1.GetInstanceRequest) Instance(com.google.spanner.admin.instance.v1.Instance) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)43 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)42 Instance (com.google.cloud.redis.v1beta1.Instance)34 Instance (com.google.cloud.compute.v1.Instance)25 InstancesClient (com.google.cloud.compute.v1.InstancesClient)19 AbstractMessage (com.google.protobuf.AbstractMessage)17 ByteString (com.google.protobuf.ByteString)17 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 Operation (com.google.longrunning.Operation)10 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 Any (com.google.protobuf.Any)8 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)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