Skip to content

Conversation

@marko-kriskovic
Copy link
Owner

Summary

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

Problem

The mapToJson method at code/src/main/java/org/example/util/JsonMapConverter.java:41 had an inverted condition:

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

This caused the method to:

  • Throw an exception when a valid (non-null) map was passed
  • Process null maps without throwing an exception

Solution

Changed the condition to correctly check for null:

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

Tests Fixed

This resolves all failing tests mentioned in issue #16:

  • ✅ testMapToJson_NullInput
  • ✅ testMapToJson_NestedMap
  • ✅ testMapToJson_EmptyMap
  • ✅ testRoundTrip_JsonToMapToJson

Fixes #16

The condition was inverted - it was throwing an exception when map != null instead of when map == null. This caused all tests to fail as the method would throw an exception for valid input and process null input incorrectly.

Fixes #16
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