AEM Junits | Community
Skip to main content
Employee
December 14, 2022
Solved

AEM Junits

  • December 14, 2022
  • 1 reply
  • 630 views

Hi All,

 

I have a servlet and it has an inner class which has some methods inside it. The structure looks like this

 

public class ImageServlet extends AbstractImageServlet {

class ImageWrapper {


public Image getImage() {
final Image image;

if (name == null) {

image = new Image(resource);
} else {

image = new Image(resource, name); // getting null pointer exception here as even though I am trying to mock Image, unable to mock it properly.
}

return image;
}


}

@SuppressWarnings("deprecation")
@9944223
protected void writeLayer(final SlingHttpServletRequest request, final SlingHttpServletResponse response,
final ImageContext context, final Layer layer) throws RepositoryException, IOException {

final Image image = wrapper.getImage();
}
}

 

Any pointers will help.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.