use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.
the class LanguageSelectorTest method generateSelect.
@Test
public void generateSelect() throws Exception {
Response response = mock(Response.class);
Request request = getSpyMockRequest("select", ImmutableMap.of("language", "RU"));
component.generate(request, response, injector);
verify(response).sendAsRawJson(eq(languageSelectorResponse));
}
use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.
the class StaticPageComponentTest method generate.
@Test
public void generate() throws Exception {
Response response = mock(Response.class);
String page = "info.be";
Request req = getSpyMockRequest(page, ImmutableMap.of(TIMESTAMP_PARAM, "123456789"));
component.generate(req, response, injector);
// todo verify(response).sendAsJson(eq(new ResourceData(STATIC_ACTION,
// new StaticPagePresentation("", "<h1>Info</h1><p>Test text.</p>"))),
// eq(ImmutableMap.of(TIMESTAMP_PARAM, "123456789")),
// eq(Collections.singletonMap(SELF_LINK, "static/" + page)));
verify(response).sendAsJson(any(ResourceData.class), any(Map.class));
}
use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.
the class TestUtils method getSpyMockRequest.
protected Request getSpyMockRequest(String requestUri, Map<String, String> parameters, Map<String, Object> sessionValues) {
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
when(httpServletRequest.getSession()).thenReturn(mock(HttpSession.class));
Request request = Mockito.spy(new RequestImpl(httpServletRequest, null, parameters));
when(request.getRequestUri()).thenReturn(requestUri);
for (Map.Entry<String, Object> entry : sessionValues.entrySet()) {
when(request.getAttribute(entry.getKey())).thenReturn(entry.getValue());
}
return request;
}
Aggregations