@Test public void testAddMessage() { ArgumentCaptor<String> clientIdCaptor = ArgumentCaptor .forClass(String.class); ArgumentCaptor<FacesMessage> facesMessageCaptor = ArgumentCaptor .forClass(FacesMessage.class); someBean.addMessage(FacesMessage.SEVERITY_ERROR, "error", "something went wrong"); verify(facesContext).addMessage(clientIdCaptor.capture(), facesMessageCaptor.capture()); assertNull(clientIdCaptor.getValue()); FacesMessage captured = facesMessageCaptor.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();  }