Skip to content

Commit

Permalink
feat: navigator template does not need to be downloaded
Browse files Browse the repository at this point in the history
more convenient, templates are small, possibility do add your own template view env may come later if people want that
  • Loading branch information
globalworming committed Oct 26, 2020
1 parent 17f0837 commit 3af9f01
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Oct 26 08:51:03 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ class GenerateReport(
}

override fun generateReport(): Path {
val userDir = EnvironmentSpecificConfiguration.from(environmentVariables)
.getProperty("user.dir")
val tmpDir = Files.createTempDirectory("serenity")
val templateArchive: Path = findTemplateArchive(listOf(userDir, "$userDir/src/test/resources"))
extract(templateArchive, tmpDir)
extractArchive(tmpDir)
fillTemplateAndWriteToReportDirectory(tmpDir)
copyAllOtherNavigatorResources(tmpDir)
if (!tmpDir.toFile().deleteRecursively()) {
Expand Down Expand Up @@ -114,12 +111,12 @@ class GenerateReport(
writer.close()
}

private fun extract(targGzArchive: Path, outputDir: Path) {
private fun extractArchive(outputDir: Path) {
try {
val i = TarArchiveInputStream(
GzipCompressorInputStream(
BufferedInputStream(
FileInputStream(targGzArchive.toFile()))))
this.javaClass.getResourceAsStream("serenity-report-navigator_v0.2.3.tar.gz"))))

var entry: TarArchiveEntry? = null

Expand Down Expand Up @@ -150,25 +147,6 @@ class GenerateReport(
}
}

private fun findTemplateArchive(searchDirs: List<String>): Path {
val templateArchive: Path

try {
val searchFiles = searchDirs
.map { Files.list(Paths.get(it)).toList() }
.flatten()

templateArchive = searchFiles
.filter { it.fileName.toString().startsWith("serenity-report-navigator_v") }
.first { it.fileName.toString().endsWith(".tar.gz") }

} catch (e: NoSuchElementException) {
throw FileNotFoundException("no 'serenity-report-navigator_vX.X.X.tar.gz' found in " + searchDirs.joinToString(", "))
}
return templateArchive
}


companion object {
val logging: Log = LogFactory.getLog(GenerateReport::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ class WhenGeneratingFromAReportNavigatorTemplate {

private val environmentVariables: EnvironmentVariables = MockEnvironmentVariables()


init {
environmentVariables.setProperty("user.dir", File(ClassLoader.getSystemResource("exampleProject").file).absolutePath)
}

@Nested
inner class AllReports {

Expand Down

0 comments on commit 3af9f01

Please sign in to comment.