Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

How to Mock WorkflowService

Avatar

Level 2

Below is my original class 

@reference
private ResourceResolverFactory resourceResolverFactory;

@reference
private WorkflowService workflowService;

 

How can I mock the above?

I tried something like below:

 

@Mock
WorkflowService workflowServiceMock;

 

then

workflowServiceMock = context.registerInjectActivateService(workflowServiceMock);

 

But it throws NullPointerException

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@aemg12 

Can you please paste some more snippets or logic ? So that it will be more clear to investigate why the workflow session is returning NULLPOINTER_EXCEPTION

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@aemg12 

Can you please paste some more snippets or logic ? So that it will be more clear to investigate why the workflow session is returning NULLPOINTER_EXCEPTION

Avatar

Community Advisor

Hi @aemg12 

Based on the code you shared, context seems to be NULL, check that. If not please share code with error stack.

AG