Hi,
while i am trying to get current node value by mocking node class and ResourceResolver class I am getting nullPointerException over there.Exception is raising from getResource() method.
Here is my actual class code
public class Myclass extends WCMUse {
public void activate() throws Exception {
Node currentNode = getResource().adaptTo(Node.class);
.
.
..........bla bla
}
}
Here is my Test class
@Mock
Node node;
@Mock
ResourceResolver resourceResolver;
@Test
Resource res=resourceResolver.getResource("/");
EasyMock.expect(res.adaptTo((Class<Node>) EasyMock.anyObject())).andReturn(node);
In that underlined part I am getting null pointer Exception.
Please suggest me the exact approach.
Solved! Go to Solution.
Views
Replies
Total Likes
See this community article that talks about using Sling API to get resources:
https://helpx.adobe.com/experience-manager/using/using-sling-apis.html
Views
Replies
Total Likes
See this community article that talks about using Sling API to get resources:
https://helpx.adobe.com/experience-manager/using/using-sling-apis.html
Views
Replies
Total Likes
Hi Thanks for your reply
But I am facing that nullPointerException issue while creating Unit testcases for the component plz help me on that
Views
Replies
Total Likes
Views
Likes
Replies