DataSourceStateChangedListener extends PostGovernanceRepositoryEventListener { @Override protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) { return registryCenterNode.getGovernanceSchema(event.getKey()).map(schema -> new DisabledStateChangedEvent(schema, isDataSourceDisabled(event))); } DataSourceStateChangedListener(final RegistryRepository registryRepository, final Collection<String> schemaNames);   }
@Test public void assertCreateGovernanceEvent() { Optional<GovernanceEvent> actual = dataSourceStateChangedListener.createGovernanceEvent( new DataChangedEvent("/states/datanodes/primary_replica_db/replica_ds_0", "disabled", ChangedType.UPDATED)); assertTrue(actual.isPresent()); assertThat(((DisabledStateChangedEvent) actual.get()).getGovernanceSchema().getSchemaName(), is(new GovernanceSchema("primary_replica_db", "replica_ds_0").getSchemaName())); }