Search in sources :

Example 26 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method createTableExceptionTest.

@Test
public void createTableExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableTableAdmin.addException(exception);
    try {
        InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
        String tableId = "tableId-1552905847";
        Table table = Table.newBuilder().build();
        client.createTable(parent, tableId, table);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) Table(com.google.bigtable.admin.v2.Table) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 27 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method createTableExceptionTest2.

@Test
public void createTableExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableTableAdmin.addException(exception);
    try {
        String parent = "parent-995424086";
        String tableId = "tableId-1552905847";
        Table table = Table.newBuilder().build();
        client.createTable(parent, tableId, table);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : Table(com.google.bigtable.admin.v2.Table) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 28 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method modifyColumnFamiliesTest.

@Test
public void modifyColumnFamiliesTest() throws Exception {
    Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
    List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
    Table actualResponse = client.modifyColumnFamilies(name, modifications);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ModifyColumnFamiliesRequest actualRequest = ((ModifyColumnFamiliesRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(modifications, actualRequest.getModificationsList());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : TableName(com.google.bigtable.admin.v2.TableName) Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) ModifyColumnFamiliesRequest(com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest) Test(org.junit.Test)

Example 29 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method listTablesTest2.

@Test
public void listTablesTest2() throws Exception {
    Table responsesElement = Table.newBuilder().build();
    ListTablesResponse expectedResponse = ListTablesResponse.newBuilder().setNextPageToken("").addAllTables(Arrays.asList(responsesElement)).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListTablesPagedResponse pagedListResponse = client.listTables(parent);
    List<Table> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTablesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTablesRequest actualRequest = ((ListTablesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) ListTablesRequest(com.google.bigtable.admin.v2.ListTablesRequest) ListTablesResponse(com.google.bigtable.admin.v2.ListTablesResponse) ByteString(com.google.protobuf.ByteString) ListTablesPagedResponse(com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse) Test(org.junit.Test)

Example 30 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method createTableFromSnapshotTest.

@Test
public void createTableFromSnapshotTest() throws Exception {
    Table expectedResponse = Table.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).putAllClusterStates(new HashMap<String, Table.ClusterState>()).putAllColumnFamilies(new HashMap<String, ColumnFamily>()).setRestoreInfo(RestoreInfo.newBuilder().build()).build();
    Operation resultOperation = Operation.newBuilder().setName("createTableFromSnapshotTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockBigtableTableAdmin.addResponse(resultOperation);
    InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    String tableId = "tableId-1552905847";
    SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
    Table actualResponse = client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateTableFromSnapshotRequest actualRequest = ((CreateTableFromSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(tableId, actualRequest.getTableId());
    Assert.assertEquals(sourceSnapshot.toString(), actualRequest.getSourceSnapshot());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) Table(com.google.bigtable.admin.v2.Table) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) CreateTableFromSnapshotRequest(com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) SnapshotName(com.google.bigtable.admin.v2.SnapshotName) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)40 Table (com.google.privacy.dlp.v2.Table)23 Table (org.molgenis.emx2.Table)23 Table (com.google.bigtable.admin.v2.Table)21 ByteString (com.google.protobuf.ByteString)18 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column)17 ArrayList (java.util.ArrayList)14 AbstractMessage (com.google.protobuf.AbstractMessage)13 HashMap (java.util.HashMap)13 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)11 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)10 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)10 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint)10 Row (org.molgenis.emx2.Row)10 IOException (java.io.IOException)9 List (java.util.List)9 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum)7 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer)6 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table)6