Skip to content
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e598ce7
feat - migrated maven project to java 16 (#1)
mxyns Mar 2, 2022
fc8c4d8
Merge pull request #2 from noahra/issue/#1
mxyns Mar 2, 2022
fff39bd
test - failing test for unsupported Record (#3)
mxyns Mar 2, 2022
7fc8851
Merge pull request #4 from noahra/issue/#3
mxyns Mar 2, 2022
4766703
test - add serialization test (#7)
lnsandnkth Mar 2, 2022
0d893a4
Merge pull request #8 from noahra/issue/#7
lnsandnkth Mar 2, 2022
da40903
test - fix added assertion (#3)
lnsandnkth Mar 2, 2022
6927007
Merge pull request #10 from noahra/issue/#3
lnsandnkth Mar 2, 2022
077c4d5
feat - record support with canonical constructor (#5) (PR #13)
yuxin-miao Mar 4, 2022
149b796
feat - handle multiple record constructors by using canonical constru…
mxyns Mar 4, 2022
4b7c1f0
test - add tests for any wrap and stream (#15)
lnsandnkth Mar 4, 2022
ac59b48
Merge pull request #17 from noahra/issue/#15
lnsandnkth Mar 4, 2022
8dc32ff
test - example of use of another constructor for record decoding (#16)
mxyns Mar 6, 2022
f921396
clean - reemoved syso/sout (#19)
mxyns Mar 6, 2022
2d2ff04
clean - removed unsused imports (#19)
mxyns Mar 6, 2022
37a6755
test - add tests for getRecordCtor (#21)
Mar 6, 2022
dc3a7af
Modularized, Java17, dependency-updates.
Aug 13, 2022
e736444
trying source and target tags to try to fix jitpack.io compilation
Aug 13, 2022
bdbd720
java.lang.module.FindException: Module com.fasterxml.jackson.databind
Aug 13, 2022
6a90a5a
transitive module Javassist not found
Aug 13, 2022
1652d87
revert transitive and open for more tests
Aug 13, 2022
0451822
fixed module-info using "requires static" for optional and test-only
Aug 16, 2022
26eab37
opened module
Aug 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test - add tests for getRecordCtor (#21)
  • Loading branch information
xinmiao authored and yuxin-miao committed Mar 6, 2022
commit 37a67552435e8aa1c93951679d001fe265133b26
32 changes: 25 additions & 7 deletions src/test/java/com/jsoniter/TestRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jsoniter.annotation.JsonCreator;
import com.jsoniter.annotation.JsonProperty;
import com.jsoniter.any.Any;
import com.jsoniter.spi.ClassDescriptor;
import com.jsoniter.spi.ClassInfo;
import com.jsoniter.spi.JsonException;
import junit.framework.TestCase;
Expand All @@ -17,7 +18,8 @@

public class TestRecord extends TestCase {

record TestRecord1(long field1) {}
record TestRecord1(long field1) {
}

public record TestRecord0(Long id, String name) {

Expand Down Expand Up @@ -114,7 +116,8 @@ public void test_record_withOnlyFieldDecoder() throws IOException {

public void test_record_2_fields_withOnlyFieldDecoder() throws IOException {

record TestRecord2(long field1, String field2) {}
record TestRecord2(long field1, String field2) {
}

assertEquals(ReflectionRecordDecoder.OnlyFieldRecord.class, ReflectionDecoderFactory.create(new ClassInfo(TestRecord2.class)).getClass());

Expand All @@ -127,7 +130,8 @@ record TestRecord2(long field1, String field2) {}

public void test_record_2_fields_swapFieldOrder_withOnlyFieldDecoder() throws IOException {

record TestRecord2(String field2, long field1) {}
record TestRecord2(String field2, long field1) {
}

assertEquals(ReflectionRecordDecoder.OnlyFieldRecord.class, ReflectionDecoderFactory.create(new ClassInfo(TestRecord2.class)).getClass());

Expand All @@ -140,8 +144,10 @@ record TestRecord2(String field2, long field1) {}

public void test_record_recordComposition_withOnlyFieldDecoder() throws IOException {

record TestRecordA(long fieldA) {}
record TestRecordB(long fieldB, TestRecordA a) {}
record TestRecordA(long fieldA) {
}
record TestRecordB(long fieldB, TestRecordA a) {
}

assertEquals(ReflectionRecordDecoder.OnlyFieldRecord.class, ReflectionDecoderFactory.create(new ClassInfo(TestRecordB.class)).getClass());

Expand All @@ -154,7 +160,8 @@ record TestRecordB(long fieldB, TestRecordA a) {}

public void test_record_empty_constructor_withOnlyFieldDecoder() throws IOException {

record TestRecord3() {}
record TestRecord3() {
}

assertEquals(ReflectionRecordDecoder.OnlyFieldRecord.class, ReflectionDecoderFactory.create(new ClassInfo(TestRecord3.class)).getClass());

Expand Down Expand Up @@ -216,6 +223,8 @@ public TestRecord6(@JsonProperty("valInt") int valInt) {
}
}

assertEquals(ReflectionRecordDecoder.WithCtor.class, ReflectionDecoderFactory.create(new ClassInfo(TestRecord6.class)).getClass());

JsonIterator iter = JsonIterator.parse("{ 'valInt' : 1 }".replace('\'', '"'));
TestRecord6 record = iter.read(TestRecord6.class);

Expand All @@ -227,8 +236,10 @@ public void test_record_withCtorDecoder() throws IOException {
record TestRecord2(@JsonProperty long field1) {

@JsonCreator
TestRecord2 {}
TestRecord2 {
}
}
assertEquals(ReflectionRecordDecoder.WithCtor.class, ReflectionDecoderFactory.create(new ClassInfo(TestRecord2.class)).getClass());

assertEquals(ReflectionDecoderFactory.create(new ClassInfo(TestRecord2.class)).getClass(), ReflectionObjectDecoder.WithCtor.class);

Expand All @@ -237,4 +248,11 @@ record TestRecord2(@JsonProperty long field1) {

assertEquals(1, record.field1);
}

public void test_record_constructor() throws IOException {
ClassDescriptor desc = ClassDescriptor.getDecodingClassDescriptor(new ClassInfo(TestRecord0.class), false);
assertEquals(TestRecord0.class.getConstructors()[1], desc.ctor.ctor);

}

}