I tried to written test cases in below controller class but facing null pointer exception
public class SiteXMLCreatorController extends WCMUse implements Controller
{
PageManager pm = getPageManager();
Page parentProvided = pm.getPage(getProperties().get("sectionparent",
String.class));
if (parentProvided != null) {int depth_selected = Integer.parseInt((String) getProperties().get("depth"));
}
I written test cases
public class SiteXMLCreatorControllerTest
{
SiteXMLCreatorController underTest;
@Mock
Page P_MOCK;
@Mock
PageManager PAGE_MOCK;
@Mock
ValueMap properties;
@Mock
WCMUse WCMUSE_MOCK;
@Mock
ResourceResolver resourceResolver;
@Before
public void setUp() throws Exception {
underTest=new SiteXMLCreatorController();
//when(underTest.getPageManager()).thenReturn(PAGE_MOCK);
}
@Test
public void testGetSiteMap() throws Exception
{
when(WCMUSE_MOCK.getPageManager()).thenReturn(PAGE_MOCK);
when(PAGE_MOCK.getPage("sectionparent")).thenReturn(P_MOCK);
when(PAGE_MOCK.getContainingPage("/content/geometrixx/en").getPath()).thenReturn(P_MOCK);
}
last line of code i getting error. Please let me know how resolve it.