Skip to content

Commit

Permalink
Add test cases on ShadowRuleConfigurationChecker (#33521)
Browse files Browse the repository at this point in the history
* Add ShadowDataSourceMappingsFinder

* Add ShadowDataSourceMappingsFinder

* Add ShadowDataSourceMappingsFinder

* Add ShadowDataSourceMappingsFinder

* Add test cases on ShadowRuleConfigurationChecker
  • Loading branch information
terrymanu authored Nov 3, 2024
1 parent 9e193e7 commit 14a2d75
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.shardingsphere.shadow.exception.metadata.MissingRequiredProductionDataSourceException;
import org.apache.shardingsphere.shadow.exception.metadata.MissingRequiredShadowDataSourceException;
import org.apache.shardingsphere.shadow.exception.metadata.NotImplementHintShadowAlgorithmException;
import org.apache.shardingsphere.shadow.exception.metadata.ShadowDataSourceMappingNotFoundException;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
Expand Down Expand Up @@ -88,6 +89,21 @@ private ShadowRuleConfiguration createRuleConfigurationWithInvalidDefaultShadowA
return result;
}

@Test
void assertCheckWithInvalidShadowTableDataSourcesReferences() {
assertThrows(ShadowDataSourceMappingNotFoundException.class,
() -> ruleConfigChecker.check("foo_db", createRuleConfigurationWithInvalidShadowTableDataSourcesReferences(), createDataSourceMap(), Collections.emptyList()));
}

private ShadowRuleConfiguration createRuleConfigurationWithInvalidShadowTableDataSourcesReferences() {
ShadowRuleConfiguration result = new ShadowRuleConfiguration();
result.setShadowAlgorithms(Collections.singletonMap("foo-algo", new AlgorithmConfiguration("SQL_HINT", new Properties())));
result.setDefaultShadowAlgorithmName("foo-algo");
result.setDataSources(Collections.singleton(new ShadowDataSourceConfiguration("foo_ds", "prod_ds", "shadow_ds")));
result.setTables(Collections.singletonMap("foo_tbl", new ShadowTableConfiguration(Collections.singletonList("bar_ds"), new LinkedList<>(Collections.singleton("foo-algo")))));
return result;
}

@Test
void assertCheckWithInvalidShadowTableAlgorithmsReferences() {
assertThrows(MissingRequiredAlgorithmException.class,
Expand Down

0 comments on commit 14a2d75

Please sign in to comment.