Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 24, 2024
2 parents 7c009d5 + 78da93f commit 12b9080
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.HashMap;
import java.util.Map;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonSubTypes;
Expand All @@ -13,6 +12,8 @@
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Unit test proving that below issue is fixed.
* <p>
Expand Down Expand Up @@ -56,11 +57,11 @@ public void testDeserializeWithDifferentOrdering3133() throws Exception
// case 1 : type first
String ordering1 = a2q("{'type': 'MAP','map': { 'doubleValue': 0.1 }}");
TestMapContainer3133 model1 = mapper.readValue(ordering1, TestMapContainer3133.class);
Assertions.assertTrue(model1.getMap().get("doubleValue") instanceof Double);
assertTrue(model1.getMap().get("doubleValue") instanceof Double);

// case 2 : value first
String ordering2 = a2q("{'map': { 'doubleValue': 0.1 }, 'type': 'MAP'}");
TestMapContainer3133 model2 = mapper.readValue(ordering2, TestMapContainer3133.class);
Assertions.assertTrue(model2.getMap().get("doubleValue") instanceof Double);
assertTrue(model2.getMap().get("doubleValue") instanceof Double);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.*;
Expand All @@ -11,8 +10,9 @@
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.fail;

public class ObjectIdSubTypes4610Test extends DatabindTestUtil
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public void shouldHandleTypeDefinitionJson() throws Exception {
.without(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS)
.readValue(input);

Assertions.assertInstanceOf(NumberTypeDefinition.class, model);
assertInstanceOf(NumberTypeDefinition.class, model);
}

@Test
Expand All @@ -56,7 +56,7 @@ public void testRoundTrip() throws Exception {
TypeDefinition model = MAPPER.readerFor(TypeDefinition.class)
.with(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS)
.readValue(JSON);
Assertions.assertInstanceOf(NumberTypeDefinition.class, model);
assertInstanceOf(NumberTypeDefinition.class, model);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Map;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import tools.jackson.core.type.TypeReference;
Expand All @@ -13,6 +12,8 @@
import tools.jackson.databind.module.SimpleModule;
import tools.jackson.databind.testutil.failure.JacksonTestFailureExpected;

import static org.junit.jupiter.api.Assertions.assertEquals;

// [databind#4680] Custom key deserialiser registered for `Object.class` is ignored on nested JSON
public class CustomObjectKeyDeserializer4680Test
{
Expand Down Expand Up @@ -58,15 +59,15 @@ public Object deserializeKey(String key, DeserializationContext ctxt) {

// THEN
// depth 1 works as expected
Assertions.assertEquals("Erik", result.get("name_"));
assertEquals("Erik", result.get("name_"));

// before fix, depth 2 does NOT work as expected
Map<String, Object> addressMap = (Map<String, Object>) result.get("address_");
// before fix, null?? Fails here
Assertions.assertEquals("Elvirastr", addressMap.get("street_"));
assertEquals("Elvirastr", addressMap.get("street_"));
Map<String, Object> cityMap = (Map<String, Object>) addressMap.get("city_");
Assertions.assertEquals(1, cityMap.get("id_"));
Assertions.assertEquals("Berlin", cityMap.get("name_"));
assertEquals(1, cityMap.get("id_"));
assertEquals("Berlin", cityMap.get("name_"));
}

}

0 comments on commit 12b9080

Please sign in to comment.