Search in sources :

Example 1 with PartialUpdateInstanceRequest

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);
}
Also used : PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) Test(org.junit.Test)

Example 2 with PartialUpdateInstanceRequest

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);
}
Also used : PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) Test(org.junit.Test)

Example 3 with PartialUpdateInstanceRequest

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);
}
Also used : PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) Test(org.junit.Test)

Example 4 with PartialUpdateInstanceRequest

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()));
}
Also used : PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.bigtable.admin.v2.Instance) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Aggregations

PartialUpdateInstanceRequest (com.google.bigtable.admin.v2.PartialUpdateInstanceRequest)4 Test (org.junit.Test)4 Instance (com.google.bigtable.admin.v2.Instance)1 Operation (com.google.longrunning.Operation)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 ByteString (com.google.protobuf.ByteString)1 FieldMask (com.google.protobuf.FieldMask)1