Search in sources :

Example 1 with StartsWith

use of org.mockito.internal.matchers.StartsWith in project kie-wb-common by kiegroup.

the class PipelineExecutorTaskManagerImplExecutionTest method testStopTaskInNonStopeableState.

private void testStopTaskInNonStopeableState(PipelineExecutorTask.Status notStopeableStatus) throws PipelineExecutorException {
    PipelineExecutorTaskImpl task = mock(PipelineExecutorTaskImpl.class);
    when(task.getId()).thenReturn(TASK_ID);
    when(task.getPipelineStatus()).thenReturn(notStopeableStatus);
    PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class);
    when(taskEntry.isAsync()).thenReturn(true);
    when(taskEntry.getTask()).thenReturn(task);
    taskManager.currentTasks.put(TASK_ID, taskEntry);
    taskManager.init();
    expectedException.expectMessage(new StartsWith("A PipelineExecutorTask in status: " + notStopeableStatus.name() + " can not be stopped. Stop operation is available for the following status set:"));
    taskManager.stop(TASK_ID);
}
Also used : StartsWith(org.mockito.internal.matchers.StartsWith)

Example 2 with StartsWith

use of org.mockito.internal.matchers.StartsWith in project kie-wb-common by kiegroup.

the class PipelineExecutorTaskManagerImplExecutionTest method testDeleteTaskInNonStopeableState.

private void testDeleteTaskInNonStopeableState(PipelineExecutorTask.Status nonStopeableStatus) throws Exception {
    PipelineExecutorTask task = mock(PipelineExecutorTask.class);
    when(task.getPipelineStatus()).thenReturn(nonStopeableStatus);
    PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class);
    when(trace.getTask()).thenReturn(task);
    when(pipelineExecutorRegistry.getExecutorTrace(TASK_ID)).thenReturn(trace);
    expectedException.expectMessage(new StartsWith("A PipelineExecutorTask in status: " + nonStopeableStatus + " can not" + " be deleted. Delete operation is available for the following status set:"));
    taskManager.delete(TASK_ID);
}
Also used : PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) PipelineExecutorTask(org.guvnor.ala.pipeline.execution.PipelineExecutorTask) StartsWith(org.mockito.internal.matchers.StartsWith)

Example 3 with StartsWith

use of org.mockito.internal.matchers.StartsWith in project kie-wb-common by kiegroup.

the class PipelineExecutorTaskManagerImplExecutionTest method testDeleteActiveTask.

@Test
public void testDeleteActiveTask() throws Exception {
    PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class);
    taskManager.currentTasks.put(TASK_ID, taskEntry);
    expectedException.expectMessage(new StartsWith("An active PipelineExecutorTask was found for taskId: " + TASK_ID));
    taskManager.delete(TASK_ID);
}
Also used : StartsWith(org.mockito.internal.matchers.StartsWith) Test(org.junit.Test)

Example 4 with StartsWith

use of org.mockito.internal.matchers.StartsWith in project mockito by mockito.

the class TypeSafeMatchingTest method compareToStringVsInt.

/**
     * Should not throw an {@link ClassCastException}
     */
@Test
public void compareToStringVsInt() {
    boolean match = matchesTypeSafe().apply(new StartsWith("Hello"), 123);
    assertThat(match).isFalse();
}
Also used : StartsWith(org.mockito.internal.matchers.StartsWith) Test(org.junit.Test)

Example 5 with StartsWith

use of org.mockito.internal.matchers.StartsWith in project actframework by actframework.

the class ActTestBase method setup.

protected void setup() throws Exception {
    initActMetricPlugin();
    mockApp = mock(App.class);
    Field f = App.class.getDeclaredField("INST");
    f.setAccessible(true);
    f.set(null, mockApp);
    mockSingletonRegistry = mock(SingletonRegistry.class);
    // when(mockApp.singletonRegistry()).thenReturn(mockSingletonRegistry);
    mockJobManager = mock(JobManager.class);
    when(mockApp.jobManager()).thenReturn(mockJobManager);
    mockEventBus = mock(EventBus.class);
    when(mockApp.eventBus()).thenReturn(mockEventBus);
    mockAppConfig = mock(AppConfig.class);
    when(mockAppConfig.possibleControllerClass(argThat(new StartsWith("testapp.controller.")))).thenReturn(true);
    mockActionContext = mock(ActionContext.class);
    when(mockActionContext.app()).thenReturn(mockApp);
    when(mockActionContext.config()).thenReturn(mockAppConfig);
    mockRouter = mock(Router.class);
    when(mockApp.config()).thenReturn(mockAppConfig);
    when(mockApp.router()).thenReturn(mockRouter);
    when(mockApp.router(Matchers.same(""))).thenReturn(mockRouter);
    when(mockApp.getInstance(any(Class.class))).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            Class<?> cls = (Class) args[0];
            if (SessionManager.class == cls) {
                return new SessionManager(mockAppConfig);
            }
            return $.newInstance((Class) args[0]);
        }
    });
    mockReq = mock(H.Request.class);
    mockResp = mock(ActResponse.class);
    when(mockReq.method()).thenReturn(H.Method.GET);
}
Also used : App(act.app.App) AppConfig(act.conf.AppConfig) SessionManager(act.session.SessionManager) Router(act.route.Router) JobManager(act.job.JobManager) EventBus(act.event.EventBus) ActionContext(act.app.ActionContext) StartsWith(org.mockito.internal.matchers.StartsWith) Field(java.lang.reflect.Field) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SingletonRegistry(act.app.SingletonRegistry)

Aggregations

StartsWith (org.mockito.internal.matchers.StartsWith)5 Test (org.junit.Test)2 ActionContext (act.app.ActionContext)1 App (act.app.App)1 SingletonRegistry (act.app.SingletonRegistry)1 AppConfig (act.conf.AppConfig)1 EventBus (act.event.EventBus)1 JobManager (act.job.JobManager)1 Router (act.route.Router)1 SessionManager (act.session.SessionManager)1 Field (java.lang.reflect.Field)1 PipelineExecutorTask (org.guvnor.ala.pipeline.execution.PipelineExecutorTask)1 PipelineExecutorTrace (org.guvnor.ala.pipeline.execution.PipelineExecutorTrace)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1