Identity links give null pointer exception

Hello,
I am facing an issue at my junit test when they include identity links.
I am getting the following:

java.lang.NullPointerException: Cannot invoke “org.flowable.common.engine.impl.interceptor.CommandContext.getEngineConfigurations()” because the return value of “org.flowable.variable.service.impl.util.CommandContextUtil.getCommandContext()” is null

which fails when calling: task.getIdentityLinks()

at my test I include identity links like that:

when(flowableTaskService.createTaskQuery()).thenReturn(mockTaskQuery);
        when(mockTaskQuery.includeIdentityLinks()).thenReturn(mockTaskQuery);
        when(mockTaskQuery.includeTaskLocalVariables()).thenReturn(mockTaskQuery);
        when(mockTaskQuery.includeProcessVariables()).thenReturn(mockTaskQuery);
        when(mockTaskQuery.listPage(0, 10)).thenReturn(List.of(task1));

so I was thinking that there shouldn’t be an error.
Identity engine is not enabled.