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);
}
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);
}
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);
}
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();
}
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);
}
Aggregations