Search in sources :

Example 1 with NoMatchFromMatchingService

use of uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService in project verify-hub by alphagov.

the class Cycle0And1MatchRequestSentStateControllerTest method cycle0And1NoMatchResponseFromMatchingServiceWhenC3NotEnabled_shouldNotLogWaitingForCycle3AttributesEventToEventSink.

@Test
public void cycle0And1NoMatchResponseFromMatchingServiceWhenC3NotEnabled_shouldNotLogWaitingForCycle3AttributesEventToEventSink() {
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(emptyList());
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(MATCHING_SERVICE_ENTITY_ID, REQUEST_ID);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(hubEventLogger, times(0)).logWaitingForCycle3AttributesEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Test(org.junit.Test)

Example 2 with NoMatchFromMatchingService

use of uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink.

@Test
public void cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
    final EventSinkHubEvent eventSinkHubEvent = argumentCaptor.getValue();
    assertThat(eventSinkHubEvent.getEventType()).isEqualTo(EventSinkHubEventConstants.EventTypes.SESSION_EVENT);
    assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
    assertThat(eventSinkHubEvent.getSessionId()).isEqualTo(sessionId.getSessionId());
    assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.request_id)).isEqualTo(requestId);
    assertThat(eventSinkHubEvent.getOriginatingService()).isEqualTo(serviceInfo.getName());
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 3 with NoMatchFromMatchingService

use of uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink.

@Test
public void cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, mock(StateTransitionAction.class), policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isNotEqualTo(CYCLE3_MATCH);
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) StateTransitionAction(uk.gov.ida.hub.policy.domain.StateTransitionAction) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 4 with NoMatchFromMatchingService

use of uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method statusShouldSendNoMatchResponseToTransactionWhenNoMatchResponseReceivedFromMatchingServiceCycle3Match.

@Test
public void statusShouldSendNoMatchResponseToTransactionWhenNoMatchResponseReceivedFromMatchingServiceCycle3Match() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<NoMatchState> argumentCaptor = ArgumentCaptor.forClass(NoMatchState.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
    NoMatchStateController noMatchStateController = new NoMatchStateController(argumentCaptor.getValue(), responseFromHubFactory);
    ResponseProcessingDetails responseProcessingDetails = noMatchStateController.getResponseProcessingDetails();
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SEND_NO_MATCH_RESPONSE_TO_TRANSACTION);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) Test(org.junit.jupiter.api.Test)

Example 5 with NoMatchFromMatchingService

use of uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method shouldNotLogCycle3MatchEventToEventSinkForCycle3NoMatchResponseFromMatchingService.

@Test
public void shouldNotLogCycle3MatchEventToEventSinkForCycle3NoMatchResponseFromMatchingService() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, mock(StateTransitionAction.class), policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isNotEqualTo(CYCLE3_MATCH);
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) StateTransitionAction(uk.gov.ida.hub.policy.domain.StateTransitionAction) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.jupiter.api.Test)

Aggregations

NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)15 MatchingProcess (uk.gov.ida.hub.policy.domain.MatchingProcess)8 Test (org.junit.Test)7 Test (org.junit.jupiter.api.Test)7 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)6 SessionId (uk.gov.ida.hub.policy.domain.SessionId)6 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)6 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)4 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)4 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Matchers.anyString (org.mockito.Matchers.anyString)3 StateTransitionAction (uk.gov.ida.hub.policy.domain.StateTransitionAction)2 WaitingForMatchingServiceResponseStateController (uk.gov.ida.hub.policy.domain.controller.WaitingForMatchingServiceResponseStateController)1 WaitingForMatchingServiceResponseState (uk.gov.ida.hub.policy.domain.state.WaitingForMatchingServiceResponseState)1