Skip to content

Commit

Permalink
Fixing Record Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Shounaks committed Feb 22, 2024
1 parent 0705483 commit eb9e69e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 49 deletions.
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) {}
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) {}

0 comments on commit eb9e69e

Please sign in to comment.