package org.sonar.application.es;
import java.io.File;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
private static List<File> buildOutdatedSearchDirs(Props props) {
String dataPath = props.nonNullValue(PATH_DATA.getKey());
- return Collections.singletonList(new File(dataPath, "es"));
+ return Arrays.asList(new File(dataPath, "es"), new File(dataPath, "es5"));
}
private static File buildDataDir(Props props) {
String dataPath = props.nonNullValue(PATH_DATA.getKey());
- return new File(dataPath, "es5");
+ return new File(dataPath, "es6");
}
private static File buildLogPath(Props props) {
EsInstallation underTest = new EsInstallation(props);
- assertThat(underTest.getDataDirectory()).isEqualTo(new File(dataDir, "es5"));
+ assertThat(underTest.getDataDirectory()).isEqualTo(new File(dataDir, "es6"));
}
@Test
assertThat(underTest.getLogDirectory()).isEqualTo(logDir);
}
+ @Test
+ public void getOutdatedSearchDirectories_returns_all_previously_used_es_data_directory_names() throws IOException {
+ File sqHomeDir = temp.newFolder();
+ File logDir = temp.newFolder();
+ Props props = new Props(new Properties());
+ props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath());
+ props.set(PATH_HOME.getKey(), sqHomeDir.getAbsolutePath());
+ props.set(PATH_TEMP.getKey(), temp.newFolder().getAbsolutePath());
+ props.set(PATH_LOGS.getKey(), logDir.getAbsolutePath());
+
+ EsInstallation underTest = new EsInstallation(props);
+
+ assertThat(underTest.getOutdatedSearchDirectories())
+ .extracting(t -> t.getName())
+ .containsOnly("es", "es5");
+ }
+
@Test
public void conf_directory_is_conf_es_subdirectory_of_sq_temp_directory() throws IOException {
File tempDir = temp.newFolder();