Hello @satishm1 -
While you are trying to write the Test Cases for the AccordianSchemaModel which implements the Adaptable interface and relies on SlingHttpServletRequest in its init() method.
Have you been mocking the SlingHttpServletRequest the right way? If not, please try below approach to create the mock object of SlingHttpServletRequest :
// Create a mock of SlingHttpServletRequest
SlingHttpServletRequest request = Mockito.mock(SlingHttpServletRequest.class);
// Set up necessary properties or behaviors
// For example, if your init() method accesses request parameters, you can mock the behavior as follows:
Mockito.when(request.getParameter("paramName")).thenReturn("paramValue");
// Pass the mock request object to the AccordionSchemaModel instance
AccordionSchemaModel model = new AccordionSchemaModel();
model.init(request);
// Proceed with your test assertions
// ...
Hope this helps 🙂