use of org.springframework.webflow.test.MockParameterMap in project head by mifos.
the class CreateSavingsAccountTest method testEnterAccountDetailsStep_NewProductSelected.
@Test
public void testEnterAccountDetailsStep_NewProductSelected() {
Integer productId = 1;
setCurrentState("enterAccountDetailsStep");
MockExternalContext context = new MockExternalContext();
MockParameterMap requestParameterMap = new MockParameterMap();
requestParameterMap.put("productId", productId.toString());
context.setRequestParameterMap(requestParameterMap);
context.setEventId("newProductSelected");
resumeFlow(context);
verify(controller).loadProduct(productId, formBean);
assertCurrentStateEquals("enterAccountDetailsStep");
}
use of org.springframework.webflow.test.MockParameterMap in project head by mifos.
the class CreateSavingsAccountTest method testSelectProductOfferingStep_ProductSelected.
@Test
public void testSelectProductOfferingStep_ProductSelected() {
Integer productId = 1;
setCurrentState("selectProductOfferingStep");
doNothing().when(controller).loadProduct(1, formBean);
MockExternalContext context = new MockExternalContext();
MockParameterMap requestParameterMap = new MockParameterMap();
requestParameterMap.put("productId", productId.toString());
context.setRequestParameterMap(requestParameterMap);
context.setEventId("productSelected");
resumeFlow(context);
verify(controller).loadProduct(productId, formBean);
assertCurrentStateEquals("enterAccountDetailsStep");
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class RadiusAuthenticationWebflowEventResolverFailureTests method initialize.
@BeforeEach
public void initialize() {
this.context = mock(RequestContext.class);
when(context.getConversationScope()).thenReturn(new LocalAttributeMap<>());
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestScope()).thenReturn(new LocalAttributeMap<>());
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
val request = new MockHttpServletRequest();
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
when(context.getFlowExecutionContext()).thenReturn(new MockFlowExecutionContext(new MockFlowSession(new Flow("mockFlow"))));
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val authentication = CoreAuthenticationTestUtils.getAuthentication();
WebUtils.putAuthentication(authentication, context);
val builder = mock(AuthenticationResultBuilder.class);
when(builder.getInitialAuthentication()).thenReturn(Optional.of(authentication));
when(builder.collect(any(Authentication.class))).thenReturn(builder);
WebUtils.putAuthenticationResultBuilder(builder, context);
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class SendForgotUsernameInstructionsActionEmailMessageBodyTests method verifyOp.
@Test
public void verifyOp() throws Exception {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getFlashScope()).thenReturn(new LocalAttributeMap<>());
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestScope()).thenReturn(new LocalAttributeMap<>());
when(context.getConversationScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
request.setParameter("email", "casuser@apereo.org");
var result = sendForgotUsernameInstructionsAction.execute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, result.getId());
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class WebAuthnAuthenticationWebflowEventResolverTests method verifyOperation.
@Test
public void verifyOperation() {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = mock(RequestContext.class);
when(context.getRequestScope()).thenReturn(new LocalAttributeMap<>());
when(context.getConversationScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
WebUtils.putCredential(context, RegisteredServiceTestUtils.getCredentialsWithDifferentUsernameAndPassword("casuser", "123456"));
val event = webAuthnAuthenticationWebflowEventResolver.resolveSingle(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, event.getId());
assertEquals(HttpStatus.UNAUTHORIZED.value(), response.getStatus());
val support = new EventFactorySupport();
assertTrue(event.getAttributes().contains(support.getExceptionAttributeName()));
}
Aggregations