### Question:
ChangeExecutedEventListener extends EventDistributor<ChangeExecutedEvent, Change> { @Override protected void onEvent(ChangeExecutedEvent event) { if (!hasListenersForTenant(event.getTenantId())) { return; } try { for (Change change : getListenersForTenant(event.getTenantId())) { if (change.equals(event.getChange())) { change.onExecution(event.getMigration()); } } } catch (FireflyExtensionRepository.FireflyExtensionNotFoundException e) { throw new RuntimeException(e); } } @Autowired  ChangeExecutedEventListener(ClusterService clusterService,
                                       TenantService tenantService,
                                       ApplicationContext applicationContext);   }### Answer:
@Test public void shouldCallAllListenersForTenant() throws Exception { listener.registerListener(TENANT_ID, change); listener.onEvent(changeExecutedEvent); verify(change).onExecution(MIGRATION); }
@Test public void shouldNotCallListenersForOtherChanges() throws Exception { listener.registerListener(TENANT_ID, change); Change otherChange = mock(Change.class); given(changeExecutedEvent.getChange()).willReturn(otherChange); listener.onEvent(changeExecutedEvent); verify(change, never()).onExecution(MIGRATION); }
@Test public void shouldNotCallListenersForOtherTenants() throws Exception { listener.registerListener("otherTenantId", change); listener.onEvent(changeExecutedEvent); verify(change, never()).onExecution(MIGRATION); }