Skip to content

Conversation

@marko-kriskovic
Copy link
Owner

Summary

This PR fixes the failing tests in JsonMapConverterTest by correcting a logical error in the mapToJson method.

Problem

The mapToJson method had an inverted null check condition on line 38:

  • Before: if (map != null) - throws exception when map is NOT null
  • After: if (map == null) - throws exception when map IS null

This bug caused the method to throw an IllegalArgumentException for valid (non-null) map inputs, while allowing null inputs to proceed, which is the opposite of the intended behavior.

Changes

  • Fixed the condition in mapToJson method from if (map != null) to if (map == null)
  • This now properly validates null input and throws IllegalArgumentException as expected by the tests
  • Behavior now matches the mapToPrettyJson method which already had the correct null check

Test Coverage

This fix resolves the following failing tests:

  • testMapToJson_NullInput - Now correctly throws exception for null input
  • testMapToJson_SimpleMap - Now works correctly with valid map input
  • testMapToJson_NestedMap - Now works correctly with nested maps
  • testMapToJson_EmptyMap - Now works correctly with empty maps
  • testRoundTrip_JsonToMapToJson - Now completes the round-trip conversion successfully

Fixes #25

Changed condition from 'if (map != null)' to 'if (map == null)' 
to properly validate null input and throw IllegalArgumentException.

Fixes #25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

padaju testovi

2 participants