Skip to content

Commit

Permalink
Refactor AlgorithmChangedProcessorTest (#33487)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Oct 31, 2024
1 parent c18b9c8 commit e86ca4d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,22 @@ private ShardingSphereDatabase mockDatabase(final AlgorithmChangedProcessorFixtu

@Test
void assertChangeRuleItemConfiguration() {
AlterNamedRuleItemEvent event = new AlterNamedRuleItemEvent("", "bar_algo", "", "", "");
AlgorithmChangedProcessorFixtureRuleConfiguration currentRuleConfig = new AlgorithmChangedProcessorFixtureRuleConfiguration();
currentRuleConfig.getAlgorithmConfigurations().put("foo_algo", new AlgorithmConfiguration("FOO_FIXTURE", new Properties()));
AlgorithmConfiguration toBeChangedItemConfig = new AlgorithmConfiguration("BAR_FIXTURE", new Properties());
processor.changeRuleItemConfiguration(new AlterNamedRuleItemEvent("", "bar_algo", "", "", ""), currentRuleConfig, toBeChangedItemConfig);
processor.changeRuleItemConfiguration(event, currentRuleConfig, toBeChangedItemConfig);
assertThat(currentRuleConfig.getAlgorithmConfigurations().size(), is(2));
assertThat(currentRuleConfig.getAlgorithmConfigurations().get("foo_algo").getType(), is("FOO_FIXTURE"));
assertThat(currentRuleConfig.getAlgorithmConfigurations().get("bar_algo").getType(), is("BAR_FIXTURE"));
}

@Test
void assertDropRuleItemConfiguration() {
DropNamedRuleItemEvent event = new DropNamedRuleItemEvent("", "foo_algo", "");
AlgorithmChangedProcessorFixtureRuleConfiguration currentRuleConfig = new AlgorithmChangedProcessorFixtureRuleConfiguration();
currentRuleConfig.getAlgorithmConfigurations().put("foo_algo", new AlgorithmConfiguration("FOO_FIXTURE", new Properties()));
processor.dropRuleItemConfiguration(new DropNamedRuleItemEvent("", "foo_algo", ""), currentRuleConfig);
processor.dropRuleItemConfiguration(event, currentRuleConfig);
assertTrue(currentRuleConfig.getAlgorithmConfigurations().isEmpty());
}
}

0 comments on commit e86ca4d

Please sign in to comment.