use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable-hbase by googleapis.
the class TestColumnDescriptorAdapter method ttlIsPreservedInColumnFamily.
@Test
public void ttlIsPreservedInColumnFamily() {
// TTL of 1 day (in microseconds):
GCRules.GCRule expected = GCRULES.union().rule(GCRULES.maxAge(Duration.ofSeconds(86400))).rule(GCRULES.maxVersions(1));
HColumnDescriptor descriptor = adapter.adapt(columnFamily(expected));
Assert.assertEquals(1, descriptor.getMaxVersions());
Assert.assertEquals(86400, descriptor.getTimeToLive());
}
use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable-hbase by googleapis.
the class TestColumnDescriptorAdapter method maxVersionsIsPreservedInGcExpression.
@Test
public void maxVersionsIsPreservedInGcExpression() {
descriptor.setMaxVersions(10);
ColumnFamily result = adapter.adapt(descriptor);
GCRules.GCRule expected = GCRULES.maxVersions(10);
Assert.assertEquals(expected.toProto(), result.getGcRule());
}
use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily 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);
}
use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily 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.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable by googleapis.
the class TableAdminExampleTest method ruleCheck.
// TODO: add test for tableAdmin.listAllTables()
// TODO: add test for tableAdmin.getTableMeta()
// TODO: add test for tableAdmin.listColumnFamilies()
private boolean ruleCheck(GCRule condition) {
boolean found = false;
List<ColumnFamily> columnFamilies = adminClient.getTable(tableId).getColumnFamilies();
for (ColumnFamily columnFamily : columnFamilies) {
if (columnFamily.getGCRule().equals(condition)) {
found = true;
break;
}
}
return found;
}
Aggregations