### Question:
StigmaDecisionMaker { @Nonnull public StigmaRefreshDecision onLoginFail(@Nullable final StigmaDetails stigmaDetails) { final StigmaRefreshDecision decision; if (isStigmaValid(stigmaDetails)) { stigmaService.revokeStigma(stigmaDetails.getStigma()); decision = StigmaRefreshDecision.refresh(newStigmaToken(), TOKEN_GOOD_LOGIN_FAIL); } else { decision = StigmaRefreshDecision.refresh(newStigmaToken(), TOKEN_BAD_LOGIN_FAIL); } if (logger.isDebugEnabled()) { logger.debug("Decision after failed login: " + decision); } writeToMetrics(decision); return decision; } StigmaDecisionMaker(final StigmaService stigmaService,
                               final StigmaTokenFactory stigmaTokenFactory,
                               final StigmaValidator stigmaValidator); @Nonnull StigmaRefreshDecision onLoginSuccess(@Nullable final StigmaDetails stigmaDetails); @Nonnull StigmaRefreshDecision onLoginFail(@Nullable final StigmaDetails stigmaDetails);  }### Answer:
@Test void should_make_decision_on_login_failure_and_valid_token() { given(stigmaValidator.isValid(STIGMA_DETAILS)).willReturn(true); final StigmaRefreshDecision result = decisionMaker.onLoginFail(STIGMA_DETAILS); assertThat(result).isEqualTo(StigmaRefreshDecision.refresh(REFRESHED_STIGMA_TOKEN, TOKEN_GOOD_LOGIN_FAIL)); }
@Test void should_make_decision_on_login_failure_and_invalid_token() { final StigmaRefreshDecision result = decisionMaker.onLoginFail(null); assertThat(result).isEqualTo(StigmaRefreshDecision.refresh(REFRESHED_STIGMA_TOKEN, TOKEN_BAD_LOGIN_FAIL)); }
@Test void should_make_decision_on_login_failure_and_not_active_stigma() { given(stigmaValidator.isValid(STIGMA_DETAILS)).willReturn(false); final StigmaRefreshDecision result = decisionMaker.onLoginFail(STIGMA_DETAILS); assertThat(result).isEqualTo(StigmaRefreshDecision.refresh(REFRESHED_STIGMA_TOKEN, TOKEN_BAD_LOGIN_FAIL)); }