Skip to content

Commit

Permalink
core: logo is a project file
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Mar 17, 2024
1 parent 8bbac04 commit 7abf3a2
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 <Project Logo> must be a valid file");
}

if(layoutPdf == null) throw ParametersException.required("Layout PDF");
if(htmlPanelToggle == null) throw ParametersException.required("HTML Panel Toggle");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -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);

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

0 comments on commit 7abf3a2

Please sign in to comment.