I wrote myself aSortingBean
which is similiar to theCarsSortingBean
over here. I want to write a unit test for this class but I don't know how to do this. I got problems with the first line of the sort
method. How can I successfully mock this?
I already found out, that there is something calledMockFacesContext
:
@Test
public void testSort() throws Exception {
facesContextMock = MockFacesContext.getMockContext(true);
replay(facesContextMock);
classUnderTest.sort();
}
With this test I am getting aNullPointerException
because theRequestParameterMap
is not filled.
Can you give me any hint of how to solve this problem?