Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
flaming-archer committed Nov 5, 2023
1 parent 7611c7d commit 2710fab
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,37 @@ public void panopticOperationsHandlerGetPrimaryAllDatabases() throws Exception {
assertThat(handler.getPrimaryAllDatabases(), is(Lists.newArrayList("primary_db1")));
}

@Test
public void panopticOperationsHandlerStartOkCanFilterPrimaryDatabase() throws Exception {
String pattern = "*";
List<String> allPrimaryDatabases =
Lists.newArrayList("db1", "db2", "db3");
when(primaryDatabaseClient.get_databases(pattern)).thenReturn(allPrimaryDatabases);
when(primaryDatabaseClient.get_all_databases()).thenReturn(allPrimaryDatabases);

List<String> allFederatedDatabases =
Lists.newArrayList("db2", "db3", "db4");
when(federatedDatabaseClient.get_databases(pattern)).thenReturn(allFederatedDatabases);
when(federatedDatabaseClient.get_all_databases()).thenReturn(allFederatedDatabases);

try {
primaryMetastore.setMappedDatabases(allPrimaryDatabases);
federatedMetastore.setMappedDatabases(allFederatedDatabases);
service = new StaticDatabaseMappingService(metaStoreMappingFactory,
Arrays.asList(primaryMetastore, federatedMetastore), queryMapping);
} catch (WaggleDanceException exception) {
primaryMetastore.setMappedDatabases(Lists.newArrayList("db1"));
federatedMetastore.setMappedDatabases(Lists.newArrayList("db2", "db3", "db4"));

service = new StaticDatabaseMappingService(metaStoreMappingFactory,
Arrays.asList(primaryMetastore, federatedMetastore), queryMapping);

return;
}

fail("Shouldn't be here");
}

@Test
public void panopticOperationsHandlerGetAllDatabasesWithEmptyMappedDatabases() {
federatedMetastore.setMappedDatabases(Collections.emptyList());
Expand Down

0 comments on commit 2710fab

Please sign in to comment.