From 2710fab51852883a68b7f9ef9ebb038f57f39bc8 Mon Sep 17 00:00:00 2001 From: dtb <2011xuesong@gmail.com> Date: Sun, 5 Nov 2023 19:06:02 +0800 Subject: [PATCH] add test --- .../StaticDatabaseMappingServiceTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/service/impl/StaticDatabaseMappingServiceTest.java b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/service/impl/StaticDatabaseMappingServiceTest.java index 505934342..a9123c78a 100644 --- a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/service/impl/StaticDatabaseMappingServiceTest.java +++ b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/service/impl/StaticDatabaseMappingServiceTest.java @@ -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 allPrimaryDatabases = + Lists.newArrayList("db1", "db2", "db3"); + when(primaryDatabaseClient.get_databases(pattern)).thenReturn(allPrimaryDatabases); + when(primaryDatabaseClient.get_all_databases()).thenReturn(allPrimaryDatabases); + + List 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());