use of com.google.bigtable.v2.CheckAndMutateRowRequest in project java-bigtable-hbase by googleapis.
the class TestCheckAndMutateUtil method testRowMutations.
@Test
public /**
* Tests that a CheckAndMutate with a {@link RowMutations} works correctly for the filter and
* mutation aspects
*/
void testRowMutations() throws IOException {
CheckAndMutateUtil.RequestBuilder underTest = createRequestBuilder();
RowMutations rowMutations = new RowMutations(rowKey);
rowMutations.add(PUT);
CheckAndMutateRowRequest result = underTest.qualifier(qual).ifMatches(CompareOp.EQUAL, checkValue).withMutations(rowMutations).build().toProto(REQUEST_CONTEXT);
Assert.assertEquals(1, result.getTrueMutationsCount());
checkPutMutation(result.getTrueMutations(0));
checkPredicate(result);
}
use of com.google.bigtable.v2.CheckAndMutateRowRequest in project java-bigtable-hbase by googleapis.
the class TestCheckAndMutateUtil method testIfNotExists.
@Test
public /**
* Test to make sure that {@link CheckAndMutateUtil.RequestBuilder#ifNotExists()} works correctly
*/
void testIfNotExists() throws DoNotRetryIOException {
CheckAndMutateUtil.RequestBuilder underTest = createRequestBuilder();
CheckAndMutateRowRequest result = underTest.qualifier(qual).ifNotExists().withPut(PUT).build().toProto(REQUEST_CONTEXT);
Assert.assertEquals(1, result.getFalseMutationsCount());
checkPutMutation(result.getFalseMutations(0));
RowFilter expected = FILTERS.chain().filter(FAMILY_AND_QUAL_FILTER).filter(FILTERS.limit().cellsPerColumn(1)).toProto();
Assert.assertEquals(expected, result.getPredicateFilter());
}
use of com.google.bigtable.v2.CheckAndMutateRowRequest in project java-bigtable-hbase by googleapis.
the class TestCheckAndMutateUtil method testPut.
// ************************** TEST METHODS ***************************
@Test
public /**
* Tests that a CheckAndMutate with a {@link Put} works correctly for the filter and mutation
* aspects
*/
void testPut() throws DoNotRetryIOException {
CheckAndMutateUtil.RequestBuilder underTest = createRequestBuilder();
CheckAndMutateRowRequest result = underTest.qualifier(qual).ifMatches(CompareOp.EQUAL, checkValue).withPut(PUT).build().toProto(REQUEST_CONTEXT);
Assert.assertEquals(1, result.getTrueMutationsCount());
checkPutMutation(result.getTrueMutations(0));
checkPredicate(result);
}
use of com.google.bigtable.v2.CheckAndMutateRowRequest in project java-bigtable by googleapis.
the class ConditionalRowMutationTest method conditionTest.
@Test
public void conditionTest() {
ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY).condition(Filters.FILTERS.key().regex("a.*")).then(Mutation.create().deleteRow());
CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT);
assertThat(actualProto.getPredicateFilter()).isEqualTo(RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8("a.*")).build());
}
use of com.google.bigtable.v2.CheckAndMutateRowRequest in project java-bigtable by googleapis.
the class ConditionalRowMutationTest method thenTest.
@Test
public void thenTest() {
ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY).then(Mutation.create().deleteCells("family1", "qualifier1")).then(Mutation.create().deleteCells("family2", "qualifier2"));
CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT);
assertThat(actualProto.getTrueMutationsList()).containsExactly(com.google.bigtable.v2.Mutation.newBuilder().setDeleteFromColumn(DeleteFromColumn.newBuilder().setFamilyName("family1").setColumnQualifier(ByteString.copyFromUtf8("qualifier1"))).build(), com.google.bigtable.v2.Mutation.newBuilder().setDeleteFromColumn(DeleteFromColumn.newBuilder().setFamilyName("family2").setColumnQualifier(ByteString.copyFromUtf8("qualifier2"))).build()).inOrder();
}
Aggregations