Skip to content

Conversation

@marko-kriskovic
Copy link
Owner

Summary

This PR fixes the failing tests in JsonMapConverterTest by correcting an inverted null check condition in the mapToJson() method.

Problem

The tests were failing because the mapToJson() method at line 41 had an inverted condition:

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

This caused the method to throw an IllegalArgumentException whenever a valid (non-null) map was passed, which is the opposite of the intended behavior.

Solution

Changed the condition from if (map != null) to if (map == null) in code/src/main/java/org/example/util/JsonMapConverter.java:41

Now the method correctly:

  • ✅ Throws an exception when a null map is passed
  • ✅ Processes valid maps without throwing exceptions

Tests Fixed

This fix resolves all failing tests in JsonMapConverterTest:

  • testMapToJson_SimpleMap()
  • testMapToJson_EmptyMap()
  • testMapToJson_NestedMap()
  • testRoundTrip_JsonToMapToJson()

Closes #18

The condition in mapToJson was inverted - it was throwing an exception
when map was NOT null, instead of when it WAS null. Changed the condition
from 'if (map != null)' to 'if (map == null)' to properly validate null input.

Fixes #18
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.

Testovi padaju, ne znam zašto

2 participants