Search in sources :

Example 1 with ProcessInstances

use of io.automatiko.engine.api.workflow.ProcessInstances 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));
}
Also used : StaticIdentityProvider(io.automatiko.engine.services.identity.StaticIdentityProvider) Process(io.automatiko.engine.api.workflow.Process) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Response(javax.ws.rs.core.Response) ProcessInstances(io.automatiko.engine.api.workflow.ProcessInstances) ProcessErrors(io.automatiko.engine.api.workflow.ProcessErrors) StatusType(javax.ws.rs.core.Response.StatusType) CollectingUnitOfWorkFactory(io.automatiko.engine.services.uow.CollectingUnitOfWorkFactory) IdentitySupplier(io.automatiko.engine.api.auth.IdentitySupplier) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) List(java.util.List) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Application(io.automatiko.engine.api.Application) DefaultUnitOfWorkManager(io.automatiko.engine.services.uow.DefaultUnitOfWorkManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Application (io.automatiko.engine.api.Application)1 IdentitySupplier (io.automatiko.engine.api.auth.IdentitySupplier)1 Process (io.automatiko.engine.api.workflow.Process)1 ProcessErrors (io.automatiko.engine.api.workflow.ProcessErrors)1 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)1 ProcessInstances (io.automatiko.engine.api.workflow.ProcessInstances)1 StaticIdentityProvider (io.automatiko.engine.services.identity.StaticIdentityProvider)1 CollectingUnitOfWorkFactory (io.automatiko.engine.services.uow.CollectingUnitOfWorkFactory)1 DefaultUnitOfWorkManager (io.automatiko.engine.services.uow.DefaultUnitOfWorkManager)1 List (java.util.List)1 Response (javax.ws.rs.core.Response)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 StatusType (javax.ws.rs.core.Response.StatusType)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1