-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
49 deletions.
There are no files selected for viewing
77 changes: 42 additions & 35 deletions
77
jr-objects/src/test/groovy/com/fasterxml/jackson/jr/passing/GroovyTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,68 @@ | ||
package com.fasterxml.jackson.jr.passing | ||
|
||
import org.junit.Test | ||
import org.junit.Assert | ||
|
||
import com.fasterxml.jackson.jr.ob.JSON | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
class GroovyTest | ||
{ | ||
class GroovyTest { | ||
@Test | ||
void testSimpleGroovyObject() throws Exception { | ||
def json = JSON.std.asString(new GroovyOb()) | ||
def expected = """{"AAAAA_A_Field_Starting_With_Two_Capital_Letters":"XYZ","aDouble":0.0,"aPublicInitializedInteger":56,"aPublicInitializedIntegerObject":1516,"aPublicUninitializedInteger":0,"anInitializedIntegerObject":1112,"anInitializedPublicString":"stringData","anInitializedString":"ABC","anInteger":0,"anIntegerWithValue":12}""" | ||
Assert.assertEquals(json, expected) | ||
} | ||
|
||
@Test | ||
void testRecord() throws Exception { | ||
def json = JSON.std.asString(new Cow("foo", Map.of("foo", "bar"))) | ||
def expected = """{"message":"foo","object":{"foo":"bar"}}""" | ||
Assert.assertEquals(json, expected) | ||
} | ||
} | ||
|
||
class GroovyOb { | ||
int anInteger | ||
int anIntegerWithValue = 12 | ||
int anInteger | ||
int anIntegerWithValue = 12 | ||
|
||
static int anStaticInteger = 34 | ||
static int anStaticIntegerWithValue = 34 | ||
static int anStaticInteger = 34 | ||
static int anStaticIntegerWithValue = 34 | ||
|
||
public int aPublicUninitializedInteger | ||
public int aPublicInitializedInteger = 56 | ||
public int aPublicUninitializedInteger | ||
public int aPublicInitializedInteger = 56 | ||
|
||
private int aPrivateUninitializedInteger | ||
private int aPrivateInitializedInteger = 78 | ||
private int aPrivateUninitializedInteger | ||
private int aPrivateInitializedInteger = 78 | ||
|
||
public static int aPublicStaticUninitializedInteger | ||
public static int aPublicStaticInitializedInteger = 910 | ||
public static int aPublicStaticUninitializedInteger | ||
public static int aPublicStaticInitializedInteger = 910 | ||
|
||
Integer anIntegerObject | ||
Integer anInitializedIntegerObject = 1112 | ||
Integer anIntegerObject | ||
Integer anInitializedIntegerObject = 1112 | ||
|
||
static Integer aStaticIntegerObject | ||
static Integer aStaticInitializedIntegerObject = 1314 | ||
static Integer aStaticIntegerObject | ||
static Integer aStaticInitializedIntegerObject = 1314 | ||
|
||
public Integer aPublicUninitializedIntegerObject | ||
public Integer aPublicInitializedIntegerObject = 1516 | ||
public Integer aPublicUninitializedIntegerObject | ||
public Integer aPublicInitializedIntegerObject = 1516 | ||
|
||
public static Integer aPublicStaticUninitializedIntegerObject | ||
public static Integer aPublicStaticInitializedIntegerObject = 1718 | ||
public static Integer aPublicStaticUninitializedIntegerObject | ||
public static Integer aPublicStaticInitializedIntegerObject = 1718 | ||
|
||
String aString | ||
String anInitializedString = "ABC" | ||
String aString | ||
String anInitializedString = "ABC" | ||
|
||
static String aStaticString = "jacksonJR" | ||
static String aStaticString = "jacksonJR" | ||
|
||
public String aPublicString | ||
public String anInitializedPublicString = "stringData" | ||
public String aPublicString | ||
public String anInitializedPublicString = "stringData" | ||
|
||
public String AAAAA_A_Field_Starting_With_Two_Capital_Letters = "XYZ" | ||
//Other Items | ||
public static String staticStr = "jacksonJR" // Public Static Object | ||
static int anStaticInt // Uninitialized Static Object | ||
public double aDouble // uninitialized primitive | ||
public Double aDoubleObject // testing boxing object | ||
private int hiddenvalue = 123 // private value | ||
public String AAAAA_A_Field_Starting_With_Two_Capital_Letters = "XYZ" | ||
//Other Items | ||
public static String staticStr = "jacksonJR" // Public Static Object | ||
static int anStaticInt // Uninitialized Static Object | ||
public double aDouble // uninitialized primitive | ||
public Double aDoubleObject // testing boxing object | ||
private int hiddenvalue = 123 // private value | ||
} | ||
|
||
record Cow(String message, Map<String, String> object) {} |
14 changes: 0 additions & 14 deletions
14
jr-objects/src/test/groovy/com/fasterxml/jackson/jr/passing/ReadRecordTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
package com.fasterxml.jackson.jr.passing | ||
|
||
import com.fasterxml.jackson.jr.ob.JSON | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
class ReadRecordTest { | ||
@Test | ||
void testSimpleGroovyObject() throws Exception { | ||
def json = JSON.std.asString(new Cow("foo", Map.of("foo", "bar"))) | ||
def expected = """{"message":"foo","object":{"foo":"bar"}}""" | ||
Assert.assertEquals(json, expected) | ||
} | ||
} | ||
|
||
record Cow(String message, Map<String, String> object) {} | ||
|