BigtableInstanceName implements Serializable { public String toTableId(String tableName) { Preconditions.checkNotNull(tableName, "Table name cannot be null"); String tablesPrefix = instanceName + TABLE_SEPARATOR; Preconditions.checkState( tableName.startsWith(tablesPrefix), "'%s' does not start with '%s'", tableName, tablesPrefix); String tableId = tableName.substring(tablesPrefix.length()).trim(); Preconditions.checkState(!tableId.isEmpty(), "Table id is blank"); return tableId; } @InternalApi("For internal usage only")  BigtableInstanceName(String projectId, String instanceId); @Override String toString(); String toTableId(String tableName); String toTableNameStr(String tableId); BigtableTableName toTableName(String tableId); String getProjectId(); String getInstanceId(); String getInstanceName(); BigtableClusterName toClusterName(String clusterId); static final String BIGTABLE_V2_INSTANCE_FMT; static final String TABLE_SEPARATOR; }
@Test public void testGoodTableQualifier() { bigtableInstanceName.toTableId(instanceName + BigtableInstanceName.TABLE_SEPARATOR + "foo"); }
@Test public void testNullQualifier() { expectedException.expect(NullPointerException.class); bigtableInstanceName.toTableId(null); }
@Test public void testBadQualifier() { expectedException.expect(IllegalStateException.class); bigtableInstanceName.toTableId( instanceName.replace("some-instance", "another-instance") + BigtableInstanceName.TABLE_SEPARATOR + "foo"); }
@Test public void testBlankTableName() { expectedException.expect(IllegalStateException.class); bigtableInstanceName.toTableId(instanceName + BigtableInstanceName.TABLE_SEPARATOR); }
@Test public void testNoTableName() { expectedException.expect(IllegalStateException.class); bigtableInstanceName.toTableId(instanceName + BigtableInstanceName.TABLE_SEPARATOR); }