Search in sources :

Example 6 with CreateInstanceRequest

use of com.google.spanner.admin.instance.v1.CreateInstanceRequest 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)

Aggregations

Operation (com.google.longrunning.Operation)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 ByteString (com.google.protobuf.ByteString)4 Test (org.junit.Test)4 CreateInstanceRequest (com.google.spanner.admin.instance.v1.CreateInstanceRequest)3 Cluster (com.google.bigtable.admin.v2.Cluster)2 CreateInstanceRequest (com.google.bigtable.admin.v2.CreateInstanceRequest)2 Instance (com.google.bigtable.admin.v2.Instance)2 Instance (com.google.spanner.admin.instance.v1.Instance)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ProjectName (com.google.bigtable.admin.v2.ProjectName)1 ContainerImage (com.google.cloud.notebooks.v1beta1.ContainerImage)1 CreateEnvironmentRequest (com.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest)1 CreateInstanceRequest (com.google.cloud.notebooks.v1beta1.CreateInstanceRequest)1 Environment (com.google.cloud.notebooks.v1beta1.Environment)1 Instance (com.google.cloud.notebooks.v1beta1.Instance)1 ProjectName (com.google.spanner.admin.instance.v1.ProjectName)1 BeforeClass (org.junit.BeforeClass)1