@Before public void setUp() throws Exception { Kernel.INSTANCE.restart(); Kernel.initBootstrap(); statusManager = new PipelineTaskStatusManager(); RapturePipelineTask task1 = createTask(); id1 = task1.getTaskId(); statusManager.initialCreation(task1); RapturePipelineTask task2 = createTask(); id2 = task2.getTaskId(); statusManager.initialCreation(task2); }
private RapturePipelineTask createTask() { RapturePipelineTask task = new RapturePipelineTask(); Worker worker = new Worker(); worker.setPriority(2); task.setPriority(worker.getPriority()); task.setCategoryList(ImmutableList.of("cat")); task.addMimeObject(worker); task.setContentType(MimeDecisionProcessAdvance.getMimeType()); task.initTask(); Kernel.getPipeline().publishMessageToCategory(ContextFactory.getKernelUser(), task); return task; }
@Test public void testQueryTasks() throws Exception { List<RapturePipelineTask> result = statusManager.queryTasks("SELECT content"); assertEquals(2, result.size()); RapturePipelineTask p1 = result.get(0); RapturePipelineTask p2 = result.get(1); if (p1.getTaskId().equals(id1)) { assertEquals(id2, p2.getTaskId()); } else if (p2.getTaskId().equals(id1)) { assertEquals(id2, p1.getTaskId()); } assertEquals(1, p1.getCategoryList().size()); assertEquals(1, p2.getCategoryList().size()); assertEquals("cat", p1.getCategoryList().get(0)); assertEquals(MimeDecisionProcessAdvance.getMimeType(), p1.getContentType()); assertEquals(p1.getContent(), p2.getContent()); }