### Question:
RulesRunner { public void onLogin(final LoginContext context) { for (LoginRule loginRule : loginRules) { loginRule.execute(context, eventPublisher::publishEvent); } } RulesRunner(final ApplicationEventPublisher eventPublisher, final List<LoginRule> rules); void onLogin(final LoginContext context);  }### Answer:
@Test void shouldExecuteRulesAndPublishResultingEvents() { List<LoginRule> rules = new ArrayList<>(); final UserAgentFailedLoginOverThresholdEvent userAgentEvent = new UserAgentFailedLoginOverThresholdEvent("user-agent"); rules.add(fixedEventRule(userAgentEvent)); final IpFailedLoginOverThresholdEvent ipEvent = new IpFailedLoginOverThresholdEvent("5.5.5.5"); rules.add(fixedEventRule(ipEvent)); rules.add(nopRule()); final RulesRunner rulesRunner = new RulesRunner(publisherStub, rules); rulesRunner.onLogin(new LoginContext()); assertThat(publisherStub.getEvents()).hasSize(2) .hasAtLeastOneElementOfType(UserAgentFailedLoginOverThresholdEvent.class) .hasAtLeastOneElementOfType(IpFailedLoginOverThresholdEvent.class); }