Search in sources :

Example 6 with MatchingProcess

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

the class AbstractAwaitingCycle3DataStateController method getCycle3AttributeRequestData.

public Cycle3AttributeRequestData getCycle3AttributeRequestData() {
    final String entityId = state.getRequestIssuerEntityId();
    final MatchingProcess matchingProcessDto = transactionsConfigProxy.getMatchingProcess(entityId);
    final String attributeName = matchingProcessDto.getAttributeName().get();
    return new Cycle3AttributeRequestData(attributeName, entityId);
}
Also used : MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)

Example 7 with MatchingProcess

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

the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldReturnUserAccountCreationRequestSentStateWhenTransactionDoesNotSupportCycle3AndSupportsUserAccountCreation.

@Test
public void getNextState_shouldReturnUserAccountCreationRequestSentStateWhenTransactionDoesNotSupportCycle3AndSupportsUserAccountCreation() {
    // Given
    URI userAccountCreationUri = URI.create("a-test-user-account-creation-uri");
    List<UserAccountCreationAttribute> userAccountCreationAttributes = singletonList(UserAccountCreationAttribute.DATE_OF_BIRTH);
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(userAccountCreationAttributes);
    when(matchingServiceConfigProxy.getMatchingService(anyString())).thenReturn(aMatchingServiceConfigEntityDataDto().withUserAccountCreationUri(userAccountCreationUri).build());
    // When
    final State nextState = controller.getNextStateForNoMatch();
    // Then
    verify(hubEventLogger).logMatchingServiceUserAccountCreationRequestSentEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, state.getSessionExpiryTimestamp(), state.getRequestId());
    verify(attributeQueryService).sendAttributeQueryRequest(eq(nextState.getSessionId()), attributeQueryRequestCaptor.capture());
    AttributeQueryRequestDto actualAttributeQueryRequestDto = attributeQueryRequestCaptor.getValue();
    assertThat(actualAttributeQueryRequestDto.getAttributeQueryUri()).isEqualTo(userAccountCreationUri);
    assertThat(actualAttributeQueryRequestDto.getUserAccountCreationAttributes()).isEqualTo(Optional.fromNullable(userAccountCreationAttributes));
    assertThat(nextState).isInstanceOf(UserAccountCreationRequestSentState.class);
}
Also used : UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) SuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState) Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) State(uk.gov.ida.hub.policy.domain.State) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) AttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto) URI(java.net.URI) Test(org.junit.Test)

Example 8 with MatchingProcess

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

the class Cycle0And1MatchRequestSentStateControllerTest method cycle0And1NoMatchResponseFromMatchingService_shouldLogRelevantEvents.

@Test
public void cycle0And1NoMatchResponseFromMatchingService_shouldLogRelevantEvents() {
    // Given
    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);
    // When
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    // Then
    verify(hubEventLogger, times(1)).logCycle01NoMatchEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
    verify(hubEventLogger, times(0)).logCycle01SuccessfulMatchEvent(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 9 with MatchingProcess

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

the class Cycle0And1MatchRequestSentStateControllerTest method cycle0And1NoMatchResponseFromMatchingServiceWhenC3Enabled_shouldLogRelevantEvents.

@Test
public void cycle0And1NoMatchResponseFromMatchingServiceWhenC3Enabled_shouldLogRelevantEvents() {
    MatchingProcess matchingProcess = mock(MatchingProcess.class);
    when(matchingProcess.getAttributeName()).thenReturn(Optional.of("BLOCKBUSTER_CARD"));
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(matchingProcess);
    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)).logCycle01NoMatchEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
    verify(hubEventLogger, times(1)).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 10 with MatchingProcess

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

the class Cycle0And1MatchRequestSentStateControllerTest method responseProcessingDetails_shouldReturnNoMatchStatus_noMatchResponseSentFromMatchingService.

@Test
public void responseProcessingDetails_shouldReturnNoMatchStatus_noMatchResponseSentFromMatchingService() {
    ArgumentCaptor<NoMatchState> argumentCaptor = ArgumentCaptor.forClass(NoMatchState.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(MATCHING_SERVICE_ENTITY_ID, REQUEST_ID);
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(emptyList());
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
    NoMatchStateController noMatchStateController = new NoMatchStateController(argumentCaptor.getValue(), responseFromHubFactory);
    final ResponseProcessingDetails responseProcessingDetails = noMatchStateController.getResponseProcessingDetails();
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SEND_NO_MATCH_RESPONSE_TO_TRANSACTION);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(state.getSessionId());
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) Test(org.junit.Test)

Aggregations

MatchingProcess (uk.gov.ida.hub.policy.domain.MatchingProcess)11 Test (org.junit.Test)10 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)5 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)5 State (uk.gov.ida.hub.policy.domain.State)4 Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState)2 EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState)2 Cycle3AttributeRequestData (uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)2 UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)2 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)2 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)2 EidasAwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState)2 EidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState)2 EidasSuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.EidasSuccessfulMatchState)2 SuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState)2 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)2 URI (java.net.URI)1 MatchFromMatchingServiceBuilder.aMatchFromMatchingService (uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService)1 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 MatchFromMatchingService (uk.gov.ida.hub.policy.domain.MatchFromMatchingService)1