Skip to content

Commit

Permalink
Merge pull request #48 from Ragin-LundF/develop
Browse files Browse the repository at this point in the history
Better output for matcher
  • Loading branch information
Ragin-LundF authored Feb 2, 2021
2 parents 2540632 + f441252 commit 1ae70c3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Release 1.25.0

Small bugfix release for proper mismatch messages of the matchers.

# Release 1.24.0

## New features
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.ragin.bdd
version=1.24.0
version=1.25.0

systemProp.sonar.host.url=https://sonarcloud.io/
systemProp.sonar.organization=ragin-lundf-github
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,29 @@ public class ScenarioStateContextMatcher extends BaseMatcher<Object> implements
private String parameter;

@Override
public boolean matches(Object actual) {
String parameterFromContext = ScenarioStateContext.current().getScenarioContextMap().get(parameter);
String actualAsString = String.valueOf(actual);
public boolean matches(final Object actual) {
final String parameterFromContext = ScenarioStateContext.current().getScenarioContextMap().get(parameter);
final String actualAsString = String.valueOf(actual);
return (actualAsString.equals(parameterFromContext));
}

@Override
public void describeTo(Description description) {
public void describeTo(final Description description) {
description.appendText("The actual value is not equal to the parameter [" + parameter + "]");
}

@Override
public void describeMismatch(final Object item, final Description description) {
description
.appendText("BDD Context value was [")
.appendValue(ScenarioStateContext.current().getScenarioContextMap().get(parameter))
.appendText("].")
.appendText(" JSON Value was [")
.appendValue(item)
.appendText("]");
super.describeMismatch(item, description);
}

@Override
public void setParameter(String parameter) {
this.parameter = parameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public boolean matches(Object item) {

@Override
public void describeMismatch(Object item, Description description) {
description.appendText("Is not a valid date: ").appendValue(item);
description.appendText("Is not a valid UUID: ").appendValue(item);
}

@Override
Expand Down

0 comments on commit 1ae70c3

Please sign in to comment.