15
15
import com .google .cloud .bigtable .data .v2 .models .Row ;
16
16
import com .google .cloud .bigtable .data .v2 .models .RowCell ;
17
17
import com .google .cloud .bigtable .data .v2 .models .RowMutation ;
18
+ import com .google .cloud .bigtable .data .v2 .models .TableId ;
18
19
import io .grpc .ManagedChannel ;
19
20
import io .grpc .ManagedChannelBuilder ;
20
21
import org .junit .Rule ;
23
24
24
25
import java .io .IOException ;
25
26
import java .util .List ;
26
- import java .util .concurrent .ExecutionException ;
27
27
28
28
import static org .assertj .core .api .Assertions .assertThat ;
29
29
@@ -43,28 +43,26 @@ public class BigtableEmulatorContainerTest {
43
43
44
44
@ Test
45
45
// testWithEmulatorContainer {
46
- public void testSimple () throws IOException , InterruptedException , ExecutionException {
46
+ public void testSimple () throws IOException {
47
47
ManagedChannel channel = ManagedChannelBuilder .forTarget (emulator .getEmulatorEndpoint ()).usePlaintext ().build ();
48
48
49
49
TransportChannelProvider channelProvider = FixedTransportChannelProvider .create (
50
50
GrpcTransportChannel .create (channel )
51
51
);
52
52
NoCredentialsProvider credentialsProvider = NoCredentialsProvider .create ();
53
-
54
- try {
55
- createTable (channelProvider , credentialsProvider , "test-table" );
56
-
53
+ createTable (channelProvider , credentialsProvider , "test-table" );
54
+ try (
57
55
BigtableDataClient client = BigtableDataClient .create (
58
56
BigtableDataSettings
59
57
.newBuilderForEmulator (emulator .getHost (), emulator .getEmulatorPort ())
60
58
.setProjectId (PROJECT_ID )
61
59
.setInstanceId (INSTANCE_ID )
62
60
.build ()
63
- );
64
-
65
- client .mutateRow (RowMutation .create ("test-table" , "1" ).setCell ("name" , "firstName" , "Ray" ));
61
+ )
62
+ ) {
63
+ client .mutateRow (RowMutation .create (TableId . of ( "test-table" ) , "1" ).setCell ("name" , "firstName" , "Ray" ));
66
64
67
- Row row = client .readRow ("test-table" , "1" );
65
+ Row row = client .readRow (TableId . of ( "test-table" ) , "1" );
68
66
List <RowCell > cells = row .getCells ("name" , "firstName" );
69
67
70
68
assertThat (cells ).isNotNull ().hasSize (1 );
0 commit comments