Skip to content

Commit

Permalink
impl. store config
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Mar 8, 2024
1 parent f1ceb46 commit 78507f6
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static com.github.clagomess.pirilampo.core.enums.CompilationTypeEnum.FEATURE;

public class FeatureToHTMLCompiler extends Compiler {
private final PropertiesCompiler propertiesCompiler = new PropertiesCompiler();
private final ParametersDto parameters;
private final File feature;
private final FeatureMetadataDto featureMetadataDto;
Expand Down Expand Up @@ -60,6 +61,7 @@ public void build() throws Exception {
outArtifact.delete();
throw e;
} finally {
propertiesCompiler.setData(parameters);
stopTimer();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@Slf4j
@RequiredArgsConstructor
public class FeatureToPDFCompiler extends Compiler {
private final PropertiesCompiler propertiesCompiler = new PropertiesCompiler();
private final ParametersDto parameters;
private final File feature;
private final FeatureMetadataDto featureMetadataDto;
Expand Down Expand Up @@ -79,6 +80,7 @@ public void build() throws Exception {
deleteAllTempFiles();
throw e;
} finally {
propertiesCompiler.setData(parameters);
stopTimer();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

@Slf4j
public class FolderToHTMLCompiler extends Compiler {
private final PropertiesCompiler propertiesCompiler = new PropertiesCompiler();
private final ImageParser imageParser = new ImageParser();
private final ParametersDto parameters;
protected final Map<String, FeatureIndexDto> index = new HashMap<>();
Expand Down Expand Up @@ -225,6 +226,7 @@ public void build() throws Exception {
outArtifact.delete();
throw e;
} finally {
propertiesCompiler.setData(parameters);
stopTimer();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@Slf4j
public class FolderToPDFCompiler extends Compiler {
private final PropertiesCompiler propertiesCompiler = new PropertiesCompiler();
private final ParametersDto parameters;

public FolderToPDFCompiler(ParametersDto parameters) {
Expand Down Expand Up @@ -92,6 +93,7 @@ public void build() throws Exception {
deleteAllTempFiles();
throw e;
} finally {
propertiesCompiler.setData(parameters);
stopTimer();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public void setData(ParametersDto parameters){
prop.setProperty("compilationArtifact", parameters.getCompilationArtifact().name());

prop.store(output, null);

log.info("- saved configuration at {}", file);
} catch (IOException ex) {
log.error(log.getName(), ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ public void build() throws Exception {
*/
}

@Test
public void checkIsSavedProperties() throws Exception {
ParametersDto parameters = new ParametersDto();
parameters.setProjectSource(featureFile);
parameters.setProjectTarget(targetFile);
parameters.setCompilationType(CompilationTypeEnum.FEATURE);
parameters.setCompilationArtifact(CompilationArtifactEnum.HTML);

new FeatureToHTMLCompiler(parameters).build();

assertTrue(new File(
parameters.getProjectSource().getParentFile(),
PropertiesCompiler.FILENAME
).isFile());
}

@Test
public void checkDeletedBuffersOnError() {
ParametersDto parameters = new ParametersDto();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ public void build() throws Exception {
// @TODO: also, validate html
}

@Test
public void checkIsSavedProperties() throws Exception {
ParametersDto parameters = new ParametersDto();
parameters.setProjectSource(featureFile);
parameters.setProjectTarget(targetFile);
parameters.setCompilationType(CompilationTypeEnum.FEATURE);
parameters.setCompilationArtifact(CompilationArtifactEnum.PDF);

new FeatureToPDFCompiler(parameters).build();

assertTrue(new File(
parameters.getProjectSource().getParentFile(),
PropertiesCompiler.FILENAME
).isFile());
}

@Test
public void checkDeletedBuffersOnError() {
ParametersDto parameters = new ParametersDto();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ public void buildIndex() throws IOException {
.contains(";");
}

@Test
public void checkIsSavedProperties() throws Exception {
ParametersDto parameters = new ParametersDto();
parameters.setProjectSource(featureFolder);
parameters.setProjectTarget(targetFile);

new FolderToHTMLCompiler(parameters).build();

assertTrue(new File(
parameters.getProjectSource(),
PropertiesCompiler.FILENAME
).isFile());
}

@Test
public void checkDeletedBuffersOnError() {
ParametersDto parameters = new ParametersDto();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ public void build() throws Exception {

// @TODO: validate content html

@Test
public void checkIsSavedProperties() throws Exception {
ParametersDto parameters = new ParametersDto();
parameters.setProjectSource(featureFolder);
parameters.setProjectTarget(targetFile);
parameters.setCompilationType(CompilationTypeEnum.FOLDER);
parameters.setCompilationArtifact(CompilationArtifactEnum.PDF);

new FolderToPDFCompiler(parameters).build();

assertTrue(new File(
parameters.getProjectSource(),
PropertiesCompiler.FILENAME
).isFile());
}

@Test
public void checkDeletedBuffersOnError() {
ParametersDto parameters = new ParametersDto();
Expand Down

0 comments on commit 78507f6

Please sign in to comment.