GovernanceShardingSphereDataSourceFactory { public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> ruleConfigurations, final Properties props, final GovernanceConfiguration governanceConfig) throws SQLException { if (null == ruleConfigurations || ruleConfigurations.isEmpty()) { return createDataSource(governanceConfig); } return new GovernanceShardingSphereDataSource(dataSourceMap, ruleConfigurations, props, governanceConfig); }  static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> ruleConfigurations,
                                              final Properties props, final GovernanceConfiguration governanceConfig); static DataSource createDataSource(final DataSource dataSource, final Collection<RuleConfiguration> ruleConfigurations,
                                              final Properties props, final GovernanceConfiguration governanceConfig); static DataSource createDataSource(final GovernanceConfiguration governanceConfig);  }
@Test public void assertCreateDataSourceWhenRuleConfigurationsNotEmpty() throws SQLException { DataSource dataSource = GovernanceShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(), Collections.singletonList(mock(RuleConfiguration.class)), new Properties(), createGovernanceConfiguration()); assertTrue(dataSource instanceof GovernanceShardingSphereDataSource); }
@Test public void assertCreateDataSourceWithGivenDataSource() throws SQLException { DataSource dataSource = GovernanceShardingSphereDataSourceFactory.createDataSource(createDataSource(), Collections.singletonList(mock(RuleConfiguration.class)), new Properties(), createGovernanceConfiguration()); assertTrue(dataSource instanceof GovernanceShardingSphereDataSource); }