@@ -51,47 +51,29 @@ private void analyze(ContainAnalyzer containAnalyzer, ValuePath actualPath,
5151 Object expectedKey = expectedEntry .getKey ();
5252
5353 ValuePath propertyPath = actualPath .property (expectedKey .toString ());
54-
55- if (isNegative ) {
56- analyzeNegative (containAnalyzer , actualMap , propertyPath , expectedEntry );
57- } else {
58- analyzePositive (containAnalyzer , actualMap , propertyPath , expectedEntry );
59- }
54+ analyzePositiveNegative (containAnalyzer , actualMap , propertyPath , expectedEntry , isNegative );
6055 }
6156 }
6257
63- private void analyzePositive (ContainAnalyzer containAnalyzer ,
64- Map <?, ?> actualMap ,
65- ValuePath propertyPath ,
66- Map .Entry <?, ?> expectedEntry ) {
58+ private void analyzePositiveNegative (ContainAnalyzer containAnalyzer ,
59+ Map <?, ?> actualMap ,
60+ ValuePath propertyPath ,
61+ Map .Entry <?, ?> expectedEntry ,
62+ boolean isNegative ) {
6763 if (!actualMap .containsKey (expectedEntry .getKey ())) {
6864 containAnalyzer .reportMismatch (this , propertyPath , tokenizedMessage ().matcher ("is missing" ));
6965 } else {
7066 CompareToComparator comparator = CompareToComparator .comparator ();
7167
7268 Object actualValue = actualMap .get (expectedEntry .getKey ());
73- boolean actualValueEqual = comparator .compareIsEqual (propertyPath ,
74- actualValue , expectedEntry .getValue ());
69+ boolean actualValueEqual = isNegative ?
70+ !comparator .compareIsNotEqual (propertyPath , actualValue , expectedEntry .getValue ()):
71+ comparator .compareIsEqual (propertyPath , actualValue , expectedEntry .getValue ());
7572
7673 if (!actualValueEqual ) {
7774 containAnalyzer .reportMismatch (this , propertyPath , comparator .generateEqualMismatchReport ());
78- }
79- }
80- }
81-
82- private void analyzeNegative (ContainAnalyzer containAnalyzer ,
83- Map <?, ?> actualMap ,
84- ValuePath propertyPath ,
85- Map .Entry <?, ?> expectedEntry ) {
86- if (actualMap .containsKey (expectedEntry .getKey ())) {
87- CompareToComparator comparator = CompareToComparator .comparator ();
88-
89- Object actualValue = actualMap .get (expectedEntry .getKey ());
90- boolean actualValueNotEqual = comparator .compareIsNotEqual (propertyPath ,
91- actualValue , expectedEntry .getValue ());
92-
93- if (!actualValueNotEqual ) {
94- containAnalyzer .reportMatch (this , propertyPath , comparator .generateNotEqualMismatchReport ());
75+ } else {
76+ containAnalyzer .reportMatch (this , propertyPath , comparator .generateEqualMatchReport ());
9577 }
9678 }
9779 }
0 commit comments