use of io.automatiko.engine.api.auth.IdentitySupplier in project automatiko-engine by automatiko-io.
the class ProcessInstanceManagementResourceTest method setup.
@SuppressWarnings({ "rawtypes", "unchecked" })
@BeforeEach
public void setup() {
responseBuilder = mock(ResponseBuilder.class);
Response response = mock(Response.class);
when((runtimeDelegate).createResponseBuilder()).thenReturn(responseBuilder);
lenient().when((responseBuilder).status(any(StatusType.class))).thenReturn(responseBuilder);
lenient().when((responseBuilder).entity(any())).thenReturn(responseBuilder);
lenient().when((responseBuilder).build()).thenReturn(response);
application = mock(Application.class);
Map<String, Process<?>> processes = Mockito.mock(Map.class);
Process process = mock(Process.class);
ProcessInstances instances = mock(ProcessInstances.class);
processInstance = mock(ProcessInstance.class);
errors = mock(ProcessErrors.class);
lenient().when(processes.get(anyString())).thenReturn(process);
lenient().when(process.instances()).thenReturn(instances);
lenient().when(instances.findById(anyString())).thenReturn(Optional.of(processInstance));
lenient().when(instances.findById(anyString(), eq(5), any())).thenReturn(Optional.of(processInstance));
lenient().when(processInstance.errors()).thenReturn(Optional.of(errors));
lenient().when(processInstance.id()).thenReturn("abc-def");
lenient().when(processInstance.status()).thenReturn(ProcessInstance.STATE_ACTIVE);
lenient().when(errors.failedNodeIds()).thenReturn("xxxxx");
lenient().when(errors.errorMessages()).thenReturn("Test error message");
lenient().when(application.unitOfWorkManager()).thenReturn(new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory()));
IdentitySupplier identitySupplier = new IdentitySupplier() {
@Override
public IdentityProvider buildIdentityProvider(String user, List<String> roles) {
return new StaticIdentityProvider("test");
}
};
resource = spy(new ProcessInstanceManagementResource(processes, application, identitySupplier));
}
Aggregations