Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbernstein2 committed Aug 17, 2018
1 parent 08592c7 commit d7ecfd2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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")
);
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -61,7 +61,7 @@ public void testRequiresName() {
Exception actualException = null;

try {
Instance.PROTO_TRANSFORMER.apply(proto);
Instance.fromProto(proto);
} catch (Exception e) {
actualException = e;
}
Expand Down

0 comments on commit d7ecfd2

Please sign in to comment.