use of com.google.bigtable.admin.v2.GcRule in project java-bigtable by googleapis.
the class GCRulesTest method durationNanos.
@Test
public void durationNanos() {
GcRule actual = GCRULES.maxAge(Duration.ofNanos(11)).toProto();
GcRule expected = buildAgeRule(0, 11);
assertThat(actual).isEqualTo(expected);
}
use of com.google.bigtable.admin.v2.GcRule in project java-bigtable by googleapis.
the class GCRulesTest method durationTimeUnitMinutes.
@Test
public void durationTimeUnitMinutes() {
GcRule actual = GCRULES.maxAge(1, TimeUnit.MINUTES).toProto();
GcRule expected = buildAgeRule(60, 0);
assertThat(actual).isEqualTo(expected);
}
use of com.google.bigtable.admin.v2.GcRule in project java-bigtable-hbase by googleapis.
the class TestTableAdapter2x method testAdaptWithTable.
@Test
public void testAdaptWithTable() {
// If no GcRule passed to ColumnFamily, then ColumnDescriptorAdapter#buildGarbageCollectionRule
// updates maxVersion to Integer.MAX_VALUE
int maxVersion = 1;
GCRules.GCRule gcRule = GCRULES.maxVersions(maxVersion);
ColumnFamily columnFamily = ColumnFamily.newBuilder().setGcRule(gcRule.toProto()).build();
Table table = Table.newBuilder().setName(TABLE_NAME).putColumnFamilies(COLUMN_FAMILY, columnFamily).build();
TableDescriptor actualTableDesc = TableAdapter2x.adapt(com.google.cloud.bigtable.admin.v2.models.Table.fromProto(table));
TableDescriptor expected = new HTableDescriptor(TableName.valueOf(TABLE_ID)).addFamily(new HColumnDescriptor(COLUMN_FAMILY));
Assert.assertEquals(expected, actualTableDesc);
}
use of com.google.bigtable.admin.v2.GcRule in project java-bigtable-hbase by googleapis.
the class TestColumnDescriptorAdapter method testGCruleMaxVersion.
@Test
public void testGCruleMaxVersion() {
int ttl = 100;
descriptor.setTimeToLive(ttl);
descriptor.setMaxVersions(Integer.MAX_VALUE);
ColumnFamily result = adapter.adapt(descriptor);
GCRule expected = GCRULES.maxAge(Duration.ofSeconds(ttl));
Assert.assertEquals(expected.toProto(), result.getGcRule());
}
use of com.google.bigtable.admin.v2.GcRule in project java-bigtable-hbase by googleapis.
the class TestTableAdapter method testAdaptForTable.
@Test
public void testAdaptForTable() {
// If no GcRule passed to ColumnFamily, then ColumnDescriptorAdapter#buildGarbageCollectionRule
// updates maxVersion to Integer.MAX_VALUE
GCRule gcRule = GCRULES.maxVersions(1);
ColumnFamily columnFamily = ColumnFamily.newBuilder().setGcRule(gcRule.toProto()).build();
Table table = Table.newBuilder().setName(TABLE_NAME).putColumnFamilies(COLUMN_FAMILY, columnFamily).build();
HTableDescriptor actualTableDesc = TableAdapter.adapt(com.google.cloud.bigtable.admin.v2.models.Table.fromProto(table));
HTableDescriptor expected = new HTableDescriptor(TableName.valueOf(TABLE_ID));
expected.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
Assert.assertEquals(expected, actualTableDesc);
}
Aggregations