private void compareObjectNodes ( Context context ) { Node expected = context . getExpectedNode ( ) ; Node actual = context . getActualNode ( ) ; Path path = context . getActualPath ( ) ; Map < String , Node > expectedFields = getFields ( expected ) ; Map < String , Node > actualFields = getFields ( actual ) ; Set < String > expectedKeys = expectedFields . keySet ( ) ; Set < String > actualKeys = actualFields . keySet ( ) ; if ( ! expectedKeys . equals ( actualKeys ) ) { Set < String > missingKeys = getMissingKeys ( expectedKeys , actualKeys ) ; Set < String > extraKeys = getExtraKeys ( expectedKeys , actualKeys ) ; if ( hasOption ( Option . TREATING_NULL_AS_ABSENT ) ) { extraKeys = getNotNullExtraKeys ( actual , extraKeys ) ; } removePathsToBeIgnored ( path , extraKeys ) ; removeMissingIgnoredElements ( expected , missingKeys ) ; if ( ! missingKeys . isEmpty ( ) || ! extraKeys . isEmpty ( ) ) { for ( String key : missingKeys ) { reportDifference ( DifferenceImpl . missing ( context . inField ( key ) ) ) ; } for ( String key : extraKeys ) { reportDifference ( DifferenceImpl . extra ( context . inField ( key ) ) ) ; } String missingKeysMessage = getMissingKeysMessage ( missingKeys , path ) ; String extraKeysMessage = getExtraKeysMessage ( extraKeys , path ) ; structureDifferenceFound ( context , "Different keys found in node \"%s\"%s%s, " + differenceString ( ) , path , missingKeysMessage , extraKeysMessage , normalize ( expected ) , normalize ( actual ) ) ; } } for ( String fieldName : commonFields ( expectedFields , actualFields ) ) { compareNodes ( context . inField ( fieldName ) ) ; } }
Compares object nodes .