|
| 1 | +package org.utplsql.api.reporter; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.AfterAll; |
| 4 | +import org.junit.jupiter.api.Test; |
| 5 | +import static org.junit.jupiter.api.Assertions.*; |
| 6 | + |
| 7 | +import java.io.File; |
| 8 | +import java.io.IOException; |
| 9 | +import java.nio.file.Files; |
| 10 | +import java.nio.file.Path; |
| 11 | +import java.nio.file.Paths; |
| 12 | + |
| 13 | +public class CoverageHTMLReporterAssetTest { |
| 14 | + |
| 15 | + private static final String TEST_FOLDER = "__testAssets"; |
| 16 | + |
| 17 | + private void testFileExists( Path filePath ) |
| 18 | + { |
| 19 | + File f = new File( filePath.toUri() ); |
| 20 | + |
| 21 | + assertTrue(f.exists(), () -> "File " + f.toString() + " does not exist"); |
| 22 | + } |
| 23 | + |
| 24 | + @Test |
| 25 | + public void writeReporterAssetsTo() |
| 26 | + { |
| 27 | + try { |
| 28 | + Path targetPath = Paths.get(TEST_FOLDER); |
| 29 | + |
| 30 | + // Act |
| 31 | + CoverageHTMLReporter.writeReportAssetsTo(targetPath); |
| 32 | + |
| 33 | + testFileExists(targetPath.resolve(Paths.get("colorbox", "border.png"))); |
| 34 | + testFileExists(targetPath.resolve(Paths.get("colorbox", "controls.png"))); |
| 35 | + testFileExists(targetPath.resolve(Paths.get("colorbox", "loading.gif"))); |
| 36 | + testFileExists(targetPath.resolve(Paths.get("colorbox", "loading_background.png"))); |
| 37 | + |
| 38 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_0_aaaaaa_40x100.png"))); |
| 39 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_75_ffffff_40x100.png"))); |
| 40 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_55_fbf9ee_1x400.png"))); |
| 41 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_65_ffffff_1x400.png"))); |
| 42 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_dadada_1x400.png"))); |
| 43 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_e6e6e6_1x400.png"))); |
| 44 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_95_fef1ec_1x400.png"))); |
| 45 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_highlight-soft_75_cccccc_1x100.png"))); |
| 46 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_2e83ff_256x240.png"))); |
| 47 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_222222_256x240.png"))); |
| 48 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_454545_256x240.png"))); |
| 49 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_888888_256x240.png"))); |
| 50 | + testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_cd0a0a_256x240.png"))); |
| 51 | + |
| 52 | + testFileExists(targetPath.resolve(Paths.get("application.css"))); |
| 53 | + testFileExists(targetPath.resolve(Paths.get("application.js"))); |
| 54 | + testFileExists(targetPath.resolve(Paths.get("favicon_green.png"))); |
| 55 | + testFileExists(targetPath.resolve(Paths.get("favicon_red.png"))); |
| 56 | + testFileExists(targetPath.resolve(Paths.get("favicon_yellow.png"))); |
| 57 | + testFileExists(targetPath.resolve(Paths.get("loading.gif"))); |
| 58 | + testFileExists(targetPath.resolve(Paths.get("magnify.png"))); |
| 59 | + } |
| 60 | + catch ( IOException e ) |
| 61 | + { |
| 62 | + fail(e.getMessage()); |
| 63 | + } |
| 64 | + |
| 65 | + } |
| 66 | + |
| 67 | + @AfterAll |
| 68 | + public static void clearTestAssetsFolder() { |
| 69 | + try { |
| 70 | + Files.deleteIfExists(Paths.get(TEST_FOLDER)); |
| 71 | + } catch (IOException e) { |
| 72 | + e.printStackTrace(); |
| 73 | + } |
| 74 | + } |
| 75 | +} |
0 commit comments