package com.github.nsnjson;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.node.*;
import org.junit.*;

public class DriverTest extends AbstractFormatTest {

    @Test
    public void shouldBeConsistencyWhenGivenNull() {
        assertConsistency(getNull());
    }

    @Test
    public void shouldBeConsistencyWhenGivenBooleanTrue() {
        assertConsistency(getBooleanTrue());
    }

    @Test
    public void shouldBeConsistencyWhenGivenBooleanFalse() {
        assertConsistency(getBooleanFalse());
    }

    @Test
    public void shouldBeConsistencyWhenGivenNumberInt() {
        assertConsistency(getNumberInt());
    }

    @Test
    public void shouldBeConsistencyWhenGivenNumberLong() {
        assertConsistency(getNumberLong());
    }

    @Test
    public void shouldBeConsistencyWhenGivenNumberDouble() {
        assertConsistency(getNumberDouble());
    }

    @Test
    public void shouldBeConsistencyWhenGivenStringWhichIsEmpty() {
        assertConsistency(getEmptyString());
    }

    @Test
    public void shouldBeConsistencyWhenGivenString() {
        assertConsistency(getString());
    }

    @Test
    public void shouldBeConsistencyWhenGivenArrayWhichIsEmpty() {
        ArrayNode array = new ObjectMapper().createArrayNode();

        assertConsistency(array);
    }

    @Test
    public void shouldBeConsistencyWhenGivenArray() {
        ArrayNode array = new ObjectMapper().createArrayNode();
        array.add(getNull());
        array.add(getBooleanTrue());
        array.add(getBooleanFalse());
        array.add(getNumberInt());
        array.add(getNumberLong());
        array.add(getNumberDouble());
        array.add(getString());

        assertConsistency(array);
    }

    @Test
    public void shouldBeConsistencyWhenGivenObjectWhichIsEmpty() {
        ObjectNode object = new ObjectMapper().createObjectNode();

        assertConsistency(object);
    }

    @Test
    public void shouldBeConsistencyWhenGivenObject() {
        ObjectNode object = new ObjectMapper().createObjectNode();
        object.set("null_field", getNull());
        object.set("true_field", getBooleanTrue());
        object.set("false_field", getBooleanFalse());
        object.set("int_field", getNumberInt());
        object.set("long_field", getNumberLong());
        object.set("double_field", getNumberDouble());
        object.set("string_field", getString());

        assertConsistency(object);
    }

    private static void assertConsistency(JsonNode value) {
        JsonNode restoredValue = Driver.decode(Driver.encode(value));

        assertEquals(value, restoredValue);
    }

    private static void assertEquals(JsonNode value1, JsonNode value2) {
        Assert.assertEquals(value1.toString(), value2.toString());
    }

}
@@ -346,27 +346,27 @@
 henGiven
-BooleanTrue
+NumberIsInt
 () %7B%0A   
@@ -387,35 +387,33 @@
 sistency(get
-BooleanTrue
+NumberInt
 ());%0A    %7D%0A%0A
@@ -466,28 +466,28 @@
 henGiven
-BooleanFalse
+NumberIsLong
 () %7B%0A   
@@ -508,36 +508,34 @@
 sistency(get
-BooleanFalse
+NumberLong
 ());%0A    %7D%0A%0A
@@ -595,18 +595,23 @@
 nNumberI
-nt
+sDouble
 () %7B%0A   
@@ -634,35 +634,38 @@
 stency(getNumber
-Int
+Double
 ());%0A    %7D%0A%0A    
@@ -714,26 +714,29 @@
 henGiven
-NumberLong
+StringIsEmpty
 () %7B%0A   
@@ -757,32 +757,33 @@
 sistency(get
-NumberLo
+EmptyStri
 ng());%0A    %7D
@@ -838,28 +838,22 @@
 henGiven
-NumberDouble
+String
 () %7B%0A   
@@ -874,36 +874,30 @@
 sistency(get
-NumberDouble
+String
 ());%0A    %7D%0A%0A
@@ -954,26 +954,21 @@
 iven
-StringWhichIsEmpty
+BooleanIsTrue
 () %7B
@@ -993,35 +993,35 @@
 sistency(get
-EmptyString
+BooleanTrue
 ());%0A    %7D%0A%0A
@@ -1066,38 +1066,46 @@
 istencyWhenGiven
-String
+BooleanIsFalse
 () %7B%0A        ass
@@ -1114,38 +1114,44 @@
 tConsistency(get
-String
+BooleanFalse
 ());%0A    %7D%0A%0A    
@@ -1205,21 +1205,16 @@
 venArray
-Which
 IsEmpty(
@@ -1221,73 +1221,8 @@
 ) %7B%0A
-        ArrayNode array = new ObjectMapper().createArrayNode();%0A%0A
     
@@ -1235,37 +1235,47 @@
 sertConsistency(
-a
+getEmptyA
 rray
+()
 );%0A    %7D%0A%0A    @T
@@ -1748,13 +1748,8 @@
 ject
-Which
 IsEm
@@ -1760,76 +1760,8 @@
 ) %7B%0A
-        ObjectNode object = new ObjectMapper().createObjectNode();%0A%0A
     
@@ -1774,38 +1774,48 @@
 sertConsistency(
-o
+getEmptyO
 bject
+()
 );%0A    %7D%0A%0A    @T

Refactor DriverTest: change titles of tests