Search in sources :

Example 1 with StateProcessingValidationException

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

the class Cycle3MatchRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.

@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, null, null, null, null, null, transactionsConfigProxy, null, null, null);
    MatchFromMatchingService matchFromMatchingService = aMatchFromMatchingService().withIssuerId("issuer-id").build();
    try {
        controller.validateResponse(matchFromMatchingService);
        fail("fail");
    } catch (StateProcessingValidationException e) {
        assertThat(e.getMessage()).isEqualTo(format("Response to request ID [{0}] came from [issuer-id] and was expected to come from [{1}]", state.getRequestId(), matchingServiceEntityId));
    }
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchFromMatchingServiceBuilder.aMatchFromMatchingService(uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService) MatchFromMatchingService(uk.gov.ida.hub.policy.domain.MatchFromMatchingService) StateProcessingValidationException(uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException) Test(org.junit.Test)

Example 2 with StateProcessingValidationException

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

the class UserAccountCreationRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.

@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
    UserAccountCreationRequestSentState state = aUserAccountCreationRequestSentState().build();
    UserAccountCreationRequestSentStateController controller = new UserAccountCreationRequestSentStateController(state, null, null, null, null, null, null);
    ResponseFromMatchingService responseFromMatchingService = new UserAccountCreatedFromMatchingService("issuer-id", "", "", Optional.absent());
    try {
        controller.validateResponse(responseFromMatchingService);
        fail("fail");
    } catch (StateProcessingValidationException e) {
        assertThat(e.getMessage()).isEqualTo("Response to request ID [" + state.getRequestId() + "] came from [issuer-id] and was expected to come from [matchingServiceEntityId]");
    }
}
Also used : ResponseFromMatchingService(uk.gov.ida.hub.policy.domain.ResponseFromMatchingService) UserAccountCreatedFromMatchingService(uk.gov.ida.hub.policy.domain.UserAccountCreatedFromMatchingService) StateProcessingValidationException(uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException) UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState(uk.gov.ida.hub.policy.builder.state.UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) Test(org.junit.Test)

Example 3 with StateProcessingValidationException

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

the class LevelOfAssuranceValidatorTest method validate_shouldThrowExceptionIfLevelOfAssuranceFromMatchingServiceDoesNotExist.

@Test
public void validate_shouldThrowExceptionIfLevelOfAssuranceFromMatchingServiceDoesNotExist() throws Exception {
    LevelOfAssurance levelOfAssurance = LevelOfAssurance.LEVEL_2;
    try {
        levelOfAssuranceValidator.validate(Optional.<LevelOfAssurance>absent(), levelOfAssurance);
        fail("fail");
    } catch (StateProcessingValidationException e) {
        assertThat(e.getMessage()).isEqualTo(StateProcessingValidationException.noLevelOfAssurance().getMessage());
    }
}
Also used : LevelOfAssurance(uk.gov.ida.hub.policy.domain.LevelOfAssurance) StateProcessingValidationException(uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException) Test(org.junit.Test)

Example 4 with StateProcessingValidationException

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

the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.

@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
    final String responseIssuerId = "wrong issuer";
    MatchFromMatchingService matchFromMatchingService = aMatchFromMatchingService().withIssuerId(responseIssuerId).build();
    try {
        controller.validateResponse(matchFromMatchingService);
        fail("fail");
    } catch (StateProcessingValidationException e) {
        assertThat(e.getMessage()).isEqualTo(format("Response to request ID [requestId] came from [{0}] and was expected to come from [{1}]", responseIssuerId, MATCHING_SERVICE_ENTITY_ID));
    }
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchFromMatchingServiceBuilder.aMatchFromMatchingService(uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService) MatchFromMatchingService(uk.gov.ida.hub.policy.domain.MatchFromMatchingService) Matchers.anyString(org.mockito.Matchers.anyString) StateProcessingValidationException(uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 StateProcessingValidationException (uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException)4 MatchFromMatchingServiceBuilder.aMatchFromMatchingService (uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService)2 MatchFromMatchingService (uk.gov.ida.hub.policy.domain.MatchFromMatchingService)2 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)2 Matchers.anyString (org.mockito.Matchers.anyString)1 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)1 UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState (uk.gov.ida.hub.policy.builder.state.UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 ResponseFromMatchingService (uk.gov.ida.hub.policy.domain.ResponseFromMatchingService)1 UserAccountCreatedFromMatchingService (uk.gov.ida.hub.policy.domain.UserAccountCreatedFromMatchingService)1 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)1 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)1