package com.fasterxml.jackson.databind.node;

import java.math.BigDecimal;
import java.math.BigInteger;

import com.fasterxml.jackson.databind.*;

public class JsonNodeFactoryTest extends NodeTestBase
{
    private final ObjectMapper MAPPER = objectMapper();

    public void testSimpleCreation()
    {
        JsonNodeFactory f = MAPPER.getNodeFactory();
        JsonNode n;

        n = f.numberNode((byte) 4);
        assertTrue(n.isInt());
        assertEquals(4, n.intValue());

        assertTrue(f.numberNode((Byte) null).isNull());

        assertTrue(f.numberNode((Short) null).isNull());

        assertTrue(f.numberNode((Integer) null).isNull());

        assertTrue(f.numberNode((Long) null).isNull());

        assertTrue(f.numberNode((Float) null).isNull());

        assertTrue(f.numberNode((Double) null).isNull());

        assertTrue(f.numberNode((BigDecimal) null).isNull());

        assertTrue(f.numberNode((BigInteger) null).isNull());

        assertTrue(f.missingNode().isMissingNode());
    }
}

@@ -96,16 +96,42 @@
 Integer;
+%0Aimport java.util.TreeMap;
 %0A%0Aimport
@@ -164,16 +164,71 @@
 abind.*;
+%0Aimport com.fasterxml.jackson.databind.json.JsonMapper;
 %0A%0Apublic
@@ -330,24 +330,294 @@
 tMapper();%0A%0A
+    static class SortingNodeFactory extends JsonNodeFactory %7B%0A        private static final long serialVersionUID = 1L;%0A%0A        @Override%0A        public ObjectNode objectNode() %7B%0A            return new ObjectNode(this, new TreeMap%3CString, JsonNode%3E());%0A        %7D%0A    %7D%0A%0A
     public v
@@ -1356,16 +1356,957 @@
 ode());%0A
-
     %7D
+%0A%0A    // 09-Sep-2020, tatu: Let's try something more useful: auto-sorting%0A    //    Tree Model!%0A%0A   public void testSortingObjectNode() throws Exception%0A   %7B%0A       final String SIMPLE_INPUT = %22%7B%5C%22b%5C%22:2,%5C%22a%5C%22:1%7D%22;%0A       %0A       // First, by default, ordering retained:%0A       assertEquals(SIMPLE_INPUT,%0A               MAPPER.writeValueAsString(MAPPER.readTree(SIMPLE_INPUT)));%0A%0A       // But can change easily%0A       ObjectMapper mapper = JsonMapper.builder()%0A               .nodeFactory(new SortingNodeFactory())%0A               .build();%0A       JsonNode sort = mapper.readTree(SIMPLE_INPUT);%0A       assertEquals(%22%7B%5C%22a%5C%22:1,%5C%22b%5C%22:2%7D%22, MAPPER.writeValueAsString(sort));%0A%0A       final String BIGGER_INPUT = a2q(%22%5B'x',%7B'b':1,'c':true,'a':3%7D,false%5D%22);%0A       final String BIGGER_OUTPUT = a2q(%22%5B'x',%7B'a':3,'b':1,'c':true%7D,false%5D%22);%0A%0A       assertEquals(BIGGER_OUTPUT,%0A               MAPPER.writeValueAsString(mapper.readTree(BIGGER_INPUT)));%0A   %7D
 %0A%7D%0A

Add a new test for JsonNodeFactory