/** * Creates the underlying {@link CheckAndMutateRowRequest} protobuf. * * <p>This method is considered an internal implementation detail and not meant to be used by * applications. */ @InternalApi public CheckAndMutateRowRequest toProto(RequestContext requestContext) { Preconditions.checkState( !builder.getTrueMutationsList().isEmpty() || !builder.getFalseMutationsList().isEmpty(), "ConditionalRowMutations must have `then` or `otherwise` mutations."); String tableName = NameUtil.formatTableName( requestContext.getProjectId(), requestContext.getInstanceId(), tableId); return builder .setTableName(tableName.toString()) .setAppProfileId(requestContext.getAppProfileId()) .build(); } }
@Test public void requestIsCorrect() { callable.futureCall( ConditionalRowMutation.create("my-table", "row-key").then(Mutation.create().deleteRow())); assertThat(inner.request) .isEqualTo( CheckAndMutateRowRequest.newBuilder() .setTableName( NameUtil.formatTableName( requestContext.getProjectId(), requestContext.getInstanceId(), "my-table")) .setRowKey(ByteString.copyFromUtf8("row-key")) .setAppProfileId(requestContext.getAppProfileId()) .addTrueMutations( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromRow(DeleteFromRow.getDefaultInstance())) .build()); }
@Test public void toProtoTest() { Mutation ignoredThenMutation = Mutation.create().deleteRow(); ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY).then(ignoredThenMutation); CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT).toBuilder().clearTrueMutations().build(); assertThat(actualProto) .isEqualTo( CheckAndMutateRowRequest.newBuilder() .setTableName(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID)) .setAppProfileId(APP_PROFILE_ID) .setRowKey(TEST_KEY) .build()); }
.setTableName(tableName) .setRowKey(rowKey) .setPredicateFilter(predicateFilter)
.setTableName(tableName == null ? null : tableName.toString()) .setRowKey(rowKey) .setPredicateFilter(predicateFilter)
/** * Creates the underlying {@link CheckAndMutateRowRequest} protobuf. * * <p>This method is considered an internal implementation detail and not meant to be used by * applications. */ @InternalApi public CheckAndMutateRowRequest toProto(RequestContext requestContext) { Preconditions.checkState( !builder.getTrueMutationsList().isEmpty() || !builder.getFalseMutationsList().isEmpty(), "ConditionalRowMutations must have `then` or `otherwise` mutations."); String tableName = NameUtil.formatTableName( requestContext.getProjectId(), requestContext.getInstanceId(), tableId); return builder .setTableName(tableName.toString()) .setAppProfileId(requestContext.getAppProfileId()) .build(); } }
.setTableName(tableName) .setRowKey(rowKey) .setPredicateFilter(predicateFilter)
.setTableName(tableName == null ? null : tableName.toString()) .setRowKey(rowKey) .setPredicateFilter(predicateFilter)