use of org.springframework.webflow.test.MockParameterMap in project head by mifos.
the class CreateSavingsAccountTest method testSelectCustomerStep_CustomerSelected.
@Test
public void testSelectCustomerStep_CustomerSelected() {
Integer customerId = 1;
setCurrentState("selectCustomerStep");
doNothing().when(controller).getProductOfferings(formBean);
MockExternalContext context = new MockExternalContext();
MockParameterMap requestParameterMap = new MockParameterMap();
requestParameterMap.put("customerId", customerId.toString());
context.setRequestParameterMap(requestParameterMap);
context.setEventId("customerSelected");
resumeFlow(context);
verify(controller).customerSelected(customerId, formBean);
verify(controller).getProductOfferings(formBean);
assertCurrentStateEquals("selectProductOfferingStep");
}
use of org.springframework.webflow.test.MockParameterMap in project head by mifos.
the class CreateSavingsAccountTest method testStartFlow_CustomerIdProvided.
@Test
public void testStartFlow_CustomerIdProvided() {
Integer customerId = 1;
MutableAttributeMap input = new LocalAttributeMap();
MockParameterMap requestParameterMap = new MockParameterMap();
requestParameterMap.put("customerId", customerId.toString());
MockExternalContext context = new MockExternalContext();
context.setRequestParameterMap(requestParameterMap);
startFlow(input, context);
assertCurrentStateEquals("selectProductOfferingStep");
verify(controller).customerSelected(eq(customerId), any(CreateSavingsAccountFormBean.class));
verify(controller).getProductOfferings(any(CreateSavingsAccountFormBean.class));
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class BaseAcceptableUsagePolicyRepositoryTests method verifyFetchingPolicy.
protected void verifyFetchingPolicy(final RegisteredService service, final Authentication authentication, final boolean expectPolicyFound) {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
val context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getConversationScope()).thenReturn(new LocalAttributeMap<>());
val flowDefn = mock(FlowDefinition.class);
when(flowDefn.getApplicationContext()).thenReturn(applicationContext);
when(context.getActiveFlow()).thenReturn(flowDefn);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
WebUtils.putRegisteredService(context, service);
WebUtils.putAuthentication(authentication, context);
assertEquals(expectPolicyFound, getAcceptableUsagePolicyRepository().fetchPolicy(context).isPresent());
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class AuthyAuthenticationWebflowEventResolverTests method beforeAll.
@BeforeEach
public void beforeAll() {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getConversationScope()).thenReturn(new LocalAttributeMap<>());
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getRequestScope()).thenReturn(new LocalAttributeMap<>());
when(context.getFlashScope()).thenReturn(new LocalAttributeMap<>());
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
WebUtils.putCredential(context, new AuthyTokenCredential("token"));
}
use of org.springframework.webflow.test.MockParameterMap in project cas by apereo.
the class GenericCasWebflowExceptionHandlerTests method verifyOperation.
@Test
public void verifyOperation() {
val errors = new LinkedHashSet<Class<? extends Throwable>>();
errors.add(AccountLockedException.class);
errors.add(CredentialExpiredException.class);
errors.add(AccountExpiredException.class);
val catalog = new DefaultCasWebflowExceptionCatalog();
catalog.registerExceptions(errors);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, response));
val handler = new GenericCasWebflowExceptionHandler(catalog, MessageBundleProperties.DEFAULT_BUNDLE_PREFIX_AUTHN_FAILURE);
assertTrue(handler.supports(new AccountExpiredException(), context));
val event = handler.handle(new CredentialExpiredException(), context);
assertNotNull(event);
assertEquals(CasWebflowExceptionHandler.UNKNOWN, event.getId());
}
Aggregations