-
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.
Adding helper class for null comparisons prior to actual comparator and updated in DateTimeComparator, EntityComparator and ChildEntityComparator
- Loading branch information
Showing
5 changed files
with
74 additions
and
24 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
23 changes: 23 additions & 0 deletions
23
src/main/java/org/testmonkeys/jentitytest/comparison/util/NullComparison.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,23 @@ | ||
package org.testmonkeys.jentitytest.comparison.util; | ||
|
||
import org.testmonkeys.jentitytest.comparison.ComparisonContext; | ||
|
||
public class NullComparison { | ||
|
||
public NullComparisonResult compareOnNulls(Object actual, Object expected, ComparisonContext context) { | ||
NullComparisonResult result = new NullComparisonResult(true, context, actual, expected); | ||
|
||
if (actual == null && expected == null) { | ||
result.setStopComparison(true); | ||
return result; | ||
} | ||
|
||
if (actual != null && expected != null) | ||
return result; | ||
|
||
result.setPassed(false); | ||
result.setExpected(expected == null ? "null" : "not null"); | ||
result.setActual(actual == null ? "null" : "not null"); | ||
return result; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/org/testmonkeys/jentitytest/comparison/util/NullComparisonResult.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,21 @@ | ||
package org.testmonkeys.jentitytest.comparison.util; | ||
|
||
import org.testmonkeys.jentitytest.comparison.ComparisonContext; | ||
import org.testmonkeys.jentitytest.comparison.result.ComparisonResult; | ||
|
||
public class NullComparisonResult extends ComparisonResult { | ||
|
||
private boolean stopComparison; | ||
|
||
public NullComparisonResult(boolean passed, ComparisonContext context, Object actual, Object expected) { | ||
super(passed, context, actual, expected); | ||
} | ||
|
||
public boolean isStopComparison() { | ||
return stopComparison; | ||
} | ||
|
||
public void setStopComparison(boolean stopComparison) { | ||
this.stopComparison = stopComparison; | ||
} | ||
} |