@Before public void setUp() { providerType = mock(ProviderType.class); when(providerType.getProviderTypeName()).thenReturn(PROVIDER_TYPE_NAME); when(providerType.getVersion()).thenReturn(PROVIDER_TYPE_VERSION); pipelineService = mock(PipelineService.class); pipelineServiceBackend = new PipelineServiceBackendImpl(pipelineService); }
@Test public void testDeletePipelineExecution() { pipelineServiceBackend.deletePipelineExecution(PIPELINE_EXECUTION_ID); verify(pipelineService, times(1)).deletePipelineExecution(PIPELINE_EXECUTION_ID); } }
@Test public void testNewPipelineForProvider() { PipelineConfig pipelineConfig = mock(PipelineConfig.class); when(pipelineService.newPipeline(pipelineConfig, providerType)).thenReturn(PIPELINE_NAME); String result = pipelineServiceBackend.newPipeline(pipelineConfig, providerType); verify(pipelineService, times(1)).newPipeline(pipelineConfig, providerType); assertEquals(PIPELINE_NAME, result); }
@Test public void testGetPipelineConfigs() { List<PipelineConfig> values = mockList(PipelineConfig.class, ELEMENTS_COUNT); PipelineConfigsList list = new PipelineConfigsList(values); when(pipelineService.getPipelineConfigs(PAGE, PAGE_SIZE, SORT, SORT_ORDER)).thenReturn(list); List<PipelineConfig> result = pipelineServiceBackend.getPipelineConfigs(PAGE, PAGE_SIZE, SORT, SORT_ORDER); verify(pipelineService, times(1)).getPipelineConfigs(PAGE, PAGE_SIZE, SORT, SORT_ORDER); assertEquals(result, values); }
@Test public void testStopPipelineExecution() { pipelineServiceBackend.stopPipelineExecution(PIPELINE_EXECUTION_ID); verify(pipelineService, times(1)).stopPipelineExecution(PIPELINE_EXECUTION_ID); }
private void testRunPipeline(boolean async) { Input input = mock(Input.class); when(pipelineService.runPipeline(PIPELINE_NAME, input, async)).thenReturn(PIPELINE_EXECUTION_ID); String result = pipelineServiceBackend.runPipeline(PIPELINE_NAME, input, async); verify(pipelineService, times(1)).runPipeline(PIPELINE_NAME, input, async); assertEquals(PIPELINE_EXECUTION_ID, result); }
@Test public void testGetPipelineNames() { List<String> values = mock(List.class); when(pipelineService.getPipelineNames(PROVIDER_TYPE_NAME, PROVIDER_TYPE_VERSION, PAGE, PAGE_SIZE, SORT, SORT_ORDER)).thenReturn(values); List<String> result = pipelineServiceBackend.getPipelineNames(providerType, PAGE, PAGE_SIZE, SORT, SORT_ORDER); verify(pipelineService, times(1)).getPipelineNames(PROVIDER_TYPE_NAME, PROVIDER_TYPE_VERSION, PAGE, PAGE_SIZE, SORT, SORT_ORDER); assertEquals(values, result); }
@Test public void testGetPipelineConfigsForProviderType() { List<PipelineConfig> values = mockList(PipelineConfig.class, ELEMENTS_COUNT); PipelineConfigsList list = new PipelineConfigsList(values); when(pipelineService.getPipelineConfigs(PROVIDER_TYPE_NAME, PROVIDER_TYPE_VERSION, PAGE, PAGE_SIZE, SORT, SORT_ORDER)).thenReturn(list); List<PipelineConfig> result = pipelineServiceBackend.getPipelineConfigs(providerType, PAGE, PAGE_SIZE, SORT, SORT_ORDER); verify(pipelineService, times(1)).getPipelineConfigs(PROVIDER_TYPE_NAME, PROVIDER_TYPE_VERSION, PAGE, PAGE_SIZE, SORT, SORT_ORDER); assertEquals(result, values); }
@Test public void testNewPipeline() { PipelineConfig pipelineConfig = mock(PipelineConfig.class); when(pipelineService.newPipeline(pipelineConfig)).thenReturn(PIPELINE_NAME); String result = pipelineServiceBackend.newPipeline(pipelineConfig); verify(pipelineService, times(1)).newPipeline(pipelineConfig); assertEquals(PIPELINE_NAME, result); }