-
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.
Browse files
Browse the repository at this point in the history
feat(#9)!: introduce force write flag
- Loading branch information
Showing
16 changed files
with
356 additions
and
88 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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/io/github/goatfryed/assert_baseline/core/BaselineAssertionAdapter.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,27 @@ | ||
package io.github.goatfryed.assert_baseline.core; | ||
|
||
/** | ||
* Adapter interface to perform the real serialization and assertion | ||
* <br><br> | ||
* This interface is used to separate the format dependent actions of baseline testing | ||
* from the test process itself. | ||
*/ | ||
public interface BaselineAssertionAdapter { | ||
|
||
/** | ||
* Writes the serialized representation of the actual subject | ||
* | ||
* @param output Out parameter | ||
* @param context | ||
*/ | ||
void writeActual(BaselineContext.ActualOutput output, BaselineContext context); | ||
|
||
/** | ||
* Perform the equality assertion against the provided baseline | ||
* | ||
* @param baseline the baseline input | ||
* @param context | ||
*/ | ||
void assertEquals(BaselineContext.BaselineInput baseline, BaselineContext context); | ||
|
||
} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/io/github/goatfryed/assert_baseline/core/CliOption.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,43 @@ | ||
package io.github.goatfryed.assert_baseline.core; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Function; | ||
|
||
public class CliOption { | ||
@NotNull | ||
private final String systemProperty; | ||
@NotNull | ||
private final OptionType optionType; | ||
|
||
CliOption(@NotNull String systemProperty, @NotNull OptionType optionType) { | ||
this.systemProperty = systemProperty; | ||
this.optionType = optionType; | ||
} | ||
|
||
public String systemProperty() { | ||
return systemProperty; | ||
} | ||
|
||
OptionType optionType() { | ||
return optionType; | ||
} | ||
|
||
enum OptionType { | ||
Boolean(sVal -> { | ||
if (sVal == null) return false; | ||
if (sVal.equalsIgnoreCase("false")) return true; | ||
return true; | ||
}); | ||
|
||
private final Function<String, Object> normalizer; | ||
|
||
OptionType(Function<String,Object> normalizer) { | ||
this.normalizer = normalizer; | ||
} | ||
|
||
public Object normalize(String property) { | ||
return normalizer.apply(property); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/io/github/goatfryed/assert_baseline/core/Options.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,27 @@ | ||
package io.github.goatfryed.assert_baseline.core; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Optional; | ||
|
||
public interface Options { | ||
enum StandardOptions implements Options { | ||
FORCE_BASELINE_UPDATE( | ||
new CliOption( | ||
"io.github.goatfryed.assert_baseline.forceBaselineUpdate", | ||
CliOption.OptionType.Boolean | ||
) | ||
); | ||
|
||
@Nullable | ||
private final CliOption cliOption; | ||
|
||
StandardOptions(@Nullable CliOption cliOption) { | ||
this.cliOption = cliOption; | ||
} | ||
|
||
public Optional<CliOption> cliOption() { | ||
return Optional.ofNullable(cliOption); | ||
} | ||
} | ||
} |
Oops, something went wrong.