PipelineHelper { public String getQueueNameFor(DatashareCli.Stage stage) { if (! has(stage)) throw new IllegalArgumentException("undefined stage " + stage); String inputQueueName = getInputQueueName(propertiesProvider); return stages.indexOf(stage) == 0 || stages.indexOf(stage) == 1 ? inputQueueName: getQueueName(propertiesProvider, stages.get(stages.indexOf(stage) - 1)); } PipelineHelper(PropertiesProvider propertiesProvider); boolean has(DatashareCli.Stage stage); String getQueueNameFor(DatashareCli.Stage stage); static String getQueueName(PropertiesProvider propertiesProvider, DatashareCli.Stage stage); static String getInputQueueName(PropertiesProvider propertiesProvider); final List<DatashareCli.Stage> stages; }
@Test(expected = IllegalArgumentException.class) public void test_get_queue_name_unknown_stage() { new PipelineHelper(new PropertiesProvider(new HashMap<String, String>() {{ put("stages", "SCAN,INDEX");}})).getQueueNameFor(DatashareCli.Stage.NLP); }
@Test public void test_get_queue_name_scan_index() { PipelineHelper pipelineHelper = new PipelineHelper(new PropertiesProvider(new HashMap<String, String>() {{ put("stages", "SCAN,INDEX"); put("queueName", "extract:queue"); }})); assertThat(pipelineHelper.getQueueNameFor(DatashareCli.Stage.SCAN)).isEqualTo("extract:queue"); assertThat(pipelineHelper.getQueueNameFor(DatashareCli.Stage.INDEX)).isEqualTo("extract:queue"); }
@Test public void test_get_queue_name_scan_index_deduplicate() { PipelineHelper pipelineHelper = new PipelineHelper(new PropertiesProvider(new HashMap<String, String>() {{ put("stages", "SCAN,DEDUPLICATE,INDEX"); put("queueName", "extract:queue"); }})); assertThat(pipelineHelper.getQueueNameFor(DatashareCli.Stage.SCAN)).isEqualTo("extract:queue"); assertThat(pipelineHelper.getQueueNameFor(DatashareCli.Stage.DEDUPLICATE)).isEqualTo("extract:queue"); assertThat(pipelineHelper.getQueueNameFor(DatashareCli.Stage.INDEX)).isEqualTo("extract:queue:deduplicate"); }