diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-06-14 16:08:15 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-06-15 00:22:22 -0700 |
commit | ded91a06f0646a7a8bd13a9010d8305b8050e3f7 (patch) | |
tree | a1ff224178aefe5127af8dd1cbfaaeb8bc8a501c | |
parent | f7e9c0f2ac6d5a80d2719ea0cecfa4ced05216d4 (diff) | |
download | sonarqube-ded91a06f0646a7a8bd13a9010d8305b8050e3f7.tar.gz sonarqube-ded91a06f0646a7a8bd13a9010d8305b8050e3f7.zip |
Improve the way web hash is retrieved
-rw-r--r-- | it/it-tests/src/test/java/it/serverSystem/HttpHeadersTest.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/it/it-tests/src/test/java/it/serverSystem/HttpHeadersTest.java b/it/it-tests/src/test/java/it/serverSystem/HttpHeadersTest.java index 1d11d0d896a..12fccdb9ed7 100644 --- a/it/it-tests/src/test/java/it/serverSystem/HttpHeadersTest.java +++ b/it/it-tests/src/test/java/it/serverSystem/HttpHeadersTest.java @@ -24,14 +24,13 @@ import it.Category4Suite; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Optional; import okhttp3.CacheControl; import okhttp3.Response; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; +import static com.google.common.io.Files.getFileExtension; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.call; @@ -150,11 +149,11 @@ public class HttpHeadersTest { */ private static String getJsHash() throws IOException { File cssFolder = new File(orchestrator.getServer().getHome(), "web/css"); - Optional<Path> cssPath = Files.list(cssFolder.toPath()).map(Path::getFileName).findFirst(); - if (cssPath.isPresent()) { - String fileName = cssPath.get().toFile().getName(); - return fileName.replace("sonar.", "").replace(".css", ""); - } - throw new IllegalStateException("sonar.css hasn't been found"); + String fileName = Files.list(cssFolder.toPath()) + .map(path -> path.toFile().getName()) + .filter(name -> getFileExtension(name).equals("css")) + .findFirst() + .orElseThrow(() -> new IllegalStateException("sonar.css hasn't been found")); + return fileName.replace("sonar.", "").replace(".css", ""); } } |