I tried to mock PageManger in test classes
my main class code like
public class ABC extends WCMUse implements Controller
{
public Page getMethod() throws Exception {
List<Url> urllist=new ArrayList<Url>();
PageManager pm = getPageManager();
Page parentProvided = pm.getPage(getProperties().get("sectionparent",
String.class));
.....................
}
and test class
@RunWith(MockitoJUnitRunner.class)
public class ABCTest {
SiteXMLCreator underTest;
@Mock
Page P_MOCK;
@Mock
PageManager PAGE_MOCK;
@Mock
WCMUse WCMUSE_MOCK;
@Mock
@Rule
public final AemContext context = new AemContext();
@Before
public void setUp() throws Exception {
underTest = new ABC();
}
@Test
public void testGetMethod() throws Exception
{ underTest.getMethod();
when(context.pageManager()).thenReturn(PAGE_MOCK);
}
}
getting Null pointer exception. PageManager getting null value. Please let me know how to mock PageManger