Need Help with creating a stub for workflow model in the Junit test case
This is my servlet that is invoking a workflow and it is using a workflow model.
I am unable to create a stub for the workflow model in the testcase for the servlet.
I am using a mock workflow model but it is returning null or throwing exception.
The servlet code that starts workflow provided below.
WorkflowSession wfSession = workflowService.getWorkflowSession(session);
WorkflowModel wfModel = wfSession.getModel("/var/workflow/models/dam/dam_download_asset");
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", "/content/dam/we-retail/en/features/cart.png");
wfSession.startWorkflow(wfModel, wfData);
@1227241
public AemContext aemContext = new AemContext(ResourceResolverType.JCR_OAK);
@Mock
WorkflowServiceworkflowService;
@Mock
WorkflowSessionwfSession;
@Mock
WorkflowModel wfmodel;
@Before
public void setup() {
Mockito.lenient().when(workflowService.getWorkflowSession(resource.getResourceResolver().adaptTo(Session.class))).thenReturn(wfSession);
Mockito.lenient().when(resolverFactory.getServiceResourceResolver(this.serviceParams)).thenReturn(aemContext.resourceResolver());
wfmodel=workflowService.getWorkflowSession(resource.getResourceResolver().adaptTo(Session.class)).createNewModel("/var/workflow/models/dam/dam_download_asset");
The last line in the test case is throwing error. I don't know how to create the stub for the model.
Hence it would be highly helpful if I get the details to create the workflow-model stub in the junit test case.