use of com.google.bigtable.admin.v2.PartialUpdateInstanceRequest in project java-bigtable by googleapis.
the class UpdateInstanceRequestTest method testDisplayName.
@Test
public void testDisplayName() {
UpdateInstanceRequest input = UpdateInstanceRequest.of("my-instance").setDisplayName("my display name");
PartialUpdateInstanceRequest actual = input.toProto("my-project");
PartialUpdateInstanceRequest expected = PartialUpdateInstanceRequest.newBuilder().setUpdateMask(FieldMask.newBuilder().addPaths("display_name")).setInstance(Instance.newBuilder().setName("projects/my-project/instances/my-instance").setDisplayName("my display name")).build();
assertThat(actual).isEqualTo(expected);
}
use of com.google.bigtable.admin.v2.PartialUpdateInstanceRequest in project java-bigtable by googleapis.
the class UpdateInstanceRequestTest method testType.
@Test
public void testType() {
UpdateInstanceRequest input = UpdateInstanceRequest.of("my-instance").setProductionType();
PartialUpdateInstanceRequest actual = input.toProto("my-project");
PartialUpdateInstanceRequest expected = PartialUpdateInstanceRequest.newBuilder().setUpdateMask(FieldMask.newBuilder().addPaths("type")).setInstance(Instance.newBuilder().setName("projects/my-project/instances/my-instance").setType(Type.PRODUCTION)).build();
assertThat(actual).isEqualTo(expected);
}
use of com.google.bigtable.admin.v2.PartialUpdateInstanceRequest in project java-bigtable by googleapis.
the class UpdateInstanceRequestTest method testLabels.
@Test
public void testLabels() {
UpdateInstanceRequest input = UpdateInstanceRequest.of("my-instance").setAllLabels(ImmutableMap.of("label1", "value1", "label2", "value2"));
PartialUpdateInstanceRequest actual = input.toProto("my-project");
PartialUpdateInstanceRequest expected = PartialUpdateInstanceRequest.newBuilder().setUpdateMask(FieldMask.newBuilder().addPaths("labels")).setInstance(Instance.newBuilder().setName("projects/my-project/instances/my-instance").putLabels("label1", "value1").putLabels("label2", "value2")).build();
assertThat(actual).isEqualTo(expected);
}
use of com.google.bigtable.admin.v2.PartialUpdateInstanceRequest in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method partialUpdateInstanceTest.
@Test
public void partialUpdateInstanceTest() throws Exception {
Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
Operation resultOperation = Operation.newBuilder().setName("partialUpdateInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableInstanceAdmin.addResponse(resultOperation);
Instance instance = Instance.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Instance actualResponse = client.partialUpdateInstanceAsync(instance, updateMask).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
PartialUpdateInstanceRequest actualRequest = ((PartialUpdateInstanceRequest) actualRequests.get(0));
Assert.assertEquals(instance, actualRequest.getInstance());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations