Try this
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.*;
class WorkflowSessionTest {
private WorkflowSession wfsession;
private WorkItem workItem;
private Route route;
@BeforeEach
void setUp() {
// Mocking the WorkflowSession and WorkItem
wfsession = mock(WorkflowSession.class);
workItem = mock(WorkItem.class);
route = mock(Route.class);
// Mocking getRoutes to return a list with one route when false is passed
when(wfsession.getRoutes(workItem, false)).thenReturn(List.of(route));
}
@test
void testCompleteAndSuspendWorkflow() {
// Act - call complete on the work item
wfsession.complete(workItem, wfsession.getRoutes(workItem, false).get(0));
// Verify complete is called with the correct route
verify(wfsession).complete(workItem, route);
// Act - suspend the workflow associated with the work item
wfsession.suspendWorkflow(workItem.getWorkflow());
// Verify suspendWorkflow is called with the correct workflow
verify(wfsession).suspendWorkflow(workItem.getWorkflow());
}
}