-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Removes Spring and spring Boot dependencies from Flight Evaluation report - Adds vanilla app context creation code - Configures Thymeleaf manually - Updates tests - Configures logging - Removes unused configuration Resolves #118 {minor} Signed-off-by: Esta Nagy <[email protected]>
- Loading branch information
Showing
29 changed files
with
434 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# This file is generated by the 'io.freefair.lombok' Gradle plugin | ||
config.stopBubbling = true | ||
lombok.addLombokGeneratedAnnotation = true | ||
lombok.nonnull.exceptiontype=IllegalArgumentException |
40 changes: 40 additions & 0 deletions
40
...port/src/main/java/com/github/nagyesta/abortmission/reporting/AbortMissionAppContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.github.nagyesta.abortmission.reporting; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.github.nagyesta.abortmission.reporting.config.ConversionProperties; | ||
import com.github.nagyesta.abortmission.reporting.controller.ConversionController; | ||
import com.github.nagyesta.abortmission.reporting.html.converter.ClassJsonToHtmlConverter; | ||
import com.github.nagyesta.abortmission.reporting.html.converter.LaunchJsonToHtmlConverter; | ||
import com.github.nagyesta.abortmission.reporting.html.converter.StageLaunchStatsJsonToHtmlConverter; | ||
import com.github.nagyesta.abortmission.reporting.html.converter.StatsJsonToHtmlConverter; | ||
import org.thymeleaf.TemplateEngine; | ||
|
||
public class AbortMissionAppContext { | ||
private final ConversionController controller; | ||
|
||
public AbortMissionAppContext(final ConversionProperties properties) { | ||
final ObjectMapper objectMapper = new ObjectMapper(); | ||
final StatsJsonToHtmlConverter statsConverter = new StatsJsonToHtmlConverter(); | ||
final StageLaunchStatsJsonToHtmlConverter stageConverter = new StageLaunchStatsJsonToHtmlConverter(statsConverter); | ||
final ClassJsonToHtmlConverter classConverter = new ClassJsonToHtmlConverter(statsConverter, stageConverter); | ||
final LaunchJsonToHtmlConverter launchConverter = new LaunchJsonToHtmlConverter(statsConverter, classConverter); | ||
final TemplateEngine templateEngine = new TemplateEngine(); | ||
controller = new ConversionController(properties, objectMapper, launchConverter, templateEngine); | ||
} | ||
|
||
/** | ||
* Returns the controller. | ||
* | ||
* @return controller | ||
*/ | ||
public ConversionController controller() { | ||
return controller; | ||
} | ||
|
||
/** | ||
* Exits with an error code (1). | ||
*/ | ||
public void exitWithError() { | ||
System.exit(1); | ||
} | ||
} |
31 changes: 24 additions & 7 deletions
31
...ava/com/github/nagyesta/abortmission/reporting/AbortMissionFlightEvaluationReportApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
package com.github.nagyesta.abortmission.reporting; | ||
|
||
import com.github.nagyesta.abortmission.reporting.controller.ConversionController; | ||
import com.github.nagyesta.abortmission.reporting.config.ConversionProperties; | ||
import com.github.nagyesta.abortmission.reporting.exception.RenderException; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@SpringBootApplication | ||
@SuppressWarnings("checkstyle:HideUtilityClassConstructor") | ||
public class AbortMissionFlightEvaluationReportApp { | ||
@Slf4j | ||
public final class AbortMissionFlightEvaluationReportApp { | ||
|
||
public static void main(final String[] args) throws RenderException { | ||
SpringApplication.run(AbortMissionFlightEvaluationReportApp.class, args) | ||
.getBean(ConversionController.class).convert(); | ||
final AbortMissionFlightEvaluationReportApp app = new AbortMissionFlightEvaluationReportApp(); | ||
app.execute(app.bootstrap(Arrays.asList(args))); | ||
} | ||
|
||
AbortMissionAppContext bootstrap(final List<String> args) { | ||
final ConversionProperties properties = new PropertiesParser(args).parseArguments(); | ||
return new AbortMissionAppContext(properties); | ||
} | ||
|
||
void execute(final AbortMissionAppContext context) { | ||
try { | ||
context.controller().convert(); | ||
} catch (final RenderException ex) { | ||
log.error(ex.getMessage(), ex); | ||
context.exitWithError(); | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ion-report/src/main/java/com/github/nagyesta/abortmission/reporting/PropertiesParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.github.nagyesta.abortmission.reporting; | ||
|
||
import com.github.nagyesta.abortmission.reporting.config.ConversionProperties; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
import java.util.regex.Pattern; | ||
|
||
public final class PropertiesParser { | ||
|
||
private static final String INPUT = "--report.input"; | ||
private static final String OUTPUT = "--report.output"; | ||
private static final String RELAXED = "--report.relaxed"; | ||
private static final String FAIL_ON_ERROR = "--report.failOnError"; | ||
private static final String EQUALS = "="; | ||
private static final String EMPTY = ""; | ||
|
||
private final List<String> args; | ||
|
||
public PropertiesParser(final List<String> args) { | ||
this.args = List.copyOf(args); | ||
} | ||
|
||
public ConversionProperties parseArguments() { | ||
final ConversionProperties.ConversionPropertiesBuilder builder = ConversionProperties.builder(); | ||
parse(INPUT, File::new, builder::input); | ||
parse(OUTPUT, File::new, builder::output); | ||
parse(RELAXED, Boolean::valueOf, builder::relaxed); | ||
parse(FAIL_ON_ERROR, Boolean::valueOf, builder::failOnError); | ||
return builder.build(); | ||
} | ||
|
||
private <T> void parse(final String parameter, final Function<String, T> mapper, final Consumer<T> consumer) { | ||
args.stream().filter(s -> s.startsWith(parameter)).findFirst() | ||
.map(s -> s.replaceFirst(Pattern.quote(parameter + EQUALS), EMPTY)) | ||
.map(mapper).ifPresent(consumer); | ||
} | ||
} |
61 changes: 50 additions & 11 deletions
61
...src/main/java/com/github/nagyesta/abortmission/reporting/config/ConversionProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,61 @@ | ||
package com.github.nagyesta.abortmission.reporting.config; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.io.File; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@Component | ||
@ConfigurationProperties(prefix = "report", ignoreInvalidFields = false, ignoreUnknownFields = false) | ||
public class ConversionProperties { | ||
@NonNull | ||
public final class ConversionProperties { | ||
private File input; | ||
@NonNull | ||
private File output; | ||
private boolean relaxed = false; | ||
private boolean failOnError = false; | ||
private boolean relaxed; | ||
private boolean failOnError; | ||
|
||
private ConversionProperties(@NonNull final File input, @NonNull final File output, final boolean relaxed, final boolean failOnError) { | ||
this.input = input; | ||
this.output = output; | ||
this.relaxed = relaxed; | ||
this.failOnError = failOnError; | ||
} | ||
|
||
public static ConversionPropertiesBuilder builder() { | ||
return new ConversionPropertiesBuilder(); | ||
} | ||
|
||
@SuppressWarnings("checkstyle:HiddenField") | ||
public static final class ConversionPropertiesBuilder { | ||
private File input; | ||
private File output; | ||
private boolean relaxed = false; | ||
private boolean failOnError = false; | ||
|
||
ConversionPropertiesBuilder() { | ||
} | ||
|
||
public ConversionPropertiesBuilder input(@Nonnull final File input) { | ||
this.input = input; | ||
return this; | ||
} | ||
|
||
public ConversionPropertiesBuilder output(@Nonnull final File output) { | ||
this.output = output; | ||
return this; | ||
} | ||
|
||
public ConversionPropertiesBuilder relaxed(final boolean relaxed) { | ||
this.relaxed = relaxed; | ||
return this; | ||
} | ||
|
||
public ConversionPropertiesBuilder failOnError(final boolean failOnError) { | ||
this.failOnError = failOnError; | ||
return this; | ||
} | ||
|
||
public ConversionProperties build() { | ||
return new ConversionProperties(input, output, relaxed, failOnError); | ||
} | ||
} | ||
} |
Oops, something went wrong.