Search in sources :

Example 11 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringChangeStartTest.

@Test
public void byteStringChangeStartTest() {
    ByteStringRange range = ByteStringRange.create(ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("z")).startOpen(ByteString.copyFromUtf8("b"));
    assertThat(range.getEndBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("z"));
    assertThat(range.getStartBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("b"));
    range = range.startClosed(ByteString.copyFromUtf8("c"));
    assertThat(range.getStartBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("c"));
    assertThat(range.startOpen(ByteString.EMPTY).getStartBound()).isEqualTo(BoundType.UNBOUNDED);
    assertThat(range.startClosed(ByteString.EMPTY).getStartBound()).isEqualTo(BoundType.UNBOUNDED);
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 12 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringChangeEndStringTest.

@Test
public void byteStringChangeEndStringTest() {
    ByteStringRange range = ByteStringRange.create("a", "z").endClosed("y");
    assertThat(range.getStartBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("a"));
    assertThat(range.getEndBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("y"));
    range = range.endOpen("x");
    assertThat(range.getEndBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("x"));
    assertThat(range.endOpen("").getEndBound()).isEqualTo(BoundType.UNBOUNDED);
    assertThat(range.endClosed("").getEndBound()).isEqualTo(BoundType.UNBOUNDED);
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 13 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringUnboundedTest.

@Test
public void byteStringUnboundedTest() {
    ByteStringRange range = ByteStringRange.unbounded();
    assertThat(range.getStartBound()).isEqualTo(BoundType.UNBOUNDED);
    assertThat(range.getEndBound()).isEqualTo(BoundType.UNBOUNDED);
    Throwable actualError = null;
    try {
        range.getStart();
    } catch (Throwable e) {
        actualError = e;
    }
    assertThat(actualError).isInstanceOf(IllegalStateException.class);
    try {
        range.getEnd();
    } catch (Throwable e) {
        actualError = e;
    }
    assertThat(actualError).isInstanceOf(IllegalStateException.class);
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 14 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringOfTest.

@Test
public void byteStringOfTest() {
    ByteStringRange range = ByteStringRange.create(ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("b"));
    assertThat(range.getStartBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("a"));
    assertThat(range.getEndBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("b"));
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 15 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringChangeStartStringTest.

@Test
public void byteStringChangeStartStringTest() {
    ByteStringRange range = ByteStringRange.create("a", "z").startOpen("b");
    assertThat(range.getEndBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("z"));
    assertThat(range.getStartBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("b"));
    range = range.startClosed("c");
    assertThat(range.getStartBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("c"));
    assertThat(range.startOpen("").getStartBound()).isEqualTo(BoundType.UNBOUNDED);
    assertThat(range.startClosed("").getStartBound()).isEqualTo(BoundType.UNBOUNDED);
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Aggregations

ByteStringRange (com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange)22 Test (org.junit.Test)20 RowSet (com.google.bigtable.v2.RowSet)10 RowRange (com.google.bigtable.v2.RowRange)1 RowKeyWrapper (com.google.cloud.bigtable.hbase.util.RowKeyWrapper)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ByteString (com.google.protobuf.ByteString)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1