Search in sources :

Example 1 with ReadModifyWriteRule

use of com.google.bigtable.v2.ReadModifyWriteRule in project simple-bigtable by spotify.

the class BigtableReadModifyWriteImplTest method testMultipleRules.

@Test
public void testMultipleRules() throws Exception {
    final BigtableReadModifyWriteImpl appendValue = (BigtableReadModifyWriteImpl) bigtableReadModifyWrite.read("family1:qualifier1").thenIncrementAmount(15).read("family2:qualifier2").thenAppendValue(ByteString.copyFromUtf8("value")).read("family3:qualifier3").thenIncrementAmount(30);
    verifyReadModifyWriteRequest();
    appendValue.execute();
    appendValue.executeAsync();
    assertEquals(3, appendValue.getReadModifyWriteRequest().getRulesCount());
    assertEquals(ReadModifyWriteRule.getDefaultInstance(), appendValue.getReadModifyWriteRule().build());
    ReadModifyWriteRule rule = appendValue.getReadModifyWriteRequest().getRules(0);
    assertEquals("family1", rule.getFamilyName());
    assertEquals("qualifier1", rule.getColumnQualifier().toStringUtf8());
    assertEquals(ByteString.EMPTY, rule.getAppendValue());
    assertEquals(15L, rule.getIncrementAmount());
    rule = appendValue.getReadModifyWriteRequest().getRules(1);
    assertEquals("family2", rule.getFamilyName());
    assertEquals("qualifier2", rule.getColumnQualifier().toStringUtf8());
    assertEquals("value", rule.getAppendValue().toStringUtf8());
    assertEquals(0L, rule.getIncrementAmount());
    rule = appendValue.getReadModifyWriteRequest().getRules(2);
    assertEquals("family3", rule.getFamilyName());
    assertEquals("qualifier3", rule.getColumnQualifier().toStringUtf8());
    assertEquals(ByteString.EMPTY, rule.getAppendValue());
    assertEquals(30L, rule.getIncrementAmount());
    verify(bigtableMock.getMockedDataClient()).readModifyWriteRow(appendValue.getReadModifyWriteRequest().build());
    verify(bigtableMock.getMockedDataClient()).readModifyWriteRowAsync(appendValue.getReadModifyWriteRequest().build());
    verifyNoMoreInteractions(bigtableMock.getMockedDataClient());
}
Also used : ReadModifyWriteRule(com.google.bigtable.v2.ReadModifyWriteRule) Test(org.junit.Test)

Example 2 with ReadModifyWriteRule

use of com.google.bigtable.v2.ReadModifyWriteRule in project simple-bigtable by spotify.

the class BigtableReadModifyWriteImplTest method testReadThenIncrement.

@Test
public void testReadThenIncrement() throws Exception {
    final BigtableReadModifyWriteImpl appendValue = (BigtableReadModifyWriteImpl) bigtableReadModifyWrite.read("family:qualifier").thenIncrementAmount(15);
    verifyReadModifyWriteRequest();
    appendValue.execute();
    appendValue.executeAsync();
    assertEquals(1, appendValue.getReadModifyWriteRequest().getRulesCount());
    assertEquals(ReadModifyWriteRule.getDefaultInstance(), appendValue.getReadModifyWriteRule().build());
    final ReadModifyWriteRule rule = appendValue.getReadModifyWriteRequest().getRules(0);
    assertEquals("family", rule.getFamilyName());
    assertEquals("qualifier", rule.getColumnQualifier().toStringUtf8());
    assertEquals(ByteString.EMPTY, rule.getAppendValue());
    assertEquals(15L, rule.getIncrementAmount());
    verify(bigtableMock.getMockedDataClient()).readModifyWriteRow(appendValue.getReadModifyWriteRequest().build());
    verify(bigtableMock.getMockedDataClient()).readModifyWriteRowAsync(appendValue.getReadModifyWriteRequest().build());
    verifyNoMoreInteractions(bigtableMock.getMockedDataClient());
}
Also used : ReadModifyWriteRule(com.google.bigtable.v2.ReadModifyWriteRule) Test(org.junit.Test)

Example 3 with ReadModifyWriteRule

use of com.google.bigtable.v2.ReadModifyWriteRule in project simple-bigtable by spotify.

the class BigtableReadModifyWriteImplTest method testReadThenAppendValue.

@Test
public void testReadThenAppendValue() throws Exception {
    final BigtableReadModifyWriteImpl appendValue = (BigtableReadModifyWriteImpl) bigtableReadModifyWrite.read("family:qualifier").thenAppendValue(ByteString.copyFromUtf8("value"));
    verifyReadModifyWriteRequest();
    appendValue.execute();
    appendValue.executeAsync();
    assertEquals(1, appendValue.getReadModifyWriteRequest().getRulesCount());
    assertEquals(ReadModifyWriteRule.getDefaultInstance(), appendValue.getReadModifyWriteRule().build());
    final ReadModifyWriteRule rule = appendValue.getReadModifyWriteRequest().getRules(0);
    assertEquals("family", rule.getFamilyName());
    assertEquals("qualifier", rule.getColumnQualifier().toStringUtf8());
    assertEquals("value", rule.getAppendValue().toStringUtf8());
    assertEquals(0L, rule.getIncrementAmount());
    verify(bigtableMock.getMockedDataClient()).readModifyWriteRow(appendValue.getReadModifyWriteRequest().build());
    verify(bigtableMock.getMockedDataClient()).readModifyWriteRowAsync(appendValue.getReadModifyWriteRequest().build());
    verifyNoMoreInteractions(bigtableMock.getMockedDataClient());
}
Also used : ReadModifyWriteRule(com.google.bigtable.v2.ReadModifyWriteRule) Test(org.junit.Test)

Aggregations

ReadModifyWriteRule (com.google.bigtable.v2.ReadModifyWriteRule)3 Test (org.junit.Test)3