@Test public void testAddMessage() { Capture<String> clientIdCapture = new Capture<String>(); Capture<FacesMessage> facesMessageCapture = new Capture<FacesMessage>(); expect(FacesContext.getCurrentInstance()).andReturn(facesContext) .once(); facesContext.addMessage(capture(clientIdCapture), capture(facesMessageCapture)); expectLastCall().once(); PowerMock.replay(FacesContext.class); replay(facesContext); someBean.addMessage(FacesMessage.SEVERITY_ERROR, "error", "something went wrong"); PowerMock.verify(FacesContext.class); verify(facesContext); assertNull(clientIdCapture.getValue()); FacesMessage captured = facesMessageCapture.getValue(); assertEquals(FacesMessage.SEVERITY_ERROR, captured.getSeverity()); assertEquals("error", captured.getSummary()); assertEquals("something went wrong", captured.getDetail()); }
public void addMessage(Severity severity, String summary, String detail) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail)); }
SomeBean { public void addMessage(Severity severity, String summary, String detail) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail)); } }
SomeBean { public void addMessage(Severity severity, String summary, String detail) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail)); }  }
SomeBean { public void addMessage(Severity severity, String summary, String detail) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail)); }  void addMessage(Severity severity, String summary, String detail); String logout(); }
SomeBean { public void addMessage(Severity severity, String summary, String detail) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail)); }  void addMessage(Severity severity, String summary, String detail); String logout();  }