From d7ecfd2a71896d1b9cf9401d6e75e80168cac4cd Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Fri, 17 Aug 2018 17:22:01 -0400 Subject: [PATCH] tweaks --- .../v2/BigtableInstanceAdminClientTest.java | 49 ++++++++++--------- .../admin/v2/models/InstanceTest.java | 4 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java index 1993b01162b0..1adbf9be0641 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java @@ -30,9 +30,7 @@ import com.google.bigtable.admin.v2.CreateInstanceMetadata; import com.google.bigtable.admin.v2.Instance.Type; import com.google.bigtable.admin.v2.InstanceName; -import com.google.bigtable.admin.v2.ListInstancesResponse; import com.google.bigtable.admin.v2.LocationName; -import com.google.bigtable.admin.v2.PartialUpdateInstanceRequest; import com.google.bigtable.admin.v2.ProjectName; import com.google.bigtable.admin.v2.StorageType; import com.google.bigtable.admin.v2.UpdateInstanceMetadata; @@ -135,7 +133,7 @@ public void testCreateInstance() { mockOperationResult(mockCreateInstanceCallable, expectedRequest, expectedResponse); // Execute - com.google.cloud.bigtable.admin.v2.models.Instance actualResult = adminClient.createInstance( + Instance actualResult = adminClient.createInstance( CreateInstanceRequest.of(INSTANCE_NAME.getInstance()) .setType(Type.DEVELOPMENT) .addCluster("cluster1", "us-east1-c", 1, StorageType.SSD) @@ -149,7 +147,7 @@ public void testCreateInstance() { public void testUpdateInstance() { // Setup com.google.bigtable.admin.v2.PartialUpdateInstanceRequest expectedRequest = - PartialUpdateInstanceRequest.newBuilder() + com.google.bigtable.admin.v2.PartialUpdateInstanceRequest.newBuilder() .setUpdateMask( FieldMask.newBuilder() .addPaths("display_name") @@ -169,7 +167,7 @@ public void testUpdateInstance() { mockOperationResult(mockUpdateInstanceCallable, expectedRequest, expectedResponse); // Execute - com.google.cloud.bigtable.admin.v2.models.Instance actualResult = adminClient.updateInstance( + Instance actualResult = adminClient.updateInstance( UpdateInstanceRequest.of(INSTANCE_NAME.getInstance()) .setDisplayName("new display name") ); @@ -209,15 +207,18 @@ public void testListInstances() { .setParent(PROJECT_NAME.toString()) .build(); - com.google.bigtable.admin.v2.ListInstancesResponse expectedResponse = ListInstancesResponse - .newBuilder() - .addInstances( - com.google.bigtable.admin.v2.Instance.newBuilder().setName(INSTANCE_NAME + "1").build() - ) - .addInstances( - com.google.bigtable.admin.v2.Instance.newBuilder().setName(INSTANCE_NAME + "2").build() - ) - .build(); + com.google.bigtable.admin.v2.ListInstancesResponse expectedResponse = + com.google.bigtable.admin.v2.ListInstancesResponse + .newBuilder() + .addInstances( + com.google.bigtable.admin.v2.Instance.newBuilder().setName(INSTANCE_NAME + "1") + .build() + ) + .addInstances( + com.google.bigtable.admin.v2.Instance.newBuilder().setName(INSTANCE_NAME + "2") + .build() + ) + .build(); Mockito.when(mockListInstancesCallable.futureCall(expectedRequest)) .thenReturn(ApiFutures.immediateFuture(expectedResponse)); @@ -240,15 +241,17 @@ public void testListInstancesFailedZone() { .setParent(PROJECT_NAME.toString()) .build(); - com.google.bigtable.admin.v2.ListInstancesResponse expectedResponse = ListInstancesResponse - .newBuilder() - .addInstances( - com.google.bigtable.admin.v2.Instance.newBuilder().setName(INSTANCE_NAME + "1").build() - ) - .addFailedLocations( - LocationName.of(PROJECT_NAME.getProject(), "us-east1-d").toString() - ) - .build(); + com.google.bigtable.admin.v2.ListInstancesResponse expectedResponse = + com.google.bigtable.admin.v2.ListInstancesResponse + .newBuilder() + .addInstances( + com.google.bigtable.admin.v2.Instance.newBuilder().setName(INSTANCE_NAME + "1") + .build() + ) + .addFailedLocations( + LocationName.of(PROJECT_NAME.getProject(), "us-east1-d").toString() + ) + .build(); Mockito.when(mockListInstancesCallable.futureCall(expectedRequest)) .thenReturn(ApiFutures.immediateFuture(expectedResponse)); diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/models/InstanceTest.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/models/InstanceTest.java index 1904028744ab..38199bb5bf23 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/models/InstanceTest.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/models/InstanceTest.java @@ -36,7 +36,7 @@ public void testFromProto() { .putLabels("label2", "value2") .build(); - Instance result = Instance.PROTO_TRANSFORMER.apply(proto); + Instance result = Instance.fromProto(proto); assertThat(result.getId()).isEqualTo("my-instance"); assertThat(result.getDisplayName()).isEqualTo("my display name"); @@ -61,7 +61,7 @@ public void testRequiresName() { Exception actualException = null; try { - Instance.PROTO_TRANSFORMER.apply(proto); + Instance.fromProto(proto); } catch (Exception e) { actualException = e; }