@Test public void testExecuteWithoutFile() { when(config.getPathInitScript()).thenReturn(""); step.execute(config); verify(step, never()).parseJson(any(ElasticsearchClient.class), eq(log), any(Path.class)); verify(step, never()).parseScript(any(ElasticsearchClient.class), eq(log), any(Path.class)); }
@Test public void testExecuteScriptFile() { String filePath = "folder/init.script"; when(config.getPathInitScript()).thenReturn(filePath); doNothing().when(step).validateFile(filePath); doNothing() .when(step) .parseScript(any(ElasticsearchClient.class), eq(log), any(Path.class)); step.execute(config); verify(step).validateFile(filePath); ArgumentCaptor<Path> pathCaptor = ArgumentCaptor.forClass(Path.class); verify(step).parseScript(any(ElasticsearchClient.class), eq(log), pathCaptor.capture()); assertEquals(filePath, pathCaptor.getValue().toString().replace('\\', '/')); }
@Test public void testExecuteJsonFile() { String filePath = "folder/init.json"; when(config.getPathInitScript()).thenReturn(filePath); doNothing().when(step).validateFile(filePath); doNothing() .when(step) .parseJson(any(ElasticsearchClient.class), eq(log), any(Path.class)); step.execute(config); verify(step).validateFile(filePath); ArgumentCaptor<Path> pathCaptor = ArgumentCaptor.forClass(Path.class); verify(step).parseJson(any(ElasticsearchClient.class), eq(log), pathCaptor.capture()); assertEquals(filePath, pathCaptor.getValue().toString().replace('\\', '/')); }