From: Julien Lancelot Date: Wed, 14 Jun 2017 14:08:15 +0000 (+0200) Subject: Improve the way web hash is retrieved X-Git-Tag: 6.5-M1~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ded91a06f0646a7a8bd13a9010d8305b8050e3f7;p=sonarqube.git Improve the way web hash is retrieved --- 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 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", ""); } }