Skip to content

Commit

Permalink
Merge branch '2.18' into 2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 24, 2024
2 parents 78da93f + 77d71c7 commit 682fd2f
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void testCopyWith() throws Exception {
JsonNode readResult = copiedMapper.readTree(json);
// validate functionality
assertEquals("Black", readResult.get("color").asText());
assertEquals(true, readResult.get("free").asBoolean());
assertTrue(readResult.get("free").asBoolean());
assertEquals(204, readResult.get("pages").asInt());
String readResultAsString = _unifyLFs("{\n \"color\" : \"Black\",\n \"free\" : \"true\",\n \"pages\" : \"204.04\"\n}");
assertEquals(readResultAsString, _unifyLFs(mapper.writeValueAsString(readResult)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ public void testIntToBooleanCoercionSuccessPojo() throws Exception
final ObjectReader r = DEFAULT_MAPPER.readerFor(BooleanPOJO.class);

p = r.readValue(DOC_WITH_0);
assertEquals(false, p.value);
assertFalse(p.value);
p = r.readValue(utf8Bytes(DOC_WITH_0));
assertEquals(false, p.value);
assertFalse(p.value);

p = r.readValue(DOC_WITH_1);
assertEquals(true, p.value);
assertTrue(p.value);
p = r.readValue(utf8Bytes(DOC_WITH_1));
assertEquals(true, p.value);
assertTrue(p.value);
}

@Test
Expand All @@ -221,12 +221,12 @@ public void testIntToBooleanCoercionSuccessRoot() throws Exception

ab = atomicR.readValue(" 0");
ab = atomicR.readValue(utf8Bytes(" 0"));
assertEquals(false, ab.get());
assertFalse(ab.get());

ab = atomicR.readValue(" 111");
assertEquals(true, ab.get());
assertTrue(ab.get());
ab = atomicR.readValue(utf8Bytes(" 111"));
assertEquals(true, ab.get());
assertTrue(ab.get());
}

// Test for verifying that Long values are coerced to boolean correctly as well
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

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

import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.a2q;

Expand Down Expand Up @@ -232,7 +233,7 @@ public void testWithUnwrappedAndCreatorSingleParameterAtBeginning() throws Excep
assertEquals("John", person.getName().getFirst());
assertEquals("Doe", person.getName().getLast());
assertEquals(30, person.getAge());
assertEquals(true, person.isAlive());
assertTrue(person.isAlive());
}

@Test
Expand All @@ -246,7 +247,7 @@ public void testWithUnwrappedAndCreatorSingleParameterInMiddle() throws Exceptio
assertEquals("John", person.getName().getFirst());
assertEquals("Doe", person.getName().getLast());
assertEquals(30, person.getAge());
assertEquals(true, person.isAlive());
assertTrue(person.isAlive());
}

@Test
Expand All @@ -260,7 +261,7 @@ public void testWithUnwrappedAndCreatorSingleParameterAtEnd() throws Exception {
assertEquals("John", person.getName().getFirst());
assertEquals("Doe", person.getName().getLast());
assertEquals(30, person.getAge());
assertEquals(true, person.isAlive());
assertTrue(person.isAlive());
}

@Test
Expand All @@ -274,7 +275,7 @@ public void testWithUnwrappedAndCreatorMultipleParametersAtBeginning() throws Ex
assertEquals("John", animal.getName().getFirst());
assertEquals("Doe", animal.getName().getLast());
assertEquals(30, animal.getAge());
assertEquals(true, animal.isAlive());
assertTrue(animal.isAlive());
}

@Test
Expand All @@ -288,7 +289,7 @@ public void testWithUnwrappedAndCreatorMultipleParametersInMiddle() throws Excep
assertEquals("John", animal.getName().getFirst());
assertEquals("Doe", animal.getName().getLast());
assertEquals(30, animal.getAge());
assertEquals(true, animal.isAlive());
assertTrue(animal.isAlive());
}

@Test
Expand All @@ -302,7 +303,7 @@ public void testWithUnwrappedAndCreatorMultipleParametersAtEnd() throws Exceptio
assertEquals("John", animal.getName().getFirst());
assertEquals("Doe", animal.getName().getLast());
assertEquals(30, animal.getAge());
assertEquals(true, animal.isAlive());
assertTrue(animal.isAlive());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void testManualPolymorphicCatBasic() throws Exception
Cat cat = (Cat) animal;
assertEquals(18, cat.lives);
// ok, he can't drink dairy products. Let's verify:
assertEquals(false, cat.likesCream);
assertFalse(cat.likesCream);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public void testConstructorAndProps() throws Exception
("{ \"a\" : \"1\", \"b\": 2, \"c\" : true }", ConstructorAndPropsBean.class);
assertEquals(1, bean.a);
assertEquals(2, bean.b);
assertEquals(true, bean.c);
assertTrue(bean.c);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void testNullsAsEmptyWithPrimitiveArrays() throws Exception
NullContentAsEmpty<boolean[]> result = MAPPER.readValue(JSON,
new TypeReference<NullContentAsEmpty<boolean[]>>() { });
assertEquals(1, result.values.length);
assertEquals(false, result.values[0]);
assertFalse(result.values[0]);
}
}

