### Question:
AuthnFailedErrorStateController extends AbstractAuthnFailedErrorStateController<AuthnFailedErrorState> implements IdpSelectingStateController { @Override public void handleIdpSelected(String idpEntityId, String principalIpAddress, boolean registering, LevelOfAssurance requestedLoa, String analyticsSessionId, String journeyType, String abTestVariant) { IdpSelectedState idpSelectedState = IdpSelector.buildIdpSelectedState(state, idpEntityId, registering, requestedLoa, transactionsConfigProxy, identityProvidersConfigProxy); stateTransitionAction.transitionTo(idpSelectedState); hubEventLogger.logIdpSelectedEvent(idpSelectedState, principalIpAddress, analyticsSessionId, journeyType, abTestVariant); } AuthnFailedErrorStateController(
            AuthnFailedErrorState state,
            ResponseFromHubFactory responseFromHubFactory,
            StateTransitionAction stateTransitionAction,
            TransactionsConfigProxy transactionsConfigProxy,
            IdentityProvidersConfigProxy identityProvidersConfigProxy,
            HubEventLogger hubEventLogger); FailureResponseDetails handleFailureResponse(); void tryAnotherIdpResponse(); @Override void handleIdpSelected(String idpEntityId, String principalIpAddress, boolean registering, LevelOfAssurance requestedLoa, String analyticsSessionId, String journeyType, String abTestVariant); @Override String getRequestIssuerId(); @Override AuthnRequestSignInProcess getSignInProcessDetails();  }### Answer:
@Test public void handleIdpSelect_shouldTransitionStateAndLogEvent() { controller.handleIdpSelected(IDP_ENTITY_ID, "some-ip-address", false, LevelOfAssurance.LEVEL_2, "some-analytics-session-id", "some-journey-type", abTestVariant); ArgumentCaptor<IdpSelectedState> capturedState = ArgumentCaptor.forClass(IdpSelectedState.class); verify(stateTransitionAction, times(1)).transitionTo(capturedState.capture()); assertThat(capturedState.getValue().getIdpEntityId()).isEqualTo(IDP_ENTITY_ID); assertThat(capturedState.getValue().getLevelsOfAssurance()).containsSequence(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2); verify(hubEventLogger, times(1)).logIdpSelectedEvent(capturedState.getValue(), "some-ip-address", "some-analytics-session-id", "some-journey-type", abTestVariant); }
@Test public void idpSelect_shouldThrowWhenIdentityProviderInvalid() { try { controller.handleIdpSelected("notExist", "some-ip-address", REGISTERING, LevelOfAssurance.LEVEL_2, "some-analytics-session-id", "some-journey-type", abTestVariant); fail("Should throw StateProcessingValidationException"); } catch(StateProcessingValidationException e) { assertThat(e.getMessage()).contains("Available Identity Provider for session ID [" + authnFailedErrorState .getSessionId().getSessionId() + "] not found for entity ID [notExist]."); verify(hubEventLogger, times(0)).logIdpSelectedEvent(any(IdpSelectedState.class), eq("some-ip-address"), eq("some-analytics-session-id"), eq("some-journey-type"), eq(abTestVariant)); } }