/** * Cosntruct a new BaleenJob * * @param name The name of the job * @param config The job configuration * @param scheduler The scheduler (i.e. collection reader) * @param tasks List of tasks (i.e. annotators) */ public BaleenJob( String name, PipelineConfiguration config, CollectionReader scheduler, List<AnalysisEngine> tasks) { super(name, config, new NoOpOrderer(), scheduler, tasks, Collections.emptyList()); }
/** * Cosntruct a new BaleenJob * * @param name The name of the job * @param config The job configuration * @param scheduler The scheduler (i.e. collection reader) * @param tasks List of tasks (i.e. annotators) */ public BaleenJob( String name, PipelineConfiguration config, CollectionReader scheduler, List<AnalysisEngine> tasks) { super(name, config, new NoOpOrderer(), scheduler, tasks, Collections.emptyList()); }
/** * Create a new pipeline orderer * * @throws BaleenException */ private IPipelineOrderer createPipelineOrderer() { Class<?> c; try { c = BuilderUtils.getClassFromString(pipelineOrderer, getDefaultOrdererPackage()); return (IPipelineOrderer) c.newInstance(); } catch (InvalidParameterException | InstantiationException | IllegalAccessException ipe) { LOGGER.warn("Couldn't find or use specified orderer " + pipelineOrderer, ipe); return new NoOpOrderer(); } }
/** * Create a new pipeline orderer * * @throws BaleenException */ private IPipelineOrderer createPipelineOrderer() { Class<?> c; try { c = BuilderUtils.getClassFromString(pipelineOrderer, getDefaultOrdererPackage()); return (IPipelineOrderer) c.newInstance(); } catch (InvalidParameterException | InstantiationException | IllegalAccessException ipe) { LOGGER.warn("Couldn't find or use specified orderer " + pipelineOrderer, ipe); return new NoOpOrderer(); } }
@Before public void before() { realPipeline = new BaleenPipeline( REAL, pipelineConfiguration, new NoOpOrderer(), new DummyCollectionReader(), Collections.emptyList(), Collections.emptyList()); doReturn(true).when(pipelineManager).has(REAL); doReturn(Optional.of(realPipeline)).when(pipelineManager).get(REAL); doReturn(Collections.singleton(realPipeline)).when(pipelineManager).getAll(); doReturn(Optional.empty()).when(pipelineManager).get(MISSING); doReturn(Optional.of(mockPipeline)).when(pipelineManager).get("mock"); doReturn("pipeline-name").when(mockPipeline).getName(); doReturn(false).when(mockPipeline).isPaused(); }
@Test public void testNameAndYaml() throws IOException { BaleenPipeline bop = new BaleenPipeline( "Test Name", new YamlPipelineConfiguration("Test YAML"), new NoOpOrderer(), null, Collections.emptyList(), Collections.emptyList()); assertEquals("Test Name", bop.getName()); assertEquals("Test YAML", bop.originalConfig()); // TODO: Test orderedYaml }
@Test public void testEmpty() throws Exception { BaleenPipeline pipeline = new BaleenPipeline( "name", new YamlPipelineConfiguration(), new NoOpOrderer(), null, Collections.emptyList(), Collections.emptyList()); doReturn(Optional.of(pipeline)).when(manager).get(anyString()); ServletCaller caller = new ServletCaller(); caller.addParameter("name", "name"); caller.doGet(new PipelineConfigServlet(manager)); assertEquals("", caller.getResponseBody()); }
@Test public void testWithConfig() throws Exception { BaleenPipeline pipeline = new BaleenPipeline( "name", new YamlPipelineConfiguration("Config"), new NoOpOrderer(), null, Collections.emptyList(), Collections.emptyList()); doReturn(Optional.of(pipeline)).when(manager).get(anyString()); ServletCaller caller = new ServletCaller(); caller.addParameter("name", "name"); caller.doGet(new PipelineConfigServlet(manager)); assertEquals("Config", caller.getResponseBody()); } }
@Test public void testPause() throws IOException { BaleenPipeline bop = new BaleenPipeline( "Test Name", new YamlPipelineConfiguration(), new NoOpOrderer(), null, Collections.emptyList(), Collections.emptyList()); assertFalse(bop.isPaused()); bop.pause(); assertTrue(bop.isPaused()); bop.unpause(); assertFalse(bop.isPaused()); } }