use of javax.faces.context.ExternalContext in project ART-TIME by Artezio.
the class ContextUtilTest method testGetFromFlash.
@Test
public void testGetFromFlash() {
PowerMock.mockStatic(FacesContext.class);
Flash flash = createMock(Flash.class);
FacesContext facesContext = createMock(FacesContext.class);
ExternalContext externalContext = createMock(ExternalContext.class);
expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
expect(facesContext.getExternalContext()).andReturn(externalContext);
expect(externalContext.getFlash()).andReturn(flash);
expect(flash.get("key")).andReturn("value");
PowerMock.replayAll(FacesContext.class, facesContext, externalContext, flash);
Object actual = ContextUtil.getFromFlash("key");
PowerMock.verifyAll();
}
use of javax.faces.context.ExternalContext in project ART-TIME by Artezio.
the class ContextUtilTest method testPutIntoFlash.
@Test
public void testPutIntoFlash() {
PowerMock.mockStatic(FacesContext.class);
Flash flash = createMock(Flash.class);
FacesContext facesContext = createMock(FacesContext.class);
ExternalContext externalContext = createMock(ExternalContext.class);
expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
expect(facesContext.getExternalContext()).andReturn(externalContext);
expect(externalContext.getFlash()).andReturn(flash);
expect(flash.put("key", "value")).andReturn("value");
PowerMock.replayAll(FacesContext.class, facesContext, externalContext, flash);
ContextUtil.putIntoFlash("key", "value");
PowerMock.verifyAll();
}
use of javax.faces.context.ExternalContext in project ART-TIME by Artezio.
the class ContextUtilTest method testGetFlash.
@Test
public void testGetFlash() {
PowerMock.mockStatic(FacesContext.class);
Flash flash = createMock(Flash.class);
FacesContext facesContext = createMock(FacesContext.class);
ExternalContext externalContext = createMock(ExternalContext.class);
expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
expect(facesContext.getExternalContext()).andReturn(externalContext);
expect(externalContext.getFlash()).andReturn(flash);
PowerMock.replayAll(FacesContext.class, facesContext, externalContext);
Flash actual = ContextUtil.getFlash();
PowerMock.verifyAll();
}
use of javax.faces.context.ExternalContext in project ART-TIME by Artezio.
the class ContextUtilTest method testGetExternalContext.
@Test
public void testGetExternalContext() {
PowerMock.mockStatic(FacesContext.class);
FacesContext facesContext = createMock(FacesContext.class);
ExternalContext externalContext = createMock(ExternalContext.class);
expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
expect(facesContext.getExternalContext()).andReturn(externalContext);
PowerMock.replayAll(FacesContext.class);
ExternalContext actual = ContextUtil.getExternalContext();
PowerMock.verifyAll();
}
use of javax.faces.context.ExternalContext in project ART-TIME by Artezio.
the class EffortsBeanTest method testExtractEffortsGroupingFromCookie.
@Test
public void testExtractEffortsGroupingFromCookie() throws Exception {
FacesContext facesContext = createMock(FacesContext.class);
ExternalContext externalContext = createMock(ExternalContext.class);
HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
Cookie[] cookies = new Cookie[] { new Cookie("efforts_grouping", BY_PROJECTS.toString()) };
setField(effortsBean, "facesContext", facesContext);
expect(facesContext.getExternalContext()).andReturn(externalContext).anyTimes();
expect(externalContext.getRequest()).andReturn(httpServletRequest);
expect(externalContext.getResponse()).andReturn(httpServletResponse);
expect(httpServletRequest.getCookies()).andReturn(cookies).anyTimes();
replay(facesContext, externalContext, httpServletRequest);
EffortsGrouping expected = BY_PROJECTS;
EffortsGrouping actual = Whitebox.invokeMethod(effortsBean, "extractEffortsGroupingFromCookie");
assertEquals(expected, actual);
}
Aggregations