GovernanceSchemaContexts implements SchemaContexts { @Subscribe public synchronized void renew(final SchemaAddedEvent event) throws SQLException { Map<String, ShardingSphereSchema> schemas = new HashMap<>(schemaContexts.getSchemas()); schemas.put(event.getSchemaName(), createAddedSchemaContext(event)); schemaContexts = new StandardSchemaContexts(schemas, schemaContexts.getSqlParserEngine(), schemaContexts.getExecutorKernel(), schemaContexts.getAuthentication(), schemaContexts.getProps(), schemaContexts.getDatabaseType()); governanceFacade.getConfigCenter().persistMetaData(event.getSchemaName(), schemaContexts.getSchemas().get(event.getSchemaName()).getMetaData().getRuleSchemaMetaData()); GovernanceEventBus.getInstance().post( new DataSourceChangeCompletedEvent(event.getSchemaName(), schemaContexts.getDatabaseType(), schemas.get(event.getSchemaName()).getDataSources())); } GovernanceSchemaContexts(final SchemaContexts schemaContexts, final GovernanceFacade governanceFacade); @Override DatabaseType getDatabaseType(); @Override Map<String, ShardingSphereSchema> getSchemas(); @Override ShardingSphereSchema getDefaultSchema(); @Override ShardingSphereSQLParserEngine getSqlParserEngine(); @Override ExecutorKernel getExecutorKernel(); @Override Authentication getAuthentication(); @Override ConfigurationProperties getProps(); @Override boolean isCircuitBreak(); @Override void close(); @Subscribe synchronized void renew(final SchemaAddedEvent event); @Subscribe synchronized void renew(final SchemaDeletedEvent event); @Subscribe synchronized void renew(final PropertiesChangedEvent event); @Subscribe synchronized void renew(final AuthenticationChangedEvent event); @Subscribe synchronized void renew(final MetaDataChangedEvent event); @Subscribe synchronized void renew(final RuleConfigurationsChangedEvent event); @Subscribe synchronized void renew(final DataSourceChangedEvent event); @Subscribe synchronized void renew(final DisabledStateChangedEvent event); @Subscribe synchronized void renew(final CircuitStateChangedEvent event);  }
@Test public void assertDisableStateChanged() { DisabledStateChangedEvent event = new DisabledStateChangedEvent(new GovernanceSchema("schema.ds_0"), true); governanceSchemaContexts.renew(event); verify(primaryReplicaReplicationRule, times(2)).updateRuleStatus(any(RuleChangedEvent.class)); }