diff --git a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdaterTest.java b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdaterTest.java index 661e884be5e52..e5d663be7623d 100644 --- a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdaterTest.java +++ b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdaterTest.java @@ -39,6 +39,16 @@ class CreateBroadcastTableRuleStatementUpdaterTest { private final CreateBroadcastTableRuleStatementUpdater updater = new CreateBroadcastTableRuleStatementUpdater(); + @Test + void assertCreatedRuleConfigurationWithNoStorageUnits() { + BroadcastRuleConfiguration currentConfig = mock(BroadcastRuleConfiguration.class); + when(currentConfig.getTables()).thenReturn(Collections.singleton("t_address")); + CreateBroadcastTableRuleStatement statement = new CreateBroadcastTableRuleStatement(false, Collections.singleton("t_address")); + ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS); + when(database.getResourceMetaData().getStorageUnits()).thenReturn(Collections.emptyMap()); + assertThrows(EmptyStorageUnitException.class, () -> updater.checkSQLStatement(database, statement, currentConfig)); + } + @Test void assertCheckSQLStatementWithDuplicateBroadcastRule() { BroadcastRuleConfiguration currentConfig = mock(BroadcastRuleConfiguration.class); @@ -64,14 +74,4 @@ private ShardingSphereDatabase mockShardingSphereDatabase() { when(database.getResourceMetaData().getStorageUnits()).thenReturn(Collections.singletonMap("ds_0", mock(StorageUnit.class))); return database; } - - @Test - void assertCreatedRuleConfigurationWithNoStorageUnits() { - BroadcastRuleConfiguration currentConfig = mock(BroadcastRuleConfiguration.class); - when(currentConfig.getTables()).thenReturn(Collections.singleton("t_address")); - CreateBroadcastTableRuleStatement statement = new CreateBroadcastTableRuleStatement(false, Collections.singleton("t_address")); - ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS); - when(database.getResourceMetaData().getStorageUnits()).thenReturn(Collections.emptyMap()); - assertThrows(EmptyStorageUnitException.class, () -> updater.checkSQLStatement(database, statement, currentConfig)); - } }