Skip to content

Conversation

@marko-kriskovic
Copy link
Owner

Summary

Fixed the inverted null check condition in the mapToJson method that was causing test failures.

Problem

The mapToJson method in JsonMapConverter.java had an inverted null check on line 40:

if (map != null) {
    throw new IllegalArgumentException("Map cannot be null");
}

This caused the method to throw an IllegalArgumentException when the map was NOT null, which is the opposite of the intended behavior.

Solution

Changed the condition from if (map != null) to if (map == null) to properly validate the input parameter.

Tests Fixed

This fix resolves the following failing tests:

  • testMapToJson_NullInput
  • testMapToJson_NestedMap
  • testMapToJson_EmptyMap
  • testRoundTrip_JsonToMapToJson

Changes

  • code/src/main/java/org/example/util/JsonMapConverter.java: Fixed null check condition on line 40

Closes #27

Fixed inverted null check condition in mapToJson method.
The method was throwing IllegalArgumentException when map was NOT null,
instead of when map was null. Changed condition from 'if (map != null)'
to 'if (map == null)' to properly validate input.

This fix resolves failing tests:
- testMapToJson_NullInput
- testMapToJson_NestedMap
- testMapToJson_EmptyMap
- testRoundTrip_JsonToMapToJson
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