diff --git a/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/CompilerTest.java b/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/CompilerTest.java index 0c684be..8232ea8 100644 --- a/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/CompilerTest.java +++ b/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/CompilerTest.java @@ -129,8 +129,8 @@ public void getOutArtifact( String target, String expected ) throws IOException { - File targetDir = new File("target/feature"); - if(!targetDir.exists()) assertTrue(targetDir.mkdir()); + File targetDir = new File("target/CompilerTest/feature"); + if(!targetDir.exists()) assertTrue(targetDir.mkdirs()); File targetFile = new File(targetDir, "xxx.Feature"); if(!targetFile.exists()) FileUtils.writeStringToFile(targetFile, ""); diff --git a/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompilerTest.java b/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompilerTest.java index a09cdfd..0af8e5b 100644 --- a/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompilerTest.java +++ b/core/src/test/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompilerTest.java @@ -113,7 +113,9 @@ public void buildMenu() throws IOException { log.info("{}", sw); } - Assertions.assertThat(sw.toString()).contains("var menu = {};"); + Assertions.assertThat(sw.toString()) + .contains("let menuIdx = 0;") + .contains("createMenuItem"); } @Test diff --git a/core/src/test/java/com/github/clagomess/pirilampo/core/generator/Generator.java b/core/src/test/java/com/github/clagomess/pirilampo/core/generator/Generator.java index 4eaa11a..7fa1a11 100644 --- a/core/src/test/java/com/github/clagomess/pirilampo/core/generator/Generator.java +++ b/core/src/test/java/com/github/clagomess/pirilampo/core/generator/Generator.java @@ -1,5 +1,6 @@ package com.github.clagomess.pirilampo.core.generator; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.coobird.thumbnailator.Thumbnails; import net.coobird.thumbnailator.geometry.Positions; @@ -16,11 +17,13 @@ import java.util.stream.IntStream; @Slf4j +@RequiredArgsConstructor public class Generator { - public File root = new File("target/features"); - public List paths = new LinkedList<>(); - public List features = new LinkedList<>(); - public int qtdFeatures = 1000; + public final File root; + public final List paths = new LinkedList<>(); + public final List features = new LinkedList<>(); + public final int qtdFeatures = 1000; + public final int qtdMaxCenario = 15; public void build(){ AtomicInteger progress = new AtomicInteger(1); @@ -95,7 +98,7 @@ public void genFeature(PrintWriter out, File path){ out.println(" Dado " + genWords((int) Math.ceil(Math.random() * 45))); out.println(""); - int qtdCenario = (int) Math.ceil(Math.random() * 15); + int qtdCenario = (int) Math.ceil(Math.random() * qtdMaxCenario); IntStream.rangeClosed(1, qtdCenario).forEach(i -> genCenario(out, path)); } diff --git a/core/src/test/java/com/github/clagomess/pirilampo/core/generator/GeneratorTest.java b/core/src/test/java/com/github/clagomess/pirilampo/core/generator/GeneratorTest.java index 969ff0b..803332d 100644 --- a/core/src/test/java/com/github/clagomess/pirilampo/core/generator/GeneratorTest.java +++ b/core/src/test/java/com/github/clagomess/pirilampo/core/generator/GeneratorTest.java @@ -1,21 +1,34 @@ package com.github.clagomess.pirilampo.core.generator; import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.assertTrue; @Slf4j public class GeneratorTest { - private final Generator generator = new Generator(); - private final File path = new File("target"); + private final File path = new File("target/GeneratorTest"); + private final Generator generator = new Generator(path); public void build(){ generator.build(); } + @BeforeEach + public void setup(){ + if(!path.isDirectory()){ + assertTrue(path.mkdir()); + }else{ + Arrays.stream(path.listFiles()).forEach(File::delete); + } + } + @Test public void getPath(){ log.info("{}", generator.getPath());