diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/Compiler.java b/core/src/main/java/br/com/pirilampo/core/compilers/Compiler.java index 55154d1..2ab71b0 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/Compiler.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/Compiler.java @@ -1,9 +1,9 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.dto.FeatureMetadataDto; -import br.com.pirilampo.core.dto.ParametroDto; -import br.com.pirilampo.core.enums.ArtefatoEnum; -import br.com.pirilampo.core.enums.CompilacaoEnum; +import br.com.pirilampo.core.dto.ParametersDto; +import br.com.pirilampo.core.enums.CompilationArctifactEnum; +import br.com.pirilampo.core.enums.CompilationTypeEnum; import org.apache.commons.io.input.BOMInputStream; import java.io.*; @@ -31,7 +31,7 @@ protected List listFolder(File curDir) throws Exception { private void listFolder(List buffer, File curDir) throws Exception { File[] filesList = curDir.listFiles(); - if(filesList == null) throw new Exception("Pasta não localizada!"); + if(filesList == null) throw new Exception("*.features not found"); for (File f : filesList) { if (f.isDirectory()) listFolder(buffer, f); @@ -42,12 +42,12 @@ private void listFolder(List buffer, File curDir) throws Exception { } } - protected FeatureMetadataDto getFeatureMetadata(ParametroDto parametro, File feature){ + protected FeatureMetadataDto getFeatureMetadata(ParametersDto parameters, File feature){ String htmlFeatureRoot = feature.getAbsolutePath() - .replace(parametro.getTxtSrcFonte().getAbsolutePath(), ""); + .replace(parameters.getProjectSource().getAbsolutePath(), ""); - if(parametro.getTxtSrcFonteMaster() != null){ - htmlFeatureRoot = htmlFeatureRoot.replace(parametro.getTxtSrcFonteMaster().getAbsolutePath(), ""); + if(parameters.getProjectMasterSource() != null){ + htmlFeatureRoot = htmlFeatureRoot.replace(parameters.getProjectMasterSource().getAbsolutePath(), ""); } htmlFeatureRoot = htmlFeatureRoot.replace(feature.getName(), "") @@ -63,27 +63,27 @@ protected FeatureMetadataDto getFeatureMetadata(ParametroDto parametro, File fea return result; } - protected File getOutArtifact(ParametroDto parametro){ - if(parametro.getTipCompilacao() == CompilacaoEnum.PASTA){ - File targetDir = parametro.getTxtOutputTarget() != null ? - new File(parametro.getTxtOutputTarget(), "html") : - new File(parametro.getTxtSrcFonte().getParent(), "html"); + protected File getOutArtifact(ParametersDto parameters){ + if(parameters.getCompilationType() == CompilationTypeEnum.FOLDER){ + File targetDir = parameters.getProjectTarget() != null ? + new File(parameters.getProjectTarget(), "html") : + new File(parameters.getProjectSource().getParent(), "html"); if(!targetDir.exists() && !targetDir.mkdir()){ throw new RuntimeException(String.format("Failed to create dir: %s", targetDir.getAbsolutePath())); } - return new File(targetDir, parametro.getArtefato() == ArtefatoEnum.HTML ? "index.html" : "index.pdf"); + return new File(targetDir, parameters.getCompilationArctifact() == CompilationArctifactEnum.HTML ? "index.html" : "index.pdf"); }else{ String filename = String.format( "%s.%s", - getFeatureMetadata(parametro, parametro.getTxtSrcFonte()).getName(), - parametro.getArtefato() == ArtefatoEnum.HTML ? "html" : "pdf" + getFeatureMetadata(parameters, parameters.getProjectSource()).getName(), + parameters.getCompilationArctifact() == CompilationArctifactEnum.HTML ? "html" : "pdf" ); - File targetDir = parametro.getTxtOutputTarget() != null ? - parametro.getTxtOutputTarget() : - new File(parametro.getTxtSrcFonte().getParent()); + File targetDir = parameters.getProjectTarget() != null ? + parameters.getProjectTarget() : + new File(parameters.getProjectSource().getParent()); return new File(targetDir, filename); } @@ -127,11 +127,11 @@ public String getFeaturePathWithoutAbsolute(File base, File feature){ return resultDiff.replace(File.separator, "/"); } - public File getAbsolutePathFeatureAsset(ParametroDto parametro, File feature, String fileName){ + public File getAbsolutePathFeatureAsset(ParametersDto parameters, File feature, String fileName){ Set basePaths = new LinkedHashSet() {{ add(feature.getParentFile()); - add(parametro.getTxtSrcFonte()); - if(parametro.getTxtSrcFonteMaster() != null) add(parametro.getTxtSrcFonteMaster()); + add(parameters.getProjectSource()); + if(parameters.getProjectMasterSource() != null) add(parameters.getProjectMasterSource()); }}; for (File basePath : basePaths) { diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompiler.java b/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompiler.java index 3c6de88..6fc37ce 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompiler.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompiler.java @@ -1,27 +1,27 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.dto.FeatureMetadataDto; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import java.io.*; import java.nio.charset.StandardCharsets; public class FeatureToHTMLCompiler extends Compiler { - private final ParametroDto parametro; + private final ParametersDto parameters; private final File feature; private final FeatureMetadataDto featureMetadataDto; - public FeatureToHTMLCompiler(ParametroDto parametro) { - this.parametro = parametro; - this.feature = parametro.getTxtSrcFonte(); - this.featureMetadataDto = getFeatureMetadata(parametro, feature); + public FeatureToHTMLCompiler(ParametersDto parameters) { + this.parameters = parameters; + this.feature = parameters.getProjectSource(); + this.featureMetadataDto = getFeatureMetadata(parameters, feature); } public void build() throws Exception { - ParseDocument parseDocument = new ParseDocument(parametro, feature); + ParseDocument parseDocument = new ParseDocument(parameters, feature); try ( - FileOutputStream fos = new FileOutputStream(getOutArtifact(parametro)); + FileOutputStream fos = new FileOutputStream(getOutArtifact(parameters)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); PrintWriter out = new PrintWriter(bw); ){ @@ -29,7 +29,7 @@ public void build() throws Exception { out.print(""); out.print(""); out.print(""); - out.print(String.format("%s", parametro.getTxtNome())); + out.print(String.format("%s", parameters.getProjectName())); out.print(""); @@ -37,9 +37,9 @@ public void build() throws Exception { out.print("
"); out.print(String.format( "

%s %s %s

", - parametro.getTxtNome(), + parameters.getProjectName(), featureMetadataDto.getName(), - parametro.getTxtVersao() + parameters.getProjectVersion() )); parseDocument.build(out); diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToPDFCompiler.java b/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToPDFCompiler.java index 1696109..abbcced 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToPDFCompiler.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/FeatureToPDFCompiler.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.dto.FeatureMetadataDto; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -13,14 +13,14 @@ @Slf4j @RequiredArgsConstructor public class FeatureToPDFCompiler extends Compiler { - private final ParametroDto parametro; + private final ParametersDto parameters; private final File feature; private final FeatureMetadataDto featureMetadataDto; - public FeatureToPDFCompiler(ParametroDto parametro) { - this.parametro = parametro; - this.feature = parametro.getTxtSrcFonte(); - this.featureMetadataDto = getFeatureMetadata(parametro, feature); + public FeatureToPDFCompiler(ParametersDto parameters) { + this.parameters = parameters; + this.feature = parameters.getProjectSource(); + this.featureMetadataDto = getFeatureMetadata(parameters, feature); } public void build() throws Exception { @@ -36,13 +36,13 @@ public void build() throws Exception { out.print("

"); out.print(String.format( "%s %s %s", - parametro.getTxtNome(), + parameters.getProjectName(), featureMetadataDto.getName(), - parametro.getTxtVersao() + parameters.getProjectVersion() )); out.print("

"); - new ParseDocument(parametro, feature).build(out); + new ParseDocument(parameters, feature).build(out); out.print(""); } @@ -50,13 +50,13 @@ public void build() throws Exception { // @TODO: maibe a pipe with these streams? try ( - FileOutputStream fos = new FileOutputStream(getOutArtifact(parametro)); + FileOutputStream fos = new FileOutputStream(getOutArtifact(parameters)); InputStream html = Files.newInputStream(bufferHtml.toPath()); InputStream css = Objects.requireNonNull(Thread.currentThread().getContextClassLoader() .getResource("htmlTemplate/dist/feature-pdf.min.css")) .openStream(); ){ - new ParsePdf().build(fos, html, css, parametro.getTipLayoutPdf()); + new ParsePdf().build(fos, html, css, parameters.getLayoutPdf()); } // @TODO: remove buffer file diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/FolderToHTMLCompiler.java b/core/src/main/java/br/com/pirilampo/core/compilers/FolderToHTMLCompiler.java index 3751aff..c7b8b47 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/FolderToHTMLCompiler.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/FolderToHTMLCompiler.java @@ -3,7 +3,7 @@ import br.com.pirilampo.core.dto.FeatureIndexDto; import br.com.pirilampo.core.dto.FeatureMasterDto; import br.com.pirilampo.core.dto.FeatureMetadataDto; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import br.com.pirilampo.core.enums.DiffEnum; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -23,7 +23,7 @@ @RequiredArgsConstructor public class FolderToHTMLCompiler extends Compiler { private final ParseImage parseImage = new ParseImage(); - private final ParametroDto parametro; + private final ParametersDto parameters; private final Map indice = new HashMap<>(); private List masterFiles = null; @@ -31,41 +31,41 @@ public class FolderToHTMLCompiler extends Compiler { public static final String HTML_CLOSE_TEMPLATE = "\n"; protected DiffEnum diffMaster(FeatureMetadataDto featureMetadataDto, File featureBranch, PrintWriter out) throws Exception { - if(parametro.getTxtSrcFonteMaster() == null) return DiffEnum.NAO_COMPARADO; + if(parameters.getProjectMasterSource() == null) return DiffEnum.NOT_COMPARED; if(masterFiles == null){ - masterFiles = listFolder(parametro.getTxtSrcFonteMaster()).stream() + masterFiles = listFolder(parameters.getProjectMasterSource()).stream() .map(item -> new FeatureMasterDto( - getFeaturePathWithoutAbsolute(parametro.getTxtSrcFonteMaster(), item), + getFeaturePathWithoutAbsolute(parameters.getProjectMasterSource(), item), item )).collect(Collectors.toList()); } - if(masterFiles.isEmpty()) return DiffEnum.NAO_COMPARADO; + if(masterFiles.isEmpty()) return DiffEnum.NOT_COMPARED; - String pathFeatureBranch = getFeaturePathWithoutAbsolute(parametro.getTxtSrcFonte(), featureBranch); + String pathFeatureBranch = getFeaturePathWithoutAbsolute(parameters.getProjectSource(), featureBranch); Optional optFeatureMaster = masterFiles.stream() .filter(item -> item.getPath().equals(pathFeatureBranch)) .findFirst(); - DiffEnum diff = DiffEnum.NOVO; + DiffEnum diff = DiffEnum.NEW; if(optFeatureMaster.isPresent()) { if (FileUtils.contentEquals(featureBranch, optFeatureMaster.get().getFeature())) { - diff = DiffEnum.IGUAL; + diff = DiffEnum.EQUAL; } else { - diff = DiffEnum.DIFERENTE; + diff = DiffEnum.DIFFERENT; } } log.info("Diff Master/Branch: {} - {}", diff, featureBranch.getAbsolutePath()); // pula para o proximo - if(diff.equals(DiffEnum.IGUAL)) return diff; + if(diff.equals(DiffEnum.EQUAL)) return diff; if(optFeatureMaster.isPresent()) { out.print(String.format(HTML_OPEN_TEMPLATE, "master_" + featureMetadataDto.getIdHtml())); - new ParseDocument(parametro, optFeatureMaster.get().getFeature()).build(out); + new ParseDocument(parameters, optFeatureMaster.get().getFeature()).build(out); out.print(HTML_CLOSE_TEMPLATE); out.print(String.format(HTML_OPEN_TEMPLATE, "master_" + featureMetadataDto.getIdFeature())); @@ -85,14 +85,14 @@ protected void buildMenu(PrintWriter out){ out.print("
    "); out.print("
  • "); - if(parametro.getTxtLogoSrc() != null){ - String logoString = parseImage.parse(parametro, parametro.getTxtLogoSrc()); //@TODO: transformar em buffer + if(parameters.getProjectLogo() != null){ + String logoString = parseImage.parse(parameters, parameters.getProjectLogo()); //@TODO: transformar em buffer out.print(String.format("", logoString)); }else{ out.print(String.format( "%s %s", - parametro.getTxtNome(), - parametro.getTxtVersao() + parameters.getProjectName(), + parameters.getProjectVersion() )); } @@ -105,8 +105,8 @@ protected void buildMenu(PrintWriter out){ protected void buildTemplateIndex(PrintWriter out){ out.print(String.format(HTML_OPEN_TEMPLATE, "index.html")); out.print("
    "); - out.print(String.format("

    %s

    ", parametro.getTxtNome())); - out.print(String.format("%s", parametro.getTxtVersao())); + out.print(String.format("

    %s

    ", parameters.getProjectName())); + out.print(String.format("%s", parameters.getProjectVersion())); out.print("
    "); out.print(HTML_CLOSE_TEMPLATE); } @@ -118,14 +118,13 @@ protected void buildIndex(PrintWriter out) throws JsonProcessingException { } public void build() throws Exception { - ParseMenu parseMenu = new ParseMenu(parametro); + ParseMenu parseMenu = new ParseMenu(parameters); - // Popula com arquivos feature - final List arquivos = listFolder(parametro.getTxtSrcFonte()); + final List arquivos = listFolder(parameters.getProjectSource()); if(arquivos.isEmpty()) return; try ( - FileOutputStream fos = new FileOutputStream(getOutArtifact(parametro)); + FileOutputStream fos = new FileOutputStream(getOutArtifact(parameters)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8)); PrintWriter out = new PrintWriter(bw); ){ @@ -133,26 +132,26 @@ public void build() throws Exception { out.print(""); out.print(""); out.print(""); - out.print(String.format("%s", parametro.getTxtNome())); + out.print(String.format("%s", parameters.getProjectName())); out.print(""); out.print("\n"); @@ -169,14 +168,14 @@ public void build() throws Exception { progressNum++; // monta nome menu - FeatureMetadataDto featureMetadataDto = getFeatureMetadata(parametro, f); + FeatureMetadataDto featureMetadataDto = getFeatureMetadata(parameters, f); // Processa Diff Master DiffEnum diff = diffMaster(featureMetadataDto, f, out); - if(diff == DiffEnum.IGUAL) continue; + if(diff == DiffEnum.EQUAL) continue; // Gera a feture - ParseDocument pd = new ParseDocument(parametro, f); + ParseDocument pd = new ParseDocument(parameters, f); out.print(String.format(HTML_OPEN_TEMPLATE, featureMetadataDto.getIdHtml())); pd.build(out); out.print(HTML_CLOSE_TEMPLATE); diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/FolderToPDFCompiler.java b/core/src/main/java/br/com/pirilampo/core/compilers/FolderToPDFCompiler.java index fcfdc55..43b59bf 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/FolderToPDFCompiler.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/FolderToPDFCompiler.java @@ -1,6 +1,6 @@ package br.com.pirilampo.core.compilers; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -13,10 +13,10 @@ @Slf4j @RequiredArgsConstructor public class FolderToPDFCompiler extends Compiler { - private final ParametroDto parametro; + private final ParametersDto parameters; public void build() throws Exception { - List arquivos = listFolder(parametro.getTxtSrcFonte()); + List arquivos = listFolder(parameters.getProjectSource()); if(arquivos.isEmpty()) return; File bufferHtml = File.createTempFile("pirilampo-buffer-", ".html"); @@ -33,13 +33,13 @@ public void build() throws Exception { out.print("

    "); out.print(String.format( "%s %s %s", - parametro.getTxtNome(), - getFeatureMetadata(parametro, feature).getName(), - parametro.getTxtVersao() + parameters.getProjectName(), + getFeatureMetadata(parameters, feature).getName(), + parameters.getProjectVersion() )); out.print("

    "); - new ParseDocument(parametro, feature).build(out); + new ParseDocument(parameters, feature).build(out); out.print(""); } @@ -50,13 +50,13 @@ public void build() throws Exception { // @TODO: maibe a pipe with these streams? try ( - FileOutputStream fos = new FileOutputStream(getOutArtifact(parametro)); + FileOutputStream fos = new FileOutputStream(getOutArtifact(parameters)); InputStream html = Files.newInputStream(bufferHtml.toPath()); InputStream css = Objects.requireNonNull(Thread.currentThread().getContextClassLoader() .getResource("htmlTemplate/dist/feature-pdf.min.css")) .openStream(); ){ - new ParsePdf().build(fos, html, css, parametro.getTipLayoutPdf()); + new ParsePdf().build(fos, html, css, parameters.getLayoutPdf()); } // @TODO: remove buffer file diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/ParseDocument.java b/core/src/main/java/br/com/pirilampo/core/compilers/ParseDocument.java index bbdf075..1bee4f2 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/ParseDocument.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/ParseDocument.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; -import br.com.pirilampo.core.dto.ParametroDto; -import br.com.pirilampo.core.enums.PainelEnum; +import br.com.pirilampo.core.dto.ParametersDto; +import br.com.pirilampo.core.enums.HtmlPanelToggleEnum; import br.com.pirilampo.core.exception.FeatureException; import gherkin.AstBuilder; import gherkin.Parser; @@ -26,7 +26,7 @@ class ParseDocument extends Compiler { private final ParseImage parseImage = new ParseImage(); private final ParseToMarkdown parseToMarkdown = new ParseToMarkdown(); - private final ParametroDto parametro; + private final ParametersDto parameters; private final File feature; @Getter @@ -60,8 +60,8 @@ class ParseDocument extends Compiler { private static final String HTML_CHILDREN_TABLE_TH = "%s\n"; private static final String HTML_CHILDREN_TABLE_TD = "%s\n"; - public ParseDocument(ParametroDto parametro, File feature){ - this.parametro = parametro; + public ParseDocument(ParametersDto parameters, File feature){ + this.parameters = parameters; this.feature = feature; this.paginaHtmlAnexo = new ArrayList<>(); } @@ -185,7 +185,7 @@ private void build(GherkinDocument gd, PrintWriter out){ StringEscapeUtils.escapeHtml(StringUtils.isBlank(sd.getName()) ? sd.getKeyword() : sd.getName()) )); - if (parametro.getTipPainel() == PainelEnum.FECHADO) { + if (parameters.getHtmlPanelToggle() == HtmlPanelToggleEnum.CLOSED) { out.print(String.format(HTML_OPEN_CHILDREN_BODY_CLOSED, scenarioIdx)); }else{ out.print(String.format(HTML_OPEN_CHILDREN_BODY, scenarioIdx)); @@ -243,7 +243,7 @@ protected String format(String txtRaw, boolean makdown){ // pega endereço ou base64 da imagem Matcher mImgSrc = Pattern.compile("src=\"(.+?)\"").matcher(txt); while (mImgSrc.find()) { - String imgSrc = parseImage.parse(parametro, feature, mImgSrc.group(1)); + String imgSrc = parseImage.parse(parameters, feature, mImgSrc.group(1)); txt = txt.replace(mImgSrc.group(), "src=\"" + imgSrc + "\""); } @@ -251,7 +251,7 @@ protected String format(String txtRaw, boolean makdown){ Matcher mHtmlHref = Pattern.compile("href=\"(.+?\\.html)\"").matcher(txt); while(mHtmlHref.find()) { String filename = mHtmlHref.group(1); - File htmlEmbed = getAbsolutePathFeatureAsset(parametro, feature, filename); + File htmlEmbed = getAbsolutePathFeatureAsset(parameters, feature, filename); if (htmlEmbed != null && htmlEmbed.isFile()) { paginaHtmlAnexo.add(htmlEmbed); diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/ParseImage.java b/core/src/main/java/br/com/pirilampo/core/compilers/ParseImage.java index 8996be3..0bad2d6 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/ParseImage.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/ParseImage.java @@ -1,8 +1,8 @@ package br.com.pirilampo.core.compilers; -import br.com.pirilampo.core.dto.ParametroDto; -import br.com.pirilampo.core.enums.ArtefatoEnum; +import br.com.pirilampo.core.dto.ParametersDto; +import br.com.pirilampo.core.enums.CompilationArctifactEnum; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; @@ -14,21 +14,21 @@ @Slf4j class ParseImage extends Compiler { - public String parse(ParametroDto parametro, File feature, String fileName){ - File file = getAbsolutePathFeatureAsset(parametro, feature, fileName); + public String parse(ParametersDto parameters, File feature, String fileName){ + File file = getAbsolutePathFeatureAsset(parameters, feature, fileName); if(file != null){ - return parse(parametro, file); + return parse(parameters, file); }else{ return fileName; } } - public String parse(ParametroDto parametro, File image){ + public String parse(ParametersDto parameters, File image){ if( - parametro.getSitEmbedarImagens() || - image.equals(parametro.getTxtLogoSrc()) || - parametro.getArtefato() == ArtefatoEnum.PDF + parameters.getEmbedImages() || + image.equals(parameters.getProjectLogo()) || + parameters.getCompilationArctifact() == CompilationArctifactEnum.PDF ) { try { String base64 = Base64.getEncoder().encodeToString(FileUtils.readFileToByteArray(image)); @@ -41,7 +41,7 @@ public String parse(ParametroDto parametro, File image){ log.info(e.getMessage() + " - " + image.getAbsolutePath()); } } else { - return "../" + getFeaturePathWithoutAbsolute(parametro.getTxtSrcFonte().getParentFile(), image); + return "../" + getFeaturePathWithoutAbsolute(parameters.getProjectSource().getParentFile(), image); } return image.getName(); diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/ParseMenu.java b/core/src/main/java/br/com/pirilampo/core/compilers/ParseMenu.java index 15b0d21..d5156fc 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/ParseMenu.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/ParseMenu.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.dto.MenuDto; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import br.com.pirilampo.core.enums.DiffEnum; import lombok.Getter; @@ -12,21 +12,21 @@ public class ParseMenu extends Compiler { @Getter private final MenuDto menu; - private final ParametroDto parametro; + private final ParametersDto parameters; - public ParseMenu(ParametroDto parametro){ + public ParseMenu(ParametersDto parameters){ this.menu = new MenuDto("ROOT"); - this.parametro = parametro; + this.parameters = parameters; } public void addMenuItem(File feature, DiffEnum diff, String featureTitulo){ MenuDto item = new MenuDto( featureTitulo, - getFeatureMetadata(parametro, feature).getId(), + getFeatureMetadata(parameters, feature).getId(), diff ); - String[] nodes = getFeaturePathWithoutAbsolute(parametro.getTxtSrcFonte(), feature).split("(\\\\|/)"); + String[] nodes = getFeaturePathWithoutAbsolute(parameters.getProjectSource(), feature).split("(\\\\|/)"); walker(menu.getChildren(), nodes, 0, item); } diff --git a/core/src/main/java/br/com/pirilampo/core/compilers/ParsePdf.java b/core/src/main/java/br/com/pirilampo/core/compilers/ParsePdf.java index a9bf82c..a2a9c4f 100644 --- a/core/src/main/java/br/com/pirilampo/core/compilers/ParsePdf.java +++ b/core/src/main/java/br/com/pirilampo/core/compilers/ParsePdf.java @@ -56,7 +56,7 @@ public void build( InputStream css, LayoutPdfEnum layout ) throws Exception { - Document document = new Document(layout == LayoutPdfEnum.RETRATO ? + Document document = new Document(layout == LayoutPdfEnum.PORTRAIT ? PageSize.A4 : PageSize.A4.rotate() ); @@ -105,7 +105,7 @@ public void onEndPage(PdfWriter writer, Document document) { ColumnText.showTextAligned( writer.getDirectContentUnder(), Element.ALIGN_CENTER, - new Phrase("Página " + writer.getPageNumber()), + new Phrase("Page " + writer.getPageNumber()), writer.getPageSize().getWidth() - 70, 20, 0 ); } diff --git a/core/src/main/java/br/com/pirilampo/core/dto/MenuDto.java b/core/src/main/java/br/com/pirilampo/core/dto/MenuDto.java index f57f5b7..d580733 100644 --- a/core/src/main/java/br/com/pirilampo/core/dto/MenuDto.java +++ b/core/src/main/java/br/com/pirilampo/core/dto/MenuDto.java @@ -16,7 +16,7 @@ public class MenuDto implements Comparable { public MenuDto(String title){ this.title = title; this.url = null; - this.diff = DiffEnum.NAO_COMPARADO; + this.diff = DiffEnum.NOT_COMPARED; } public MenuDto(String title, String url, DiffEnum diff) { diff --git a/core/src/main/java/br/com/pirilampo/core/dto/ParametroDto.java b/core/src/main/java/br/com/pirilampo/core/dto/ParametersDto.java similarity index 76% rename from core/src/main/java/br/com/pirilampo/core/dto/ParametroDto.java rename to core/src/main/java/br/com/pirilampo/core/dto/ParametersDto.java index 3190fbd..640da31 100644 --- a/core/src/main/java/br/com/pirilampo/core/dto/ParametroDto.java +++ b/core/src/main/java/br/com/pirilampo/core/dto/ParametersDto.java @@ -1,9 +1,9 @@ package br.com.pirilampo.core.dto; -import br.com.pirilampo.core.enums.ArtefatoEnum; -import br.com.pirilampo.core.enums.CompilacaoEnum; +import br.com.pirilampo.core.enums.CompilationArctifactEnum; +import br.com.pirilampo.core.enums.CompilationTypeEnum; +import br.com.pirilampo.core.enums.HtmlPanelToggleEnum; import br.com.pirilampo.core.enums.LayoutPdfEnum; -import br.com.pirilampo.core.enums.PainelEnum; import javafx.scene.paint.Color; import lombok.Data; import lombok.NoArgsConstructor; @@ -12,22 +12,22 @@ import java.io.File; import java.util.Properties; -@NoArgsConstructor @Data -public class ParametroDto { - private String txtNome = "Pirilampo"; - private String txtVersao = "1.0"; - private File txtLogoSrc; - private LayoutPdfEnum tipLayoutPdf = LayoutPdfEnum.RETRATO; - private PainelEnum tipPainel = PainelEnum.ABERTO; - private String clrMenu = "#14171A"; - private String clrTextoMenu = "#DDDDDD"; - private Boolean sitEmbedarImagens = true; - private CompilacaoEnum tipCompilacao = CompilacaoEnum.PASTA; - private ArtefatoEnum artefato = ArtefatoEnum.HTML; - private File txtSrcFonte; - private File txtSrcFonteMaster; - private File txtOutputTarget; +@NoArgsConstructor +public class ParametersDto { + private String projectName = "Pirilampo"; + private String projectVersion = "1.0"; + private File projectLogo; + private LayoutPdfEnum layoutPdf = LayoutPdfEnum.PORTRAIT; + private HtmlPanelToggleEnum htmlPanelToggle = HtmlPanelToggleEnum.OPEN; + private String menuColor = "#14171A"; + private String menuTextColor = "#DDDDDD"; + private Boolean embedImages = true; + private CompilationTypeEnum compilationType = CompilationTypeEnum.FOLDER; + private CompilationArctifactEnum compilationArctifact = CompilationArctifactEnum.HTML; + private File projectSource; + private File projectMasterSource; + private File projectTarget; // public ParametroDto(MainForm form){ /* @@ -45,7 +45,7 @@ public class ParametroDto { */ // } - public ParametroDto(CommandLine cmd){ + public ParametersDto(CommandLine cmd){ /* this.txtNome = cmd.getOptionValue("name"); this.txtVersao = cmd.getOptionValue("version"); @@ -56,7 +56,7 @@ public ParametroDto(CommandLine cmd){ */ } - public ParametroDto(Properties properties){ + public ParametersDto(Properties properties){ /* this.txtNome = !StringUtils.isEmpty(properties.getProperty("txtNome")) ? properties.getProperty("txtNome") : this.txtNome; this.txtVersao = !StringUtils.isEmpty(properties.getProperty("txtVersao")) ? properties.getProperty("txtVersao") : this.txtVersao; diff --git a/core/src/main/java/br/com/pirilampo/core/enums/PainelEnum.java b/core/src/main/java/br/com/pirilampo/core/enums/CompilationArctifactEnum.java similarity index 60% rename from core/src/main/java/br/com/pirilampo/core/enums/PainelEnum.java rename to core/src/main/java/br/com/pirilampo/core/enums/CompilationArctifactEnum.java index 776543e..8fbc43e 100644 --- a/core/src/main/java/br/com/pirilampo/core/enums/PainelEnum.java +++ b/core/src/main/java/br/com/pirilampo/core/enums/CompilationArctifactEnum.java @@ -5,8 +5,7 @@ @Getter @RequiredArgsConstructor -public enum PainelEnum { - FECHADO("F"), ABERTO("A"); - - private final String value; +public enum CompilationArctifactEnum { + HTML, + PDF } diff --git a/core/src/main/java/br/com/pirilampo/core/enums/ArtefatoEnum.java b/core/src/main/java/br/com/pirilampo/core/enums/CompilationTypeEnum.java similarity index 60% rename from core/src/main/java/br/com/pirilampo/core/enums/ArtefatoEnum.java rename to core/src/main/java/br/com/pirilampo/core/enums/CompilationTypeEnum.java index 64004ff..2db0781 100644 --- a/core/src/main/java/br/com/pirilampo/core/enums/ArtefatoEnum.java +++ b/core/src/main/java/br/com/pirilampo/core/enums/CompilationTypeEnum.java @@ -5,8 +5,8 @@ @Getter @RequiredArgsConstructor -public enum ArtefatoEnum { - HTML("HTML"), PDF("PDF"); - - private final String value; +public enum CompilationTypeEnum { + FOLDER, + FOLDER_DIFF, + FEATURE, } diff --git a/core/src/main/java/br/com/pirilampo/core/enums/DiffEnum.java b/core/src/main/java/br/com/pirilampo/core/enums/DiffEnum.java index c1b9985..4980c0b 100644 --- a/core/src/main/java/br/com/pirilampo/core/enums/DiffEnum.java +++ b/core/src/main/java/br/com/pirilampo/core/enums/DiffEnum.java @@ -6,10 +6,8 @@ @Getter @RequiredArgsConstructor public enum DiffEnum { - NAO_COMPARADO(0), - IGUAL(1), - DIFERENTE(2), - NOVO(3); - - private final Integer value; + NOT_COMPARED, + EQUAL, + DIFFERENT, + NEW, } diff --git a/core/src/main/java/br/com/pirilampo/core/enums/CompilacaoEnum.java b/core/src/main/java/br/com/pirilampo/core/enums/HtmlPanelToggleEnum.java similarity index 53% rename from core/src/main/java/br/com/pirilampo/core/enums/CompilacaoEnum.java rename to core/src/main/java/br/com/pirilampo/core/enums/HtmlPanelToggleEnum.java index fe2cfcc..609be67 100644 --- a/core/src/main/java/br/com/pirilampo/core/enums/CompilacaoEnum.java +++ b/core/src/main/java/br/com/pirilampo/core/enums/HtmlPanelToggleEnum.java @@ -5,8 +5,7 @@ @Getter @RequiredArgsConstructor -public enum CompilacaoEnum { - PASTA("PASTA"), FEATURE("FEATURE"), DIFF("DIFF"); - - private final String value; +public enum HtmlPanelToggleEnum { + CLOSED, + OPEN, } diff --git a/core/src/main/java/br/com/pirilampo/core/enums/LayoutPdfEnum.java b/core/src/main/java/br/com/pirilampo/core/enums/LayoutPdfEnum.java index b3e02cd..81fc530 100644 --- a/core/src/main/java/br/com/pirilampo/core/enums/LayoutPdfEnum.java +++ b/core/src/main/java/br/com/pirilampo/core/enums/LayoutPdfEnum.java @@ -6,7 +6,6 @@ @Getter @RequiredArgsConstructor public enum LayoutPdfEnum { - RETRATO("R"), PAISAGEM("P"); - - private final String value; + PORTRAIT, + LANDSCAPE, } diff --git a/core/src/main/java/br/com/pirilampo/core/util/PropertiesUtil.java b/core/src/main/java/br/com/pirilampo/core/util/PropertiesUtil.java index 0ddef24..21e533e 100644 --- a/core/src/main/java/br/com/pirilampo/core/util/PropertiesUtil.java +++ b/core/src/main/java/br/com/pirilampo/core/util/PropertiesUtil.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.util; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import lombok.extern.slf4j.Slf4j; import java.io.*; @@ -11,7 +11,7 @@ public class PropertiesUtil { private static final String FILENAME = "/../html/config.properties"; - public static ParametroDto getData(String sourcePath){ + public static ParametersDto getData(String sourcePath){ Properties prop = new Properties(); InputStream input = null; @@ -33,11 +33,11 @@ public static ParametroDto getData(String sourcePath){ } } - return new ParametroDto(prop); + return new ParametersDto(prop); } - public static void setData(ParametroDto parametro){ - File file = new File(parametro.getTxtSrcFonte() + FILENAME); + public static void setData(ParametersDto parameters){ + File file = new File(parameters.getProjectSource() + FILENAME); if(!file.isFile()){ try { @@ -49,24 +49,24 @@ public static void setData(ParametroDto parametro){ } } - try (OutputStream output = new FileOutputStream(parametro.getTxtSrcFonte() + FILENAME)){ - Properties prop = parametroToProperties(parametro); + try (OutputStream output = new FileOutputStream(parameters.getProjectSource() + FILENAME)){ + Properties prop = parametroToProperties(parameters); prop.store(output, null); } catch (IOException ex) { log.error(log.getName(), ex); } } - public static Properties parametroToProperties(ParametroDto parametro){ + public static Properties parametroToProperties(ParametersDto parameters){ Properties prop = new Properties(); /* @TODO: check - prop.setProperty("txtNome", parametro.getTxtNome()); - prop.setProperty("txtVersao", parametro.getTxtVersao()); - prop.setProperty("txtLogoSrc", parametro.getTxtLogoSrc() != null ? parametro.getTxtLogoSrc() : ""); - prop.setProperty("clrMenu", parametro.getClrMenu()); - prop.setProperty("clrTextoMenu", parametro.getClrTextoMenu()); - prop.setProperty("sitEmbedarImagens", parametro.getSitEmbedarImagens().toString()); - prop.setProperty("tipPainelFechado", parametro.getTipPainel().toString()); + prop.setProperty("txtNome", parameters.getTxtNome()); + prop.setProperty("txtVersao", parameters.getTxtVersao()); + prop.setProperty("txtLogoSrc", parameters.getTxtLogoSrc() != null ? parameters.getTxtLogoSrc() : ""); + prop.setProperty("clrMenu", parameters.getClrMenu()); + prop.setProperty("clrTextoMenu", parameters.getClrTextoMenu()); + prop.setProperty("sitEmbedarImagens", parameters.getSitEmbedarImagens().toString()); + prop.setProperty("tipPainelFechado", parameters.getTipPainel().toString()); */ return prop; } diff --git a/core/src/test/java/br/com/pirilampo/core/bean/ParametroTest.java b/core/src/test/java/br/com/pirilampo/core/bean/ParametroTest.java index 73415fc..6fdd995 100644 --- a/core/src/test/java/br/com/pirilampo/core/bean/ParametroTest.java +++ b/core/src/test/java/br/com/pirilampo/core/bean/ParametroTest.java @@ -1,6 +1,6 @@ package br.com.pirilampo.core.bean; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import javafx.scene.paint.Color; import org.junit.jupiter.api.Test; @@ -9,8 +9,8 @@ public class ParametroTest { @Test public void colorHex(){ - ParametroDto parametro = new ParametroDto(); + ParametersDto parameters = new ParametersDto(); - assertEquals("#003300", parametro.colorHex(Color.web("#003300"))); + assertEquals("#003300", parameters.colorHex(Color.web("#003300"))); } } diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/CompilerTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/CompilerTest.java index 98bdf4e..58512c8 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/CompilerTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/CompilerTest.java @@ -1,9 +1,9 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.Common; -import br.com.pirilampo.core.dto.ParametroDto; -import br.com.pirilampo.core.enums.ArtefatoEnum; -import br.com.pirilampo.core.enums.CompilacaoEnum; +import br.com.pirilampo.core.dto.ParametersDto; +import br.com.pirilampo.core.enums.CompilationArctifactEnum; +import br.com.pirilampo.core.enums.CompilationTypeEnum; import lombok.extern.slf4j.Slf4j; import lombok.val; import org.apache.commons.io.FileUtils; @@ -62,11 +62,11 @@ public void getFeatureMetadata( .getContextClassLoader() .getResource(feature).getFile()); - ParametroDto parametro = new ParametroDto(); - parametro.setTxtSrcFonte(sourceFile); - parametro.setTxtSrcFonteMaster(sourceMasterFile); + ParametersDto parameters = new ParametersDto(); + parameters.setProjectSource(sourceFile); + parameters.setProjectMasterSource(sourceMasterFile); - val result = compiler.getFeatureMetadata(parametro, featureFile); + val result = compiler.getFeatureMetadata(parameters, featureFile); assertEquals(expectedId, result.getId()); assertEquals(expectedIdHtml, result.getIdHtml()); @@ -124,8 +124,8 @@ public void writeFileToOut() throws IOException { "FEATURE,PDF,target/feature/xxx.Feature,target,target/xxx.pdf", }) public void getOutArtifact( - CompilacaoEnum tipCompilacao, - ArtefatoEnum artefato, + CompilationTypeEnum tipCompilacao, + CompilationArctifactEnum artefato, String source, String target, String expected @@ -136,13 +136,13 @@ public void getOutArtifact( if(!targetFile.exists()) FileUtils.writeStringToFile(targetFile, ""); // init test - ParametroDto parametroDto = new ParametroDto(); - parametroDto.setTipCompilacao(tipCompilacao); - parametroDto.setArtefato(artefato); - parametroDto.setTxtSrcFonte(StringUtils.isNotBlank(source) ? new File(source) : null); - parametroDto.setTxtOutputTarget(StringUtils.isNotBlank(target) ? new File(target) : null); + ParametersDto parametersDto = new ParametersDto(); + parametersDto.setCompilationType(tipCompilacao); + parametersDto.setCompilationArctifact(artefato); + parametersDto.setProjectSource(StringUtils.isNotBlank(source) ? new File(source) : null); + parametersDto.setProjectTarget(StringUtils.isNotBlank(target) ? new File(target) : null); - File result = compiler.getOutArtifact(parametroDto); + File result = compiler.getOutArtifact(parametersDto); log.info("{}", result.getAbsolutePath()); assertEquals(new File(expected).getAbsolutePath(), result.getAbsolutePath()); } @@ -172,12 +172,12 @@ public void getFeaturePathWithoutAbsolute(File base, File feature, String expect @Test public void getAbsolutePathFeatureAsset(){ - ParametroDto parametro = new ParametroDto(); - parametro.setTxtSrcFonte(featureFolder); - parametro.setTxtSrcFonteMaster(featureMasterFolder); + ParametersDto parameters = new ParametersDto(); + parameters.setProjectSource(featureFolder); + parameters.setProjectMasterSource(featureMasterFolder); assertNotNull(compiler.getAbsolutePathFeatureAsset( - parametro, + parameters, featureFile, "xxx.png" )); diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompilerTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompilerTest.java index 72eccbd..35d3f98 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompilerTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToHTMLCompilerTest.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.Common; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; @@ -15,11 +15,11 @@ public void build() throws Exception { File targetFile = new File("target/FeatureToHTMLCompilerTest"); if(!targetFile.isDirectory()) assertTrue(targetFile.mkdir()); - ParametroDto parametro = new ParametroDto(); - parametro.setTxtSrcFonte(featureFile); - parametro.setTxtOutputTarget(targetFile); + ParametersDto parameters = new ParametersDto(); + parameters.setProjectSource(featureFile); + parameters.setProjectTarget(targetFile); - new FeatureToHTMLCompiler(parametro).build(); + new FeatureToHTMLCompiler(parameters).build(); File htmlFile = new File(targetFile, "xxx.html"); assertTrue(htmlFile.isFile()); diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToPDFCompilerTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToPDFCompilerTest.java index 87e54bd..289ea23 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToPDFCompilerTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/FeatureToPDFCompilerTest.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.Common; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.graphics.PDXObject; import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; @@ -20,21 +20,21 @@ public void build() throws Exception { File targetFile = new File("target/FeatureToPDFCompilerTest"); if(!targetFile.isDirectory()) assertTrue(targetFile.mkdir()); - ParametroDto parametro = new ParametroDto(); - parametro.setTxtNome("_AA_"); - parametro.setTxtVersao("_BB_"); - parametro.setTxtSrcFonte(featureFile); - parametro.setTxtOutputTarget(targetFile); + ParametersDto parameters = new ParametersDto(); + parameters.setProjectName("_AA_"); + parameters.setProjectVersion("_BB_"); + parameters.setProjectSource(featureFile); + parameters.setProjectTarget(targetFile); - new FeatureToPDFCompiler(parametro).build(); + new FeatureToPDFCompiler(parameters).build(); File pdfFile = new File(targetFile, "xxx.pdf"); assertTrue(pdfFile.isFile()); try(PDDocument pdfDocument = PDDocument.load(pdfFile)){ String pdfAsStr = new PDFTextStripper().getText(pdfDocument); - assertTrue(pdfAsStr.contains(parametro.getTxtNome())); - assertTrue(pdfAsStr.contains(parametro.getTxtVersao())); + assertTrue(pdfAsStr.contains(parameters.getProjectName())); + assertTrue(pdfAsStr.contains(parameters.getProjectVersion())); boolean possuiImagens = StreamSupport.stream( pdfDocument.getPage(0) diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/FolderToHTMLCompilerTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/FolderToHTMLCompilerTest.java index f35e136..0ec800c 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/FolderToHTMLCompilerTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/FolderToHTMLCompilerTest.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.Common; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; @@ -21,13 +21,13 @@ public void build() throws Exception { File targetFile = new File("target/FolderToHTMLCompilerTest"); if(!targetFile.isDirectory()) assertTrue(targetFile.mkdir()); - ParametroDto parametro = new ParametroDto(); - parametro.setClrMenu("#666"); - parametro.setTxtLogoSrc(logoFile); - parametro.setTxtSrcFonte(featureFolder); - parametro.setTxtOutputTarget(targetFile); + ParametersDto parameters = new ParametersDto(); + parameters.setMenuColor("#666"); + parameters.setProjectLogo(logoFile); + parameters.setProjectSource(featureFolder); + parameters.setProjectTarget(targetFile); - new FolderToHTMLCompiler(parametro).build(); + new FolderToHTMLCompiler(parameters).build(); File htmlFile = new File(targetFile,"html/index.html"); assertTrue(htmlFile.isFile()); @@ -35,8 +35,8 @@ public void build() throws Exception { String htmlString = FileUtils.readFileToString(htmlFile); assertNotEquals(htmlString, ""); - assertTrue(htmlString.contains(parametro.getClrMenu())); - assertFalse(htmlString.contains((new File(String.valueOf(parametro.getTxtLogoSrc()))).getName())); + assertTrue(htmlString.contains(parameters.getMenuColor())); + assertFalse(htmlString.contains((new File(String.valueOf(parameters.getProjectLogo()))).getName())); assertFalse(htmlString.contains("logo_xxx.png")); assertTrue(htmlString.contains("#/html/html_embed.html")); assertTrue(htmlString.contains("html_embed_txt")); @@ -47,11 +47,11 @@ public void build_master() throws Exception { File targetFile = new File("target/FolderToHTMLCompilerTest"); if(!targetFile.isDirectory()) assertTrue(targetFile.mkdir()); - ParametroDto parametro = new ParametroDto(); - parametro.setTxtSrcFonte(featureFolder); - parametro.setTxtSrcFonteMaster(featureMasterFolder); - parametro.setTxtOutputTarget(targetFile); - new FolderToHTMLCompiler(parametro).build(); + ParametersDto parameters = new ParametersDto(); + parameters.setProjectSource(featureFolder); + parameters.setProjectMasterSource(featureMasterFolder); + parameters.setProjectTarget(targetFile); + new FolderToHTMLCompiler(parameters).build(); File htmlFile = new File(targetFile,"html/index.html"); assertTrue(htmlFile.isFile()); diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/FolderToPDFCompilerTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/FolderToPDFCompilerTest.java index 9c809fa..e573c70 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/FolderToPDFCompilerTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/FolderToPDFCompilerTest.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.Common; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.text.PDFTextStripper; import org.junit.jupiter.api.Test; @@ -16,21 +16,21 @@ public void build() throws Exception { File targetFile = new File("target/FolderToPDFCompilerTest"); if(!targetFile.isDirectory()) assertTrue(targetFile.mkdir()); - ParametroDto parametro = new ParametroDto(); - parametro.setTxtNome("_AA_"); - parametro.setTxtVersao("_BB_"); - parametro.setTxtSrcFonte(featureFolder); - parametro.setTxtOutputTarget(targetFile); + ParametersDto parameters = new ParametersDto(); + parameters.setProjectName("_AA_"); + parameters.setProjectVersion("_BB_"); + parameters.setProjectSource(featureFolder); + parameters.setProjectTarget(targetFile); - new FolderToPDFCompiler(parametro).build(); + new FolderToPDFCompiler(parameters).build(); File pdf = new File(targetFile, "html/index.pdf"); assertTrue(pdf.isFile()); PDDocument pdfDocument = PDDocument.load(pdf); String pdfAsStr = new PDFTextStripper().getText(pdfDocument); - assertTrue(pdfAsStr.contains(parametro.getTxtNome())); - assertTrue(pdfAsStr.contains(parametro.getTxtVersao())); + assertTrue(pdfAsStr.contains(parameters.getProjectName())); + assertTrue(pdfAsStr.contains(parameters.getProjectVersion())); pdfDocument.close(); } diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/ParseDocumentTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/ParseDocumentTest.java index ddaaeaa..92b53ae 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/ParseDocumentTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/ParseDocumentTest.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.Common; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import lombok.extern.slf4j.Slf4j; import lombok.val; import org.junit.jupiter.api.Test; @@ -17,9 +17,9 @@ public class ParseDocumentTest extends Common { @Test public void build() throws Exception { - val parametro = new ParametroDto(); - parametro.setTxtSrcFonte(featureFile); - ParseDocument parseDocument = new ParseDocument(parametro, featureFile); + val parameters = new ParametersDto(); + parameters.setProjectSource(featureFile); + ParseDocument parseDocument = new ParseDocument(parameters, featureFile); File tmpFile = File.createTempFile("result-", ".html"); log.info("Created: {}", tmpFile); @@ -49,9 +49,9 @@ public void build() throws Exception { "<user> and <password>$user and password", }, delimiter = '$') public void setIndiceValue(String raw, String expected){ - val parametro = new ParametroDto(); - parametro.setTxtSrcFonte(featureFolder); - ParseDocument parseDocument = new ParseDocument(parametro, featureFile); + val parameters = new ParametersDto(); + parameters.setProjectSource(featureFolder); + ParseDocument parseDocument = new ParseDocument(parameters, featureFile); assertEquals(expected, parseDocument.putIndexValue(raw)); } @@ -79,10 +79,10 @@ public void setIndiceValue(String raw, String expected){ "'aaa \n bbb ![ImageA](xx_a.png)'$'aaa\nbbb

    \"ImageA\"

    '", }, delimiter = '$', ignoreLeadingAndTrailingWhitespace = false) public void format(String raw, String expected){ - val parametro = new ParametroDto(); - parametro.setTxtSrcFonte(featureFolder); + val parameters = new ParametersDto(); + parameters.setProjectSource(featureFolder); - ParseDocument parseDocument = new ParseDocument(parametro, featureFile); + ParseDocument parseDocument = new ParseDocument(parameters, featureFile); assertEquals(expected, parseDocument.format(raw, true)); } diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/ParseImageTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/ParseImageTest.java index 5165894..6244a6d 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/ParseImageTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/ParseImageTest.java @@ -1,7 +1,7 @@ package br.com.pirilampo.core.compilers; import br.com.pirilampo.core.Common; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import lombok.extern.slf4j.Slf4j; import lombok.val; import org.junit.jupiter.params.ParameterizedTest; @@ -23,10 +23,10 @@ public class ParseImageTest extends Common { "false$https://picsum.photos/800/200$https://picsum.photos/800/200", }, delimiter = '$') public void parse(Boolean embedded, String filename, String expected){ - val parametro = new ParametroDto(); - parametro.setSitEmbedarImagens(embedded); - parametro.setTxtSrcFonte(featureFolder); + val parameters = new ParametersDto(); + parameters.setEmbedImages(embedded); + parameters.setProjectSource(featureFolder); - assertEquals(expected, parseImage.parse(parametro, featureFile, filename)); + assertEquals(expected, parseImage.parse(parameters, featureFile, filename)); } } diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/ParseMenuTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/ParseMenuTest.java index 2354091..31ac363 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/ParseMenuTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/ParseMenuTest.java @@ -2,7 +2,7 @@ import br.com.pirilampo.core.Common; import br.com.pirilampo.core.dto.MenuDto; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import br.com.pirilampo.core.enums.DiffEnum; import lombok.extern.slf4j.Slf4j; import org.assertj.core.api.Assertions; @@ -41,13 +41,13 @@ public class ParseMenuTest extends Common { new File("feature/A/A.feature") ); - private final ParametroDto parametro = new ParametroDto(){{ - setTxtSrcFonte(new File("feature")); + private final ParametersDto parameters = new ParametersDto(){{ + setProjectSource(new File("feature")); }}; - private final ParseMenu parseMenu = new ParseMenu(parametro){{ + private final ParseMenu parseMenu = new ParseMenu(parameters){{ for(File item : itens){ - addMenuItem(item, DiffEnum.NAO_COMPARADO, item.getName().replace(".feature", "_x")); + addMenuItem(item, DiffEnum.NOT_COMPARED, item.getName().replace(".feature", "_x")); } }}; diff --git a/core/src/test/java/br/com/pirilampo/core/compilers/ParsePdfTest.java b/core/src/test/java/br/com/pirilampo/core/compilers/ParsePdfTest.java index 22d28f7..0a3cde0 100644 --- a/core/src/test/java/br/com/pirilampo/core/compilers/ParsePdfTest.java +++ b/core/src/test/java/br/com/pirilampo/core/compilers/ParsePdfTest.java @@ -26,7 +26,7 @@ public void build() throws Exception { .getResource("htmlTemplate/dist/feature-pdf.min.css") .openStream(); ){ - new ParsePdf().build(fos, html, css, LayoutPdfEnum.PAISAGEM); + new ParsePdf().build(fos, html, css, LayoutPdfEnum.LANDSCAPE); assertTrue(targetFile.isFile()); } } diff --git a/core/src/test/java/br/com/pirilampo/core/util/PropertiesTest.java b/core/src/test/java/br/com/pirilampo/core/util/PropertiesTest.java index 54057f0..a34840c 100644 --- a/core/src/test/java/br/com/pirilampo/core/util/PropertiesTest.java +++ b/core/src/test/java/br/com/pirilampo/core/util/PropertiesTest.java @@ -1,6 +1,6 @@ package br.com.pirilampo.core.util; -import br.com.pirilampo.core.dto.ParametroDto; +import br.com.pirilampo.core.dto.ParametersDto; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -12,7 +12,7 @@ public class PropertiesTest { @Test public void parametroToProperties(){ - Properties prop = PropertiesUtil.parametroToProperties(new ParametroDto()); + Properties prop = PropertiesUtil.parametroToProperties(new ParametersDto()); assertNotNull(prop.getProperty("txtNome")); }