You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/03/06 06:43:19 UTC
[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #15785: Add unit test for ClusterContextManagerCoordinator
menghaoranss commented on a change in pull request #15785:
URL: https://github.com/apache/shardingsphere/pull/15785#discussion_r820188225
##########
File path: shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
##########
@@ -289,4 +295,53 @@ public void assertRenewInstanceLabels() {
coordinator.renew(mockLabelsEvent);
assertThat(contextManager.getInstanceContext().getInstance().getLabels(), is(labels));
}
+
+ @Test
+ public void assertRenewSchemaVersionChangedEvent() {
+ when(metaDataPersistService.getDataSourceService().load("schema", "1")).thenReturn(getVersionChangedDataSourcePropertiesMap());
+ when(metaDataPersistService.getSchemaRuleService().load("schema", "1")).thenReturn(Collections.emptyList());
+ SchemaVersionChangedEvent schemaVersionChangedEvent = new SchemaVersionChangedEvent("schema", "1");
+ Map<String, DataSource> dataSourceMap = initContextManager();
+ coordinator.renew(schemaVersionChangedEvent);
+ assertThat(contextManager.getDataSourceMap("schema").get("ds_0"), is(dataSourceMap.get("ds_0")));
+ assertNotNull(contextManager.getDataSourceMap("schema").get("ds_1"));
+ assertEquals(DataSourcePropertiesCreator.create(getChangeMockedDataSource()), DataSourcePropertiesCreator.create(contextManager.getDataSourceMap("schema").get("ds_1")));
+ assertNotNull(contextManager.getDataSourceMap("schema").get("primary_ds"));
+ assertEquals(DataSourcePropertiesCreator.create(getDefaultMockedDataSource()), DataSourcePropertiesCreator.create(contextManager.getDataSourceMap("schema").get("primary_ds")));
Review comment:
use `assertThat` to instead of `assertEquals` is better, look forward to your next pr.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org