Skip to content

Commit

Permalink
fix unit
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Mar 8, 2024
1 parent 46e4625 commit 2faf022
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,11 +17,13 @@
import java.util.stream.IntStream;

@Slf4j
@RequiredArgsConstructor
public class Generator {
public File root = new File("target/features");
public List<File> paths = new LinkedList<>();
public List<File> features = new LinkedList<>();
public int qtdFeatures = 1000;
public final File root;
public final List<File> paths = new LinkedList<>();
public final List<File> features = new LinkedList<>();
public final int qtdFeatures = 1000;
public final int qtdMaxCenario = 15;

public void build(){
AtomicInteger progress = new AtomicInteger(1);
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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());
Expand Down

0 comments on commit 2faf022

Please sign in to comment.