use of org.molgenis.emx2.Database in project java-spanner by googleapis.
the class SpannerThreadsTest method mockGetDatabaseResponse.
private void mockGetDatabaseResponse() {
DatabaseName name2 = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
Database expectedResponse = Database.newBuilder().setName(name2.toString()).build();
mockDatabaseAdmin.addResponse(expectedResponse);
}
use of org.molgenis.emx2.Database in project java-spanner by googleapis.
the class DatabaseAdminClientTest method listDatabasesTest2.
@Test
public void listDatabasesTest2() throws Exception {
Database responsesElement = Database.newBuilder().build();
ListDatabasesResponse expectedResponse = ListDatabasesResponse.newBuilder().setNextPageToken("").addAllDatabases(Arrays.asList(responsesElement)).build();
mockDatabaseAdmin.addResponse(expectedResponse);
String parent = "parent-995424086";
ListDatabasesPagedResponse pagedListResponse = client.listDatabases(parent);
List<Database> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDatabasesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDatabasesRequest actualRequest = ((ListDatabasesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.molgenis.emx2.Database in project java-spanner by googleapis.
the class DatabaseAdminClientTest method restoreDatabaseTest2.
@Test
public void restoreDatabaseTest2() throws Exception {
Database expectedResponse = Database.newBuilder().setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()).setCreateTime(Timestamp.newBuilder().build()).setRestoreInfo(RestoreInfo.newBuilder().build()).setEncryptionConfig(EncryptionConfig.newBuilder().build()).addAllEncryptionInfo(new ArrayList<EncryptionInfo>()).setVersionRetentionPeriod("versionRetentionPeriod-629783929").setEarliestVersionTime(Timestamp.newBuilder().build()).setDefaultLeader("defaultLeader759009962").setDatabaseDialect(DatabaseDialect.forNumber(0)).build();
Operation resultOperation = Operation.newBuilder().setName("restoreDatabaseTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockDatabaseAdmin.addResponse(resultOperation);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String databaseId = "databaseId1688905718";
String backup = "backup-1396673086";
Database actualResponse = client.restoreDatabaseAsync(parent, databaseId, backup).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
RestoreDatabaseRequest actualRequest = ((RestoreDatabaseRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(databaseId, actualRequest.getDatabaseId());
Assert.assertEquals(backup, actualRequest.getBackup());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.molgenis.emx2.Database in project java-spanner by googleapis.
the class DatabaseAdminClientTest method restoreDatabaseTest3.
@Test
public void restoreDatabaseTest3() throws Exception {
Database expectedResponse = Database.newBuilder().setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()).setCreateTime(Timestamp.newBuilder().build()).setRestoreInfo(RestoreInfo.newBuilder().build()).setEncryptionConfig(EncryptionConfig.newBuilder().build()).addAllEncryptionInfo(new ArrayList<EncryptionInfo>()).setVersionRetentionPeriod("versionRetentionPeriod-629783929").setEarliestVersionTime(Timestamp.newBuilder().build()).setDefaultLeader("defaultLeader759009962").setDatabaseDialect(DatabaseDialect.forNumber(0)).build();
Operation resultOperation = Operation.newBuilder().setName("restoreDatabaseTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockDatabaseAdmin.addResponse(resultOperation);
String parent = "parent-995424086";
String databaseId = "databaseId1688905718";
BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Database actualResponse = client.restoreDatabaseAsync(parent, databaseId, backup).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
RestoreDatabaseRequest actualRequest = ((RestoreDatabaseRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertEquals(databaseId, actualRequest.getDatabaseId());
Assert.assertEquals(backup.toString(), actualRequest.getBackup());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.molgenis.emx2.Database in project java-spanner by googleapis.
the class DatabaseAdminClientTest method createDatabaseTest.
@Test
public void createDatabaseTest() throws Exception {
Database expectedResponse = Database.newBuilder().setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString()).setCreateTime(Timestamp.newBuilder().build()).setRestoreInfo(RestoreInfo.newBuilder().build()).setEncryptionConfig(EncryptionConfig.newBuilder().build()).addAllEncryptionInfo(new ArrayList<EncryptionInfo>()).setVersionRetentionPeriod("versionRetentionPeriod-629783929").setEarliestVersionTime(Timestamp.newBuilder().build()).setDefaultLeader("defaultLeader759009962").setDatabaseDialect(DatabaseDialect.forNumber(0)).build();
Operation resultOperation = Operation.newBuilder().setName("createDatabaseTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockDatabaseAdmin.addResponse(resultOperation);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String createStatement = "createStatement744686547";
Database actualResponse = client.createDatabaseAsync(parent, createStatement).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDatabaseRequest actualRequest = ((CreateDatabaseRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(createStatement, actualRequest.getCreateStatement());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations