Expand my Community achievements bar.

SOLVED

AEM Junits

Avatar

Level 2

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")
@Override
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.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor
1 Reply

Avatar

Correct answer by
Employee Advisor