InstanceStateChangedListener extends PostGovernanceRepositoryEventListener { @Override protected Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) { return Optional.of(new CircuitStateChangedEvent(RegistryCenterNodeStatus.DISABLED.toString().equalsIgnoreCase(event.getValue()))); } InstanceStateChangedListener(final RegistryRepository registryRepository);   }
@Test public void assertCreateGovernanceEventWhenEnabled() { Optional<GovernanceEvent> actual = instanceStateChangedListener.createGovernanceEvent(new DataChangedEvent("/test_ds", "", ChangedType.UPDATED)); assertTrue(actual.isPresent()); assertFalse(((CircuitStateChangedEvent) actual.get()).isCircuitBreak()); }
@Test public void assertCreateGovernanceEventWhenDisabled() { Optional<GovernanceEvent> actual = instanceStateChangedListener.createGovernanceEvent(new DataChangedEvent("/test_ds", RegistryCenterNodeStatus.DISABLED.name(), ChangedType.UPDATED)); assertTrue(actual.isPresent()); assertTrue(((CircuitStateChangedEvent) actual.get()).isCircuitBreak()); }