1515 */
1616package com .google .cloud .examples .bigtable ;
1717
18+ import static org .junit .Assert .assertFalse ;
1819import static org .junit .Assert .assertTrue ;
1920
2021import com .google .bigtable .admin .v2 .InstanceName ;
3637import org .junit .BeforeClass ;
3738import org .junit .Test ;
3839
39- /** Integration tests for {@link TableAdmin } */
40- public class ITTableAdmin {
40+ /** Integration tests for {@link TableAdminExample } */
41+ public class ITTableAdminExample {
4142
4243 private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance" ;
4344 private static final String TABLE_PREFIX = "table" ;
44- private static String tableId ;
4545 private static BigtableTableAdminClient adminClient ;
46- private static InstanceName instanceName ;
47- private TableAdmin tableAdmin ;
46+ private static String instanceName ;
47+ private static String projectName ;
48+ private String tableId ;
49+ private TableAdminExample tableAdmin ;
4850
4951 @ BeforeClass
5052 public static void beforeClass () throws IOException {
@@ -53,9 +55,13 @@ public static void beforeClass() throws IOException {
5355 adminClient = null ;
5456 return ;
5557 }
56- instanceName = InstanceName .parse (targetInstance );
58+ instanceName = InstanceName .parse (targetInstance ).getInstance ();
59+ projectName = InstanceName .parse (targetInstance ).getProject ();
5760 BigtableTableAdminSettings adminSettings =
58- BigtableTableAdminSettings .newBuilder ().setInstanceName (instanceName ).build ();
61+ BigtableTableAdminSettings .newBuilder ()
62+ .setInstanceId (instanceName )
63+ .setProjectId (projectName )
64+ .build ();
5965 adminClient = BigtableTableAdminClient .create (adminSettings );
6066 }
6167
@@ -72,7 +78,7 @@ public void setup() throws IOException {
7278 INSTANCE_PROPERTY_NAME + " property is not set, skipping integration tests." );
7379 }
7480 tableId = generateTableId ();
75- tableAdmin = new TableAdmin ( instanceName . getProject () , instanceName . getInstance () , tableId );
81+ tableAdmin = new TableAdminExample ( projectName , instanceName , tableId );
7682 adminClient .createTable (CreateTableRequest .of (tableId ).addFamily ("cf" ));
7783 }
7884
@@ -86,15 +92,14 @@ public void after() {
8692 @ Test
8793 public void testCreateAndDeleteTable () throws IOException {
8894 // Creates a table.
89- String fakeTable = generateTableId ();
90- TableAdmin testTableAdmin =
91- new TableAdmin (instanceName .getProject (), instanceName .getInstance (), fakeTable );
95+ String testTable = generateTableId ();
96+ TableAdminExample testTableAdmin = new TableAdminExample (projectName , instanceName , testTable );
9297 testTableAdmin .createTable ();
93- assertTrue (adminClient .exists (fakeTable ));
98+ assertTrue (adminClient .exists (testTable ));
9499
95100 // Deletes a table.
96101 testTableAdmin .deleteTable ();
97- assertTrue (! adminClient .exists (fakeTable ));
102+ assertFalse ( adminClient .exists (testTable ));
98103 }
99104
100105 @ Test
@@ -178,7 +183,7 @@ public void testRunDoesNotFail() {
178183
179184 // TODO: add test for tableAdmin.listAllTables()
180185 // TODO: add test for tableAdmin.getTableMeta()
181- // TODO: add test for tableAdmin.listColumnFamilies
186+ // TODO: add test for tableAdmin.listColumnFamilies()
182187
183188 private boolean ruleCheck (Object condition ) {
184189 boolean found = false ;
0 commit comments