From 7abf3a221b9f86ba520d06dccf8a7636f360ba63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20Gomes?= Date: Sun, 17 Mar 2024 09:51:25 -0300 Subject: [PATCH] core: logo is a project file --- .../core/compilers/PropertiesCompiler.java | 15 ++------------- .../pirilampo/core/dto/ParametersDto.java | 6 +----- .../core/compilers/FolderToHTMLCompilerTest.java | 6 +----- .../pirilampo/core/dto/ParametersDtoTest.java | 9 --------- .../pirilampo/core/{ => feature}/logo_xxx.png | Bin 5 files changed, 4 insertions(+), 32 deletions(-) rename core/src/test/resources/com/github/clagomess/pirilampo/core/{ => feature}/logo_xxx.png (100%) diff --git a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/PropertiesCompiler.java b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/PropertiesCompiler.java index 9eb6b2f..5b82d20 100644 --- a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/PropertiesCompiler.java +++ b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/PropertiesCompiler.java @@ -6,7 +6,6 @@ import com.github.clagomess.pirilampo.core.enums.HtmlPanelToggleEnum; import com.github.clagomess.pirilampo.core.enums.LayoutPdfEnum; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.IOException; @@ -41,13 +40,7 @@ public void loadData(ParametersDto parameters){ parameters.setProjectName(prop.getProperty("projectName", parameters.getProjectName())); parameters.setProjectVersion(prop.getProperty("projectVersion", parameters.getProjectVersion())); - - if(prop.containsKey("projectLogo")){ - parameters.setProjectLogo(StringUtils.isNotBlank(prop.getProperty("projectLogo")) ? - new File(prop.getProperty("projectLogo")) : - null - ); - } + parameters.setProjectLogo(prop.getProperty("projectLogo", null)); parameters.setLayoutPdf(LayoutPdfEnum.valueOf(prop.getProperty( "layoutPdf", @@ -89,11 +82,7 @@ public void setData(ParametersDto parameters){ Properties prop = new Properties(); prop.setProperty("projectName", parameters.getProjectName()); prop.setProperty("projectVersion", parameters.getProjectVersion()); - prop.setProperty("projectLogo", - parameters.getProjectLogo() != null ? - parameters.getProjectLogo().getAbsolutePath() : - "" - ); + prop.setProperty("projectLogo", String.valueOf(parameters.getProjectLogo())); prop.setProperty("layoutPdf", parameters.getLayoutPdf().name()); prop.setProperty("htmlPanelToggle", parameters.getHtmlPanelToggle().name()); prop.setProperty("menuColor", parameters.getMenuColor()); diff --git a/core/src/main/java/com/github/clagomess/pirilampo/core/dto/ParametersDto.java b/core/src/main/java/com/github/clagomess/pirilampo/core/dto/ParametersDto.java index 0ae4034..d143e61 100644 --- a/core/src/main/java/com/github/clagomess/pirilampo/core/dto/ParametersDto.java +++ b/core/src/main/java/com/github/clagomess/pirilampo/core/dto/ParametersDto.java @@ -19,7 +19,7 @@ public class ParametersDto { private String projectName = "Pirilampo"; private String projectVersion = "1.0"; - private File projectLogo; + private String projectLogo; private LayoutPdfEnum layoutPdf = LayoutPdfEnum.PORTRAIT; private HtmlPanelToggleEnum htmlPanelToggle = HtmlPanelToggleEnum.OPENED; private String menuColor = "#14171A"; @@ -35,10 +35,6 @@ public void validate() throws ParametersException { if(StringUtils.isBlank(projectName)) throw ParametersException.required("Project Name"); if(StringUtils.isBlank(projectVersion)) throw ParametersException.required("Project Version"); - if(projectLogo != null && !projectLogo.isFile()){ //@TODO: can be a project logo - throw new ParametersException("Option must be a valid file"); - } - if(layoutPdf == null) throw ParametersException.required("Layout PDF"); if(htmlPanelToggle == null) throw ParametersException.required("HTML Panel Toggle"); 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 15d28ce..b293869 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 @@ -16,7 +16,6 @@ import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.Objects; import static org.junit.jupiter.api.Assertions.*; @@ -35,12 +34,9 @@ public void setup(){ @Test public void build() throws Exception { - File logoFile = new File(Objects.requireNonNull(getClass() - .getResource("../logo_xxx.png")).getFile()); - ParametersDto parameters = new ParametersDto(); parameters.setMenuColor("#666"); - parameters.setProjectLogo(logoFile); + parameters.setProjectLogo("logo_xxx.png"); parameters.setProjectSource(featureFolder); parameters.setProjectTarget(targetFile); diff --git a/core/src/test/java/com/github/clagomess/pirilampo/core/dto/ParametersDtoTest.java b/core/src/test/java/com/github/clagomess/pirilampo/core/dto/ParametersDtoTest.java index e8abf38..d663482 100644 --- a/core/src/test/java/com/github/clagomess/pirilampo/core/dto/ParametersDtoTest.java +++ b/core/src/test/java/com/github/clagomess/pirilampo/core/dto/ParametersDtoTest.java @@ -36,15 +36,6 @@ public void validate_projectVersion(){ assertThrowsExactly(ParametersException.class, dto::validate); } - @Test - public void validate_projectLogo(){ - val dto = new ParametersDto(); - dto.setProjectSource(featureFolder); - dto.setProjectLogo(featureFolder); - - assertThrowsExactly(ParametersException.class, dto::validate); - } - @Test public void validate_layoutPdf(){ val dto = new ParametersDto(); diff --git a/core/src/test/resources/com/github/clagomess/pirilampo/core/logo_xxx.png b/core/src/test/resources/com/github/clagomess/pirilampo/core/feature/logo_xxx.png similarity index 100% rename from core/src/test/resources/com/github/clagomess/pirilampo/core/logo_xxx.png rename to core/src/test/resources/com/github/clagomess/pirilampo/core/feature/logo_xxx.png