Expand Down Expand Up @@ -437,8 +437,8 @@ public void testNullsSkipWithPrimitiveArrays() throws Exception
NullContentSkip<boolean[]> result = MAPPER.readValue(JSON,
new TypeReference<NullContentSkip<boolean[]>>() { });
assertEquals(2, result.values.length);
assertEquals(true, result.values[0]);
assertEquals(true, result.values[1]);
assertTrue(result.values[0]);
assertTrue(result.values[1]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public void testNullForPrimitivesDefault() throws IOException
PrimitivesBean.class);
assertNotNull(bean);
assertEquals(0, bean.intValue);
assertEquals(false, bean.booleanValue);
assertFalse(bean.booleanValue);
assertEquals(0.0, bean.doubleValue);

bean = MAPPER.readValue("{\"byteValue\":null, \"longValue\":null, \"floatValue\":null}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,37 +151,37 @@ public void testOldSchemaGeneration() throws Exception

ObjectNode root = jsonSchema.getSchemaNode();
assertEquals("object", root.get("type").asText());
assertEquals(false, root.path("required").booleanValue());
assertFalse(root.path("required").booleanValue());
JsonNode propertiesSchema = root.get("properties");
assertNotNull(propertiesSchema);
JsonNode property1Schema = propertiesSchema.get("property1");
assertNotNull(property1Schema);
assertEquals("integer", property1Schema.get("type").asText());
assertEquals(false, property1Schema.path("required").booleanValue());
assertFalse(property1Schema.path("required").booleanValue());
JsonNode property2Schema = propertiesSchema.get("property2");
assertNotNull(property2Schema);
assertEquals("string", property2Schema.get("type").asText());
assertEquals(false, property2Schema.path("required").booleanValue());
assertFalse(property2Schema.path("required").booleanValue());
JsonNode property3Schema = propertiesSchema.get("property3");
assertNotNull(property3Schema);
assertEquals("array", property3Schema.get("type").asText());
assertEquals(false, property3Schema.path("required").booleanValue());
assertFalse(property3Schema.path("required").booleanValue());
assertEquals("string", property3Schema.get("items").get("type").asText());
JsonNode property4Schema = propertiesSchema.get("property4");
assertNotNull(property4Schema);
assertEquals("array", property4Schema.get("type").asText());
assertEquals(false, property4Schema.path("required").booleanValue());
assertFalse(property4Schema.path("required").booleanValue());
assertEquals("number", property4Schema.get("items").get("type").asText());

JsonNode property5Schema = propertiesSchema.get("property5");
assertNotNull(property5Schema);
assertEquals("string", property5Schema.get("type").asText());
assertEquals(true, property5Schema.path("required").booleanValue());
assertTrue(property5Schema.path("required").booleanValue());

JsonNode property6Schema = propertiesSchema.get("property6");
assertNotNull(property6Schema);
assertEquals("integer", property6Schema.get("type").asText());
assertEquals(false, property6Schema.path("required").booleanValue());
assertFalse(property6Schema.path("required").booleanValue());
}

@JsonFilter("filteredBean")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ public void testAsInt() throws Exception
@Test
public void testAsBoolean() throws Exception
{
assertEquals(false, BooleanNode.FALSE.asBoolean());
assertEquals(true, BooleanNode.TRUE.asBoolean());
assertEquals(false, IntNode.valueOf(0).asBoolean());
assertEquals(true, IntNode.valueOf(1).asBoolean());
assertEquals(false, LongNode.valueOf(0).asBoolean());
assertEquals(true, LongNode.valueOf(-34L).asBoolean());
assertEquals(true, new TextNode("true").asBoolean());
assertEquals(false, new TextNode("false").asBoolean());
assertEquals(false, new TextNode("barf").asBoolean());
assertEquals(true, new TextNode("barf").asBoolean(true));

assertEquals(true, new POJONode(Boolean.TRUE).asBoolean());
assertFalse(BooleanNode.FALSE.asBoolean());
assertTrue(BooleanNode.TRUE.asBoolean());
assertFalse(IntNode.valueOf(0).asBoolean());
assertTrue(IntNode.valueOf(1).asBoolean());
assertFalse(LongNode.valueOf(0).asBoolean());
assertTrue(LongNode.valueOf(-34L).asBoolean());
assertTrue(new TextNode("true").asBoolean());
assertFalse(new TextNode("false").asBoolean());
assertFalse(new TextNode("barf").asBoolean());
assertTrue(new TextNode("barf").asBoolean(true));

assertTrue(new POJONode(Boolean.TRUE).asBoolean());
}

// Deserializer to trigger the problem described in [JACKSON-554]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class FormatFeatureAcceptSingleTest extends DatabindTestUtil
{
Expand Down Expand Up @@ -213,7 +215,7 @@ public void testSingleBooleanArrayRead() throws Exception {
BooleanArrayWrapper result = MAPPER.readValue(json, BooleanArrayWrapper.class);
assertNotNull(result.values);
assertEquals(1, result.values.length);
assertEquals(true, result.values[0]);
assertTrue(result.values[0]);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class SingleValueAsArrayTest extends DatabindTestUtil
{
Expand Down Expand Up @@ -105,6 +107,6 @@ public void testPrimitives() throws Exception {

boolean[] b = MAPPER.readValue("true", boolean[].class);
assertEquals(1, d.length);
assertEquals(true, b[0]);
assertTrue(b[0]);
}
}

0 comments on commit 682fd2f

Please sign in to comment.