use of org.springframework.webflow.test.MockExternalContext in project cas by apereo.
the class GenericSuccessViewActionTests method verifyRedirect.
@Test
public void verifyRedirect() throws Exception {
val cas = mock(CentralAuthenticationService.class);
val servicesManager = mock(ServicesManager.class);
val serviceFactory = mock(ServiceFactory.class);
val service = RegisteredServiceTestUtils.getService("https://github.com/apereo/cas");
when(serviceFactory.createService(anyString())).thenReturn(service);
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
when(servicesManager.findServiceBy(any(Service.class))).thenReturn(registeredService);
casProperties.getView().setDefaultRedirectUrl(service.getId());
val action = new GenericSuccessViewAction(cas, servicesManager, serviceFactory, casProperties);
val context = new MockRequestContext();
context.setExternalContext(new MockExternalContext());
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
val result = action.execute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, result.getId());
assertTrue(context.getMockExternalContext().getExternalRedirectRequested());
assertEquals(service.getId(), context.getMockExternalContext().getExternalRedirectUrl());
}
use of org.springframework.webflow.test.MockExternalContext in project head by mifos.
the class CreateSavingsAccountTest method testPreviewStep_EditAccountDetails.
@Test
public void testPreviewStep_EditAccountDetails() {
setCurrentState("previewStep");
MockExternalContext context = new MockExternalContext();
context.setEventId("editAccountDetails");
resumeFlow(context);
verify(controller, never()).loadQuestionGroups(formBean);
assertCurrentStateEquals("editAccountDetailsStep");
}
use of org.springframework.webflow.test.MockExternalContext in project head by mifos.
the class CreateSavingsAccountTest method testPreviewStep_SaveForApproval.
@Test
public void testPreviewStep_SaveForApproval() {
setCurrentState("previewStep");
MockExternalContext context = new MockExternalContext();
context.setEventId("saveForApproval");
resumeFlow(context);
verify(controller).createAccountInPendingApprovalState(formBean);
assertFlowExecutionEnded();
assertFlowExecutionOutcomeEquals("complete");
}
use of org.springframework.webflow.test.MockExternalContext in project head by mifos.
the class CreateSavingsAccountTest method testSelectCustomerStep_Cancel.
@Test
public void testSelectCustomerStep_Cancel() {
setCurrentState("selectCustomerStep");
MockExternalContext context = new MockExternalContext();
context.setEventId("cancel");
resumeFlow(context);
assertFlowExecutionEnded();
}
use of org.springframework.webflow.test.MockExternalContext in project head by mifos.
the class CreateSavingsAccountTest method testCustomerSearchStep_Cancel.
@Test
public void testCustomerSearchStep_Cancel() {
setCurrentState("customerSearchStep");
MockExternalContext context = new MockExternalContext();
context.setEventId("cancel");
resumeFlow(context);
assertFlowExecutionEnded();
}
Aggregations