From 44bb47481ee0c7b0dac6fb2240df311dc1f69eb4 Mon Sep 17 00:00:00 2001 From: indroneel Date: Sat, 31 Oct 2026 18:26:32 +0530 Subject: [PATCH] checkpointing --- build.gradle | 9 +- .../java/daxi/moe/test/json/AllTests.java | 50 +++++ .../test/json/mod2obj/JsonMod2ObjTests.java | 60 +++++ .../test/json/mod2obj/semantics/AllTests.java | 61 +++++ .../mod2obj/semantics/Root02.java} | 21 +- .../setter/linear/boolval/AllTests.java | 50 +++++ .../setter/linear/boolval/BooleanRoot.java | 38 ++++ .../setter/linear/intval/AllTests.java | 50 +++++ .../mod2obj/setter/linear/intval/IntRoot.java | 38 ++++ .../setter/linear/objval/AllTests.java | 79 +++++++ .../setter/linear/objval/ColNested.java | 38 ++++ .../mod2obj/setter/linear/objval/Root01.java | 38 ++++ .../mod2obj/setter/linear/objval/Root02.java | 38 ++++ .../setter/linear/objval/StringNested.java} | 12 +- .../setter/linear/strval/AllTests.java | 50 +++++ .../setter/linear/strval/StringRoot.java | 38 ++++ .../mod2obj/setter/mapped/blank/AllTests.java | 51 +++++ .../setter/mapped/blank/BlankNested.java | 42 ++++ .../mod2obj/setter/mapped/blank/Root.java | 31 +++ .../setter/mapped/intval/AllTests.java | 85 +++++++ .../setter/mapped/intval/IntNested.java | 41 ++++ .../mod2obj/setter/mapped/intval/Root.java | 31 +++ .../setter/mapped/strval/AllTests.java | 62 +++++ .../mod2obj/setter/mapped/strval/Root.java | 31 +++ .../setter/mapped/strval/StringNested.java} | 14 +- .../setter/simple/bdecval/AllTests.java | 96 ++++++++ .../setter/simple/bdecval/BigDecimalRoot.java | 37 +++ .../setter/simple/bintval/AllTests.java | 113 ++++++++++ .../setter/simple/bintval/BigIntegerRoot.java | 41 ++++ .../setter/simple/boolval/AllTests.java | 66 ++++++ .../setter/simple/boolval/BooleanRoot.java | 45 ++++ .../setter/simple/byteval/AllTests.java | 96 ++++++++ .../setter/simple/byteval/ByteRoot.java | 45 ++++ .../setter/simple/doubleval/AllTests.java | 79 +++++++ .../setter/simple/doubleval/DoubleRoot.java | 45 ++++ .../setter/simple/floatval/AllTests.java | 79 +++++++ .../setter/simple/floatval/FloatRoot.java | 45 ++++ .../setter/simple/intval/AllTests.java | 79 +++++++ .../setter/simple/intval/IntegerRoot.java | 45 ++++ .../setter/simple/longval/AllTests.java | 79 +++++++ .../setter/simple/longval/LongRoot.java | 45 ++++ .../setter/simple/shortval/AllTests.java | 96 ++++++++ .../setter/simple/shortval/ShortRoot.java | 49 ++++ .../setter/simple/strval/AllTests.java | 44 ++++ .../setter/simple/strval/StringRoot.java} | 10 +- .../{scenario/delta => mem}/AllTests.java | 22 +- .../moe/test/mem/mod2obj/MemMod2ObjTests.java | 61 +++++ .../test/mem/mod2obj/semantics/AllTests.java | 71 ++++++ .../mem/mod2obj/semantics/InvalidRoot01.java | 40 ++++ .../mem/mod2obj/semantics/InvalidRoot02.java | 53 +++++ .../mod2obj/semantics/InvalidRoot03.java} | 13 +- .../mod2obj/setter/semantics/AllTests.java | 129 +++++++++++ .../mod2obj/setter/semantics/Nested.java} | 14 +- .../mem/mod2obj/setter/semantics/Root01.java | 39 ++++ .../mem/mod2obj/setter/semantics/Root02.java | 42 ++++ .../mem/mod2obj/setter/semantics/Root03.java | 43 ++++ .../mem/mod2obj/setter/semantics/Root04.java | 42 ++++ .../mem/mod2obj/setter/semantics/Root05.java | 42 ++++ .../mem/mod2obj/setter/semantics/Root06.java | 44 ++++ .../mem/mod2obj/setter/semantics/Root07.java | 42 ++++ .../mem/mod2obj/setter/semantics/Root08.java | 47 ++++ .../setter/simple/bdecval/AllTests.java | 95 ++++++++ .../simple/bdecval/BigDecimalRoot.java} | 6 +- .../setter/simple/bintval/AllTests.java | 96 ++++++++ .../simple/bintval/BigIntegerRoot.java} | 6 +- .../setter/simple/boolval/AllTests.java | 89 ++++++++ .../setter/simple/boolval/BooleanRoot.java} | 10 +- .../setter/simple/byteval/AllTests.java | 84 +++++++ .../setter/simple/byteval/ByteRoot.java} | 10 +- .../setter/simple/doubleval/AllTests.java | 92 ++++++++ .../setter/simple/doubleval/DoubleRoot.java} | 6 +- .../setter/simple/floatval/AllTests.java | 91 ++++++++ .../setter/simple/floatval/FloatRoot.java} | 6 +- .../setter/simple/intval/AllTests.java | 92 ++++++++ .../setter/simple/intval/IntegerRoot.java} | 6 +- .../setter/simple/longval/AllTests.java | 91 ++++++++ .../setter/simple/longval/LongRoot.java} | 6 +- .../setter/simple/shortval/AllTests.java | 86 +++++++ .../setter/simple/shortval/ShortRoot.java} | 6 +- .../setter/simple/strval/AllTests.java | 48 ++++ .../setter/simple/strval/StringRoot.java | 35 +++ .../moe/test/mem/obj2mod/MemObj2ModTests.java | 53 +++++ .../mem/obj2mod/linear/numitem/AllTests.java | 104 +++++++++ .../obj2mod/linear/numitem/IntArrayRoot.java | 35 +++ .../obj2mod/linear/numitem/IntListRoot.java | 37 +++ .../obj2mod/linear/numitem/IntSetRoot.java | 37 +++ .../mem/obj2mod/linear/stritem/AllTests.java | 103 +++++++++ .../linear/stritem/StringArrayRoot.java | 35 +++ .../linear/stritem/StringListRoot.java | 37 +++ .../obj2mod/linear/stritem/StringSetRoot.java | 37 +++ .../test/mem/obj2mod/semantics/AllTests.java | 110 +++++++++ .../mem/obj2mod/semantics/BadObject01.java | 42 ++++ .../obj2mod/semantics/BlankObject01.java} | 16 +- .../mem/obj2mod/semantics/BlankObject02.java | 42 ++++ .../mem/obj2mod/semantics/BlankObject03.java | 35 +++ .../mem/obj2mod/semantics/BlankObject04.java | 35 +++ .../mem/obj2mod/semantics/GoodObject.java | 35 +++ .../moe/test/mem/obj2mod/simple/AllTests.java | 157 +++++++++++++ .../mem/obj2mod/simple/BigDecimalRoot.java | 36 +++ .../mem/obj2mod/simple/BigIntegerRoot.java | 32 +++ .../test/mem/obj2mod/simple/BooleanRoot.java | 40 ++++ .../test/mem/obj2mod/simple/DoubleRoot.java | 42 ++++ .../test/mem/obj2mod/simple/FloatRoot.java | 40 ++++ .../test/mem/obj2mod/simple/IntegerRoot.java | 40 ++++ .../moe/test/mem/obj2mod/simple/LongRoot.java | 40 ++++ .../java/daxi/moe/test/mod2obj/Check.java | 32 +++ .../moe/test/mod2obj/generic/AllTests.java | 60 +++++ .../daxi/moe/test/mod2obj/generic/Nested.java | 18 ++ .../moe/test/mod2obj/generic/ValidRoot01.java | 36 +++ .../moe/test/mod2obj/generic/ValidRoot02.java | 36 +++ .../moe/test/mod2obj/generic/ValidRoot03.java | 36 +++ .../test/mod2obj/linear/generic/AllTests.java | 87 ++++++++ .../mod2obj/linear/generic/ListItem01.java | 30 +++ .../mod2obj/linear/generic/ListItem02.java | 30 +++ .../test/mod2obj/linear/generic/Root01.java | 45 ++++ .../test/mod2obj/linear/generic/Root02.java | 45 ++++ .../test/mod2obj/linear/nlinear/AllTests.java | 211 ++++++++++++++++++ .../mod2obj/linear/nlinear/ListItem01.java | 48 ++++ .../mod2obj/linear/nlinear/ListItem02.java | 38 ++++ .../mod2obj/linear/nlinear/ListItem03.java | 40 ++++ .../mod2obj/linear/nlinear/ListItem04.java | 39 ++++ .../mod2obj/linear/nlinear/ListItem05.java | 43 ++++ .../mod2obj/linear/nlinear/ListItem06.java | 38 ++++ .../mod2obj/linear/nlinear/NestedItem.java | 41 ++++ .../test/mod2obj/linear/nlinear/Root01.java | 43 ++++ .../test/mod2obj/linear/nlinear/Root02.java | 43 ++++ .../test/mod2obj/linear/nlinear/Root03.java | 43 ++++ .../test/mod2obj/linear/nlinear/Root04.java | 43 ++++ .../test/mod2obj/linear/nlinear/Root05.java | 43 ++++ .../test/mod2obj/linear/nlinear/Root06.java | 43 ++++ .../test/mod2obj/linear/nmap/AllTests.java | 101 +++++++++ .../test/mod2obj/linear/nmap/ListItem.java | 41 ++++ .../moe/test/mod2obj/linear/nmap/Root01.java | 43 ++++ .../test/mod2obj/linear/simple/AllTests.java | 103 +++++++++ .../test/mod2obj/linear/simple/Root01.java | 46 ++++ .../test/mod2obj/linear/simple/Root02.java | 53 +++++ .../test/mod2obj/linear/simple/Root03.java | 45 ++++ .../test/mod2obj/linear/simple/Root04.java | 45 ++++ .../mod2obj/linear/simple/ValueObject.java | 31 +++ .../test/mod2obj/mapped/pstr/AllTests.java | 50 +++++ .../mod2obj/mapped/pstr/StringNested.java | 31 +++ .../test/mod2obj/mapped/pstr/StringRoot.java | 31 +++ .../mod2obj/mapped/semantic/AllTests.java | 142 ++++++++++++ .../mod2obj/mapped/semantic/GoodNested.java | 31 +++ .../mod2obj/mapped/semantic/GoodRoot.java | 31 +++ .../mod2obj/mapped/semantic/Nested01.java | 22 ++ .../mod2obj/mapped/semantic/Nested02.java | 39 ++++ .../mod2obj/mapped/semantic/Nested03.java | 39 ++++ .../mod2obj/mapped/semantic/Nested04.java | 40 ++++ .../mod2obj/mapped/semantic/Nested05.java | 40 ++++ .../mod2obj/mapped/semantic/Nested06.java | 40 ++++ .../mapped/semantic/NestedEntity10.java | 31 +++ .../test/mod2obj/mapped/semantic/PType.java | 28 +++ .../test/mod2obj/mapped/semantic/Root01.java | 35 +++ .../test/mod2obj/mapped/semantic/Root02.java | 35 +++ .../test/mod2obj/mapped/semantic/Root03.java | 35 +++ .../test/mod2obj/mapped/semantic/Root04.java | 35 +++ .../test/mod2obj/mapped/semantic/Root05.java | 35 +++ .../test/mod2obj/mapped/semantic/Root06.java | 35 +++ .../mod2obj/mapped/semantic/RootEntity10.java | 31 +++ .../simple/blankmap/pstr/AllTests.java | 81 +++++++ .../mod2obj/simple/blankmap/pstr/Nested.java | 34 +++ .../simple/blankmap/pstr/StringRoot01.java | 34 +++ .../simple/blankmap/pstr/StringRoot02.java | 26 +++ .../simple/blankmap/semantic/AllTests.java | 109 +++++++++ .../simple/blankmap/semantic/Root01.java | 25 +++ .../simple/blankmap/semantic/Root02.java | 28 +++ .../simple/blankmap/semantic/Root03.java | 25 +++ .../simple/blankmap/semantic/Root04.java | 27 +++ .../simple/blankmap/semantic/Root05.java | 25 +++ .../simple/blankmap/semantic/Root06.java | 32 +++ .../alfa/scn01/MemInvalidEntityTests.java | 99 -------- .../alfa/scn02/MemIncorrectSetterTests.java | 107 --------- .../alfa/scn03/MemSimpleSetterTests.java | 123 ---------- .../alfa/scn04/MemByteSetterTests.java | 102 --------- .../alfa/scn05/MemShortSetterTests.java | 102 --------- .../alfa/scn06/MemIntegerSetterTests.java | 109 --------- .../alfa/scn07/MemFloatSetterTests.java | 109 --------- .../alfa/scn08/MemLongSetterTests.java | 109 --------- .../alfa/scn09/MemDoubleSetterTests.java | 109 --------- .../alfa/scn10/MemBigIntegerSetterTests.java | 119 ---------- .../alfa/scn11/MemBigDecimalSetterTests.java | 119 ---------- .../moe/test/scenario/mem/MemCodecTests.java | 59 +++++ .../MappedSetterTests.java | 89 ++++++++ .../s0402_mapped_setter/NestedEntity01.java} | 19 +- .../s0402_mapped_setter/NestedEntity02.java | 33 +++ .../mem/s0402_mapped_setter/RootEntity01.java | 31 +++ .../mem/s0402_mapped_setter/RootEntity02.java | 32 +++ .../MappedSetterBooleanTests.java} | 15 +- .../BadBlankMapperTests.java | 124 ++++++++++ .../mem/s0501_mapped_blank_bad/Nested01.java | 29 +++ .../mem/s0501_mapped_blank_bad/Nested02.java | 32 +++ .../mem/s0501_mapped_blank_bad/Nested03.java | 30 +++ .../mem/s0501_mapped_blank_bad/Nested04.java | 30 +++ .../mem/s0501_mapped_blank_bad/Root01.java | 31 +++ .../mem/s0501_mapped_blank_bad/Root02.java | 31 +++ .../mem/s0501_mapped_blank_bad/Root03.java | 31 +++ .../mem/s0501_mapped_blank_bad/Root04.java | 31 +++ .../mem/s0501_mapped_blank_bad/State.java | 32 +++ .../mem/s0501_mapped_blank_bad/SubNested.java | 31 +++ .../s0501_mapped_blank_bad/SubNestedP.java | 31 +++ .../s0502_mapped_blank/MappedBlankTests.java | 159 +++++++++++++ .../mem/s0502_mapped_blank/Nested01.java | 41 ++++ .../mem/s0502_mapped_blank/Nested02.java | 34 +++ .../mem/s0502_mapped_blank/Nested03.java | 34 +++ .../mem/s0502_mapped_blank/Nested04.java | 34 +++ .../mem/s0502_mapped_blank/Root01.java | 31 +++ .../mem/s0502_mapped_blank/Root02.java | 31 +++ .../mem/s0502_mapped_blank/Root03.java | 31 +++ .../mem/s0502_mapped_blank/Root04.java | 31 +++ .../mem/s0502_mapped_blank/SubNestedA.java | 31 +++ .../mem/s0502_mapped_blank/SubNestedB.java | 33 +++ .../scenario/mem/simple/strput/AllTests.java | 43 ++++ .../test/scenario/mem/simple/strput/Root.java | 39 ++++ .../simple/strset}/AllTests.java | 26 +-- testdata/json/mod2obj/semantics/bad01.json | 1 + testdata/json/mod2obj/semantics/good.json | 5 + .../mod2obj/setter/linear/boolval/test01.json | 3 + .../mod2obj/setter/linear/intval/test01.json | 3 + .../mod2obj/setter/linear/objval/test01.json | 8 + .../mod2obj/setter/linear/objval/test02.json | 19 ++ .../mod2obj/setter/linear/strval/test01.json | 3 + .../mod2obj/setter/mapped/blank/test01.json | 6 + .../mod2obj/setter/mapped/intval/test01.json | 6 + .../mod2obj/setter/mapped/intval/test02.json | 6 + .../mod2obj/setter/mapped/intval/test03.json | 6 + .../mod2obj/setter/mapped/strval/test01.json | 5 + .../mod2obj/setter/mapped/strval/test02.json | 3 + .../mod2obj/setter/simple/bdecval/test01.json | 3 + .../mod2obj/setter/simple/bdecval/test02.json | 3 + .../mod2obj/setter/simple/bdecval/test03.json | 3 + .../mod2obj/setter/simple/bdecval/test04.json | 3 + .../mod2obj/setter/simple/bintval/test01.json | 3 + .../mod2obj/setter/simple/bintval/test02.json | 3 + .../mod2obj/setter/simple/bintval/test03.json | 3 + .../mod2obj/setter/simple/bintval/test04.json | 3 + .../mod2obj/setter/simple/bintval/test05.json | 3 + .../mod2obj/setter/simple/boolval/test01.json | 4 + .../mod2obj/setter/simple/boolval/test02.json | 4 + .../mod2obj/setter/simple/byteval/test01.json | 4 + .../mod2obj/setter/simple/byteval/test02.json | 4 + .../mod2obj/setter/simple/byteval/test03.json | 4 + .../mod2obj/setter/simple/byteval/test04.json | 4 + .../setter/simple/doubleval/test01.json | 4 + .../setter/simple/doubleval/test02.json | 4 + .../setter/simple/doubleval/test03.json | 4 + .../setter/simple/floatval/test01.json | 4 + .../setter/simple/floatval/test02.json | 4 + .../setter/simple/floatval/test03.json | 4 + .../mod2obj/setter/simple/intval/test01.json | 4 + .../mod2obj/setter/simple/intval/test02.json | 4 + .../mod2obj/setter/simple/intval/test03.json | 4 + .../mod2obj/setter/simple/longval/test01.json | 4 + .../mod2obj/setter/simple/longval/test02.json | 4 + .../mod2obj/setter/simple/longval/test03.json | 4 + .../setter/simple/shortval/test01.json | 4 + .../setter/simple/shortval/test02.json | 4 + .../setter/simple/shortval/test03.json | 4 + .../setter/simple/shortval/test04.json | 4 + .../mod2obj/setter/simple/strval/test01.json | 3 + 260 files changed, 9623 insertions(+), 1333 deletions(-) create mode 100644 src/test/java/daxi/moe/test/json/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/JsonMod2ObjTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/semantics/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn01/InvalidEntity02.java => json/mod2obj/semantics/Root02.java} (77%) create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/BooleanRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/IntRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/ColNested.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root01.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root02.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn03/StringEntity.java => json/mod2obj/setter/linear/objval/StringNested.java} (86%) create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/StringRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/BlankNested.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/Root.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/IntNested.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/Root.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/Root.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn02/NopopEntity01.java => json/mod2obj/setter/mapped/strval/StringNested.java} (81%) create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/BigDecimalRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/BigIntegerRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/BooleanRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/ByteRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/DoubleRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/FloatRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/IntegerRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/LongRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/ShortRoot.java create mode 100644 src/test/java/daxi/moe/test/json/mod2obj/setter/simple/strval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn02/NopopEntity03.java => json/mod2obj/setter/simple/strval/StringRoot.java} (80%) rename src/test/java/daxi/moe/test/{scenario/delta => mem}/AllTests.java (63%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/MemMod2ObjTests.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/semantics/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot01.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot02.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn01/InvalidEntity03.java => mem/mod2obj/semantics/InvalidRoot03.java} (76%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn02/NopopEntity02.java => mem/mod2obj/setter/semantics/Nested.java} (82%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root01.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root02.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root03.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root04.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root05.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root06.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root07.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root08.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bdecval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn11/BigDecimalEntity.java => mem/mod2obj/setter/simple/bdecval/BigDecimalRoot.java} (87%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bintval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn10/BigIntegerEntity.java => mem/mod2obj/setter/simple/bintval/BigIntegerRoot.java} (87%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/boolval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn03/BooleanEntity.java => mem/mod2obj/setter/simple/boolval/BooleanRoot.java} (81%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/byteval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn04/ByteEntity.java => mem/mod2obj/setter/simple/byteval/ByteRoot.java} (81%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/doubleval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn09/DoubleEntity.java => mem/mod2obj/setter/simple/doubleval/DoubleRoot.java} (89%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/floatval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn07/FloatEntity.java => mem/mod2obj/setter/simple/floatval/FloatRoot.java} (89%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/intval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn06/IntegerEntity.java => mem/mod2obj/setter/simple/intval/IntegerRoot.java} (89%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/longval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn08/LongEntity.java => mem/mod2obj/setter/simple/longval/LongRoot.java} (89%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/shortval/AllTests.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn05/ShortEntity.java => mem/mod2obj/setter/simple/shortval/ShortRoot.java} (89%) create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/StringRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/MemObj2ModTests.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntArrayRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntListRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntSetRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringArrayRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringListRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringSetRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/semantics/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/semantics/BadObject01.java rename src/test/java/daxi/moe/test/{scenario/alfa/scn01/InvalidEntity01.java => mem/obj2mod/semantics/BlankObject01.java} (72%) create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject02.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject03.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject04.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/semantics/GoodObject.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/BigDecimalRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/BigIntegerRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/BooleanRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/DoubleRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/FloatRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/IntegerRoot.java create mode 100644 src/test/java/daxi/moe/test/mem/obj2mod/simple/LongRoot.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/Check.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/generic/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/generic/Nested.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot03.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/generic/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/generic/Root01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/generic/Root02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem03.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem04.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem05.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem06.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/NestedItem.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root03.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root04.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root05.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root06.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nmap/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nmap/ListItem.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/nmap/Root01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/simple/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/simple/Root01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/simple/Root02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/simple/Root03.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/simple/Root04.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/linear/simple/ValueObject.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/pstr/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringNested.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringRoot.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodNested.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodRoot.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested03.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested04.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested05.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested06.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/NestedEntity10.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/PType.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root03.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root04.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root05.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root06.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/mapped/semantic/RootEntity10.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/Nested.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/AllTests.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root01.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root02.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root03.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root04.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root05.java create mode 100644 src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root06.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn01/MemInvalidEntityTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn02/MemIncorrectSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn03/MemSimpleSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn04/MemByteSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn05/MemShortSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn06/MemIntegerSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn07/MemFloatSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn08/MemLongSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn09/MemDoubleSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn10/MemBigIntegerSetterTests.java delete mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn11/MemBigDecimalSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/MemCodecTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/MappedSetterTests.java rename src/test/java/daxi/moe/test/scenario/{alfa/scn02/ValidEntity.java => mem/s0402_mapped_setter/NestedEntity01.java} (74%) create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/NestedEntity02.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity01.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity02.java rename src/test/java/daxi/moe/test/scenario/{charlie/AllTests.java => mem/s0403_mapped_setter_bool/MappedSetterBooleanTests.java} (64%) create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/BadBlankMapperTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested01.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested02.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested03.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested04.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root01.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root02.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root03.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root04.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/State.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNested.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNestedP.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/MappedBlankTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested01.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested02.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested03.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested04.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root01.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root02.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root03.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root04.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedA.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedB.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/simple/strput/AllTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/mem/simple/strput/Root.java rename src/test/java/daxi/moe/test/scenario/{bravo => mem/simple/strset}/AllTests.java (66%) create mode 100644 testdata/json/mod2obj/semantics/bad01.json create mode 100644 testdata/json/mod2obj/semantics/good.json create mode 100644 testdata/json/mod2obj/setter/linear/boolval/test01.json create mode 100644 testdata/json/mod2obj/setter/linear/intval/test01.json create mode 100644 testdata/json/mod2obj/setter/linear/objval/test01.json create mode 100644 testdata/json/mod2obj/setter/linear/objval/test02.json create mode 100644 testdata/json/mod2obj/setter/linear/strval/test01.json create mode 100644 testdata/json/mod2obj/setter/mapped/blank/test01.json create mode 100644 testdata/json/mod2obj/setter/mapped/intval/test01.json create mode 100644 testdata/json/mod2obj/setter/mapped/intval/test02.json create mode 100644 testdata/json/mod2obj/setter/mapped/intval/test03.json create mode 100644 testdata/json/mod2obj/setter/mapped/strval/test01.json create mode 100644 testdata/json/mod2obj/setter/mapped/strval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/bdecval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/bdecval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/bdecval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/bdecval/test04.json create mode 100644 testdata/json/mod2obj/setter/simple/bintval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/bintval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/bintval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/bintval/test04.json create mode 100644 testdata/json/mod2obj/setter/simple/bintval/test05.json create mode 100644 testdata/json/mod2obj/setter/simple/boolval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/boolval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/byteval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/byteval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/byteval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/byteval/test04.json create mode 100644 testdata/json/mod2obj/setter/simple/doubleval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/doubleval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/doubleval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/floatval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/floatval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/floatval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/intval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/intval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/intval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/longval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/longval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/longval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/shortval/test01.json create mode 100644 testdata/json/mod2obj/setter/simple/shortval/test02.json create mode 100644 testdata/json/mod2obj/setter/simple/shortval/test03.json create mode 100644 testdata/json/mod2obj/setter/simple/shortval/test04.json create mode 100644 testdata/json/mod2obj/setter/simple/strval/test01.json diff --git a/build.gradle b/build.gradle index 1b4ce5d..d99069e 100644 --- a/build.gradle +++ b/build.gradle @@ -28,18 +28,23 @@ repositories { } dependencies { + implementation "daxi.moe:daxi.moe.api:v1-SNAPSHOT" implementation "daxi.moe:daxi.moe.main:v1-SNAPSHOT" + implementation "daxi.moe:daxi.moe.json:v1-SNAPSHOT" implementation "org.junit.jupiter:junit-jupiter:5.10.2" implementation "org.junit.platform:junit-platform-launcher:1.10.2" implementation "org.slf4j:jul-to-slf4j:2.0.7" - implementation "ch.qos.logback:logback-classic:1.4.6" + implementation 'ch.qos.logback:logback-classic:1.6.3' implementation "org.codehaus.janino:janino:3.1.9" } tasks.named("test", Test) { - useJUnitPlatform() + useJUnitPlatform() { + //includeTags "json-mod2obj", "mem-mod2obj" + //includeTags "json-mod2obj" + } systemProperty "junit.jupiter.extensions.autodetection.enabled", "true" /* diff --git a/src/test/java/daxi/moe/test/json/AllTests.java b/src/test/java/daxi/moe/test/json/AllTests.java new file mode 100644 index 0000000..4cf3672 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/AllTests.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json; + +import daxi.moe.app.External; +import daxi.moe.app.Internal; +import daxi.moe.app.Moe; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@Tag("json-mod2obj") +@DisplayName("[JSON Codec] The codec is loaded to convert data between JSON and the model") +public class AllTests extends AbstractTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[JSON Codec] Codec is loaded") + public void test01() { + Moe moe = Moe.create(); + External extern = moe.external("json"); + Assertions.assertNotNull(extern); + + Internal intern = moe.internal("json"); + Assertions.assertNotNull(intern); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/JsonMod2ObjTests.java b/src/test/java/daxi/moe/test/json/mod2obj/JsonMod2ObjTests.java new file mode 100644 index 0000000..37cce67 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/JsonMod2ObjTests.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj; + +import daxi.moe.app.External; +import daxi.moe.app.Moe; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; + +import java.io.File; +import java.nio.file.Files; +import java.util.logging.Logger; + +/** + * This class is a placeholder for the test suite that will be used to test the JSON codec + * functionality. It extends AbstractTests, which provides common setup and utility methods for the + * tests. + * + * @author indroneel + */ + +@Tag("json-mod2obj") +public class JsonMod2ObjTests extends AbstractTests { + + private static final Logger L = Logger.getLogger(JsonMod2ObjTests.class.getName()); + + private External extern; + + @BeforeEach + public final void beforeEach() { + L.info("beforeEach - resetting the test environment"); + Moe moe = Moe.create(); + extern = moe.external("json"); + Assertions.assertNotNull(extern); + } + + protected void loadExternal(String path) throws Exception { + File f = new File(path); + byte[] jsonData = Files.readAllBytes(f.toPath()); + external().from(jsonData); + } + + protected final External external() { + return extern; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/semantics/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/semantics/AllTests.java new file mode 100644 index 0000000..36186f4 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/semantics/AllTests.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.semantics; + +import daxi.moe.app.CodecException; +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Basic Semantics Tests") +public class AllTests extends JsonMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Invalid JSON data should throw CodecException") + public void test01() { + Assertions.assertThrows(CodecException.class, () -> { + loadExternal("testdata/json/mod2obj/semantics/bad01.json"); + }); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Valid JSON data should be converted successfully") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/semantics/good.json"); + }); + + Root02 root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root02.class); + }); + Assertions.assertNotNull(root); + + Assertions.assertEquals("str-val-01", root.getMember1()); + Assertions.assertEquals("str-val-02", root.getMember2()); + Assertions.assertEquals(100, root.getMember3()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity02.java b/src/test/java/daxi/moe/test/json/mod2obj/semantics/Root02.java similarity index 77% rename from src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity02.java rename to src/test/java/daxi/moe/test/json/mod2obj/semantics/Root02.java index 57a5c05..69279f7 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity02.java +++ b/src/test/java/daxi/moe/test/json/mod2obj/semantics/Root02.java @@ -12,28 +12,28 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn01; +package daxi.moe.test.json.mod2obj.semantics; import daxi.moe.app.MapFrom; -public class InvalidEntity02 { +public class Root02 { private String member1; private String member2; - - public InvalidEntity02(String member1, String member2) { - this.member1 = member1; - this.member2 = member2; - } + private int member3; public String getMember1() { return member1; } - public String getMember2() { + public String getMember2() { return member2; } + public int getMember3() { + return member3; + } + @MapFrom("member1") private void _setMember1(String value) { member1 = value; @@ -43,4 +43,9 @@ public class InvalidEntity02 { private void _setMember2(String value) { member2 = value; } + + @MapFrom("member3") + private void _setMember3(int value) { + member3 = value; + } } diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/AllTests.java new file mode 100644 index 0000000..ca5cf29 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/AllTests.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.boolval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with collection of integer Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with integer collection is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/linear/boolval/test01.json"); + }); + + BooleanRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BooleanRoot.class); + }); + + List members = root.getMembers(); + Assertions.assertFalse(members.isEmpty()); + Assertions.assertEquals(true, members.get(0)); + Assertions.assertEquals(false, members.get(1)); + Assertions.assertEquals(true, members.get(2)); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/BooleanRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/BooleanRoot.java new file mode 100644 index 0000000..fe238da --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/boolval/BooleanRoot.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.boolval; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class BooleanRoot { + + private final List members = new ArrayList<>(); + + public List getMembers() { + return members; + } + + @MapFrom("members") + private void _setMember(boolean value) { + members.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/AllTests.java new file mode 100644 index 0000000..fcfa0e8 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/AllTests.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.intval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with collection of integer Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with integer collection is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/linear/intval/test01.json"); + }); + + IntRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(IntRoot.class); + }); + + List members = root.getMembers(); + Assertions.assertFalse(members.isEmpty()); + Assertions.assertEquals(100, members.get(0)); + Assertions.assertEquals(112, members.get(1)); + Assertions.assertEquals(120, members.get(2)); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/IntRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/IntRoot.java new file mode 100644 index 0000000..7b93c73 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/intval/IntRoot.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.intval; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class IntRoot { + + private final List members = new ArrayList<>(); + + public List getMembers() { + return members; + } + + @MapFrom("members") + private void _setMember(int value) { + members.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/AllTests.java new file mode 100644 index 0000000..34cd577 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/AllTests.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.objval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods for collection of mapped Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Nested mapped value is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/linear/objval/test01.json"); + }); + + Root01 root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root01.class); + }); + + List nested = root.getNested(); + Assertions.assertNotNull(nested); + Assertions.assertEquals(2, nested.size()); + Assertions.assertEquals("str-val-01", nested.get(0).getMember1()); + Assertions.assertEquals("str-val-02", nested.get(1).getMember1()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Nested collection of mapped values is populated") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/linear/objval/test02.json"); + }); + + Root02 root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root02.class); + }); + + List nested = root.getNested(); + Assertions.assertNotNull(nested); + Assertions.assertEquals(2, nested.size()); + + List strNested1 = nested.get(0).getItems(); + Assertions.assertNotNull(strNested1); + Assertions.assertEquals(2, strNested1.size()); + Assertions.assertEquals("str-val-01", strNested1.get(0).getMember1()); + Assertions.assertEquals("str-val-02", strNested1.get(1).getMember1()); + + List strNested2 = nested.get(1).getItems(); + Assertions.assertNotNull(strNested2); + Assertions.assertEquals(2, strNested2.size()); + Assertions.assertEquals("str-val-03", strNested2.get(0).getMember1()); + Assertions.assertEquals("str-val-04", strNested2.get(1).getMember1()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/ColNested.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/ColNested.java new file mode 100644 index 0000000..8c39aa8 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/ColNested.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.objval; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class ColNested { + + private final List items; + + public ColNested() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(StringNested item) { + items.add(item); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root01.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root01.java new file mode 100644 index 0000000..e16997c --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root01.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.objval; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class Root01 { + + private final List nested; + + public Root01() { + nested = new ArrayList<>(); + } + + public List getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(StringNested value) { + nested.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root02.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root02.java new file mode 100644 index 0000000..938125c --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/Root02.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.objval; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class Root02 { + + private final List nested; + + public Root02() { + nested = new ArrayList<>(); + } + + public List getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(ColNested value) { + nested.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn03/StringEntity.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/StringNested.java similarity index 86% rename from src/test/java/daxi/moe/test/scenario/alfa/scn03/StringEntity.java rename to src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/StringNested.java index 5b8a776..9a45db2 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn03/StringEntity.java +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/objval/StringNested.java @@ -12,18 +12,18 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn03; +package daxi.moe.test.json.mod2obj.setter.linear.objval; import daxi.moe.app.MapFrom; -public class StringEntity { +/** + * @author indroneel + */ + +public class StringNested { private String member1; - public StringEntity() { - //NOOP - } - public String getMember1() { return member1; } diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/AllTests.java new file mode 100644 index 0000000..6b15bfa --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/AllTests.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.strval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with collection of String Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with String collection is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/linear/strval/test01.json"); + }); + + StringRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(StringRoot.class); + }); + + List members = root.getMembers(); + Assertions.assertFalse(members.isEmpty()); + Assertions.assertEquals("first", members.get(0)); + Assertions.assertEquals("second", members.get(1)); + Assertions.assertEquals("third", members.get(2)); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/StringRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/StringRoot.java new file mode 100644 index 0000000..8300421 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/linear/strval/StringRoot.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.linear.strval; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class StringRoot { + + private final List members = new ArrayList<>(); + + public List getMembers() { + return members; + } + + @MapFrom("members") + private void _setMember(String value) { + members.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/AllTests.java new file mode 100644 index 0000000..023b076 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/AllTests.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.blank; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Blank Mapped method for Nested String values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Nested blank mapped String values are populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/mapped/blank/test01.json"); + }); + + Root root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root.class); + }); + + BlankNested nested = root.getNested(); + Assertions.assertNotNull(nested); + Map members = nested.getMembers(); + Assertions.assertEquals(2, members.size()); + Assertions.assertEquals("str-val-01", members.get("member1")); + Assertions.assertEquals("str-val-02", members.get("member2")); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/BlankNested.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/BlankNested.java new file mode 100644 index 0000000..386fc20 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/BlankNested.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.blank; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author indroneel + */ + +public class BlankNested { + + private final Map members; + + public BlankNested() { + members = new HashMap<>(); + } + + public Map getMembers() { + return members; + } + + @MapFrom + private void _setMe(String key, String value) { + members.put(key, value); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/Root.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/Root.java new file mode 100644 index 0000000..c2b2627 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/blank/Root.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.blank; + +import daxi.moe.app.MapFrom; + +public class Root { + + private BlankNested nested; + + public BlankNested getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(BlankNested value) { + nested = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/AllTests.java new file mode 100644 index 0000000..4f11f55 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/AllTests.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.intval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with int/Integer Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with int/Integer setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/mapped/intval/test01.json"); + }); + + Root root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root.class); + }); + + IntNested nested = root.getNested(); + Assertions.assertNotNull(nested); + Assertions.assertEquals(100, nested.getMember1()); + Assertions.assertEquals(200, nested.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with int/Integer setters is populated from string " + + "values") + public void test02() throws Exception { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/mapped/intval/test02.json"); + }); + + Root root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root.class); + }); + + IntNested nested = root.getNested(); + Assertions.assertNotNull(nested); + Assertions.assertEquals(1000, nested.getMember1()); + Assertions.assertEquals(2000, nested.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with int/Integer setters is not populated from " + + "non-numeric String values") + public void test03() throws Exception { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/mapped/intval/test03.json"); + }); + + Root root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root.class); + }); + + IntNested nested = root.getNested(); + Assertions.assertNotNull(nested); + Assertions.assertEquals(0, nested.getMember1()); + Assertions.assertNull(nested.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/IntNested.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/IntNested.java new file mode 100644 index 0000000..aa72bdc --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/IntNested.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.intval; + +import daxi.moe.app.MapFrom; + +public class IntNested { + + private int member1; + private Integer member2; + + public int getMember1() { + return member1; + } + + public Integer getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(int value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Integer value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/Root.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/Root.java new file mode 100644 index 0000000..849824c --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/intval/Root.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.intval; + +import daxi.moe.app.MapFrom; + +public class Root { + + private IntNested nested; + + public IntNested getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(IntNested value) { + nested = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/AllTests.java new file mode 100644 index 0000000..34382da --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/AllTests.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.strval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods for Nested mapped String values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Nested mapped String value is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/mapped/strval/test01.json"); + }); + + Root root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root.class); + }); + + StringNested nested = root.getNested(); + Assertions.assertNotNull(nested); + Assertions.assertEquals("str-val-01", nested.getMember1()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Nested mapped String value is not populated with simple data") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/mapped/strval/test02.json"); + }); + + Root root = Assertions.assertDoesNotThrow(() -> { + return external().convert(Root.class); + }); + + StringNested nested = root.getNested(); + Assertions.assertNull(nested); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/Root.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/Root.java new file mode 100644 index 0000000..2e3ffef --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/Root.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.mapped.strval; + +import daxi.moe.app.MapFrom; + +public class Root { + + private StringNested nested; + + public StringNested getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(StringNested value) { + nested = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity01.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/StringNested.java similarity index 81% rename from src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity01.java rename to src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/StringNested.java index 3f4cf60..4ff308f 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity01.java +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/mapped/strval/StringNested.java @@ -12,24 +12,24 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn02; +package daxi.moe.test.json.mod2obj.setter.mapped.strval; import daxi.moe.app.MapFrom; -public class NopopEntity01 { +/** + * @author indroneel + */ + +public class StringNested { private String member1; - public NopopEntity01() { - //NOOP - } - public String getMember1() { return member1; } @MapFrom("member1") - private void setMember1(String value) { + private void _setMe(String value) { member1 = value; } } diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/AllTests.java new file mode 100644 index 0000000..f806aa1 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/AllTests.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.bdecval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with BigDecimal Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with BigDecimal setters is populated from decimal " + + "values") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bdecval/test01.json"); + }); + + BigDecimalRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigDecimalRoot.class); + }); + + Assertions.assertEquals(new BigDecimal("12345.6789"), root.getMember1()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with BigDecimal setters is populated from integer " + + "values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bdecval/test02.json"); + }); + + BigDecimalRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigDecimalRoot.class); + }); + + Assertions.assertEquals(new BigDecimal("12345678901234567890"), root.getMember1()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with BigDecimal setters is populated from precise " + + "string values") + public void test03() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bdecval/test03.json"); + }); + + BigDecimalRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigDecimalRoot.class); + }); + + Assertions.assertEquals(new BigDecimal("123456789012345678901234567890.123"), + root.getMember1()); + } + + @Test + @Order(4) + @DisplayName("[JSON Model2Object] Entity with BigDecimal setters is not populated from " + + "non-numeric String values") + public void test04() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bdecval/test04.json"); + }); + + BigDecimalRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigDecimalRoot.class); + }); + + Assertions.assertNull(root.getMember1()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/BigDecimalRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/BigDecimalRoot.java new file mode 100644 index 0000000..1157bf2 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bdecval/BigDecimalRoot.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.bdecval; + +import daxi.moe.app.MapFrom; + +import java.math.BigDecimal; + +public class BigDecimalRoot { + + private BigDecimal member1; + + public BigDecimalRoot() { + //NOOP + } + + public BigDecimal getMember1() { + return member1; + } + + @MapFrom("member1") + private void _setMe(BigDecimal value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/AllTests.java new file mode 100644 index 0000000..a8f219a --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/AllTests.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.bintval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.math.BigInteger; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with BigInteger Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with BigInteger setters is populated from integer " + + "values") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bintval/test01.json"); + }); + + BigIntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigIntegerRoot.class); + }); + + Assertions.assertEquals(new BigInteger("1234567890123"), root.getMember1()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with BigInteger setters is populated from decimal " + + "values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bintval/test02.json"); + }); + + BigIntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigIntegerRoot.class); + }); + + Assertions.assertEquals(BigInteger.valueOf(123), root.getMember1()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with BigInteger setters is populated from large " + + "string values") + public void test03() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bintval/test03.json"); + }); + + BigIntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigIntegerRoot.class); + }); + + Assertions.assertEquals(new BigInteger("123456789012345678901234567890"), + root.getMember1()); + } + + @Test + @Order(4) + @DisplayName("[JSON Model2Object] Entity with BigInteger setters is not populated from " + + "non-numeric String values") + public void test04() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bintval/test04.json"); + }); + + BigIntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigIntegerRoot.class); + }); + + Assertions.assertNull(root.getMember1()); + } + + @Test + @Order(5) + @DisplayName("[JSON Model2Object] Entity with BigInteger setters is populated from really " + + "large values that exceed the range of integer") + public void test05() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/bintval/test05.json"); + }); + + BigIntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BigIntegerRoot.class); + }); + + Assertions.assertEquals(new BigInteger("123456789012345678901234567890"), + root.getMember1()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/BigIntegerRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/BigIntegerRoot.java new file mode 100644 index 0000000..425d5f8 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/bintval/BigIntegerRoot.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.bintval; + +import daxi.moe.app.MapFrom; + +import java.math.BigInteger; + +/** + * @author indroneel + */ + +public class BigIntegerRoot { + + private BigInteger member1; + + public BigIntegerRoot() { + //NOOP + } + + public BigInteger getMember1() { + return member1; + } + + @MapFrom("member1") + private void _setMe(BigInteger value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/AllTests.java new file mode 100644 index 0000000..8071b2b --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/AllTests.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.boolval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with boolean Values") +public class AllTests extends JsonMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with boolean/Boolean setters is created") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/boolval/test01.json"); + }); + + BooleanRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BooleanRoot.class); + }); + + Assertions.assertTrue(root.isMember1()); + Assertions.assertTrue(root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with boolean/Boolean setters is created from" + + " true/false string values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/boolval/test02.json"); + }); + + BooleanRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(BooleanRoot.class); + }); + + Assertions.assertTrue(root.isMember1()); + Assertions.assertTrue(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/BooleanRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/BooleanRoot.java new file mode 100644 index 0000000..10011bb --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/boolval/BooleanRoot.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.boolval; + +import daxi.moe.app.MapFrom; + +public class BooleanRoot { + + private boolean member1; + private Boolean member2; + + public BooleanRoot() { + //NOOP + } + + public boolean isMember1() { + return member1; + } + + public Boolean getMember2() { + return member2; + } + + @MapFrom("member1") + private void first(boolean value) { + member1 = value; + } + + @MapFrom("member2") + private void second(Boolean value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/AllTests.java new file mode 100644 index 0000000..7a5bf36 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/AllTests.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.byteval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with byte/Byte Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with byte/Byte setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/byteval/test01.json"); + }); + + ByteRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ByteRoot.class); + }); + + Assertions.assertEquals((byte) 26, root.getMember1()); + Assertions.assertEquals(Byte.valueOf((byte) 27), root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with byte/Byte setters is populated from String " + + "values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/byteval/test02.json"); + }); + + ByteRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ByteRoot.class); + }); + + Assertions.assertEquals((byte) -128, root.getMember1()); + Assertions.assertEquals(Byte.valueOf((byte) 127), root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with byte/Byte setters is not populated from " + + "non-numeric String values") + public void test03() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/byteval/test03.json"); + }); + + ByteRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ByteRoot.class); + }); + + Assertions.assertEquals((byte) 0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } + + @Test + @Order(4) + @DisplayName("[JSON Model2Object] Entity with byte/Byte setters is populated with loss of " + + "precision") + public void test04() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/byteval/test04.json"); + }); + + ByteRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ByteRoot.class); + }); + + Assertions.assertEquals((byte) 1, root.getMember1()); + Assertions.assertEquals((byte) 2, root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/ByteRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/ByteRoot.java new file mode 100644 index 0000000..9948690 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/byteval/ByteRoot.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.byteval; + +import daxi.moe.app.MapFrom; + +public class ByteRoot { + + private byte member1; + private Byte member2; + + public ByteRoot() { + //NOOP + } + + public byte getMember1() { + return member1; + } + + public Byte getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMember1(byte value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMember2(Byte value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/AllTests.java new file mode 100644 index 0000000..0902be7 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/AllTests.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.doubleval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with double/Double Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with double/Double setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/doubleval/test01.json"); + }); + + DoubleRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(DoubleRoot.class); + }); + + Assertions.assertEquals(12.234d, root.getMember1()); + Assertions.assertEquals(-987.0, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with double/Double setters is populated from string " + + "values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/doubleval/test02.json"); + }); + + DoubleRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(DoubleRoot.class); + }); + + Assertions.assertEquals(12345.625, root.getMember1()); + Assertions.assertEquals(-0.125, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with double/Double setters is not populated from " + + "non-numeric String values") + public void test03() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/doubleval/test03.json"); + }); + + DoubleRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(DoubleRoot.class); + }); + + Assertions.assertEquals(0.0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/DoubleRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/DoubleRoot.java new file mode 100644 index 0000000..fd39350 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/doubleval/DoubleRoot.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.doubleval; + +import daxi.moe.app.MapFrom; + +public class DoubleRoot { + + private double member1; + private Double member2; + + public DoubleRoot() { + //NOOP + } + + public double getMember1() { + return member1; + } + + public Double getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(double value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Double value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/AllTests.java new file mode 100644 index 0000000..8f9729a --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/AllTests.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.floatval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with float/Float Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with float/Float setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/floatval/test01.json"); + }); + + FloatRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(FloatRoot.class); + }); + + Assertions.assertEquals(12.0f, root.getMember1()); + Assertions.assertEquals(-987.0f, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with float/Float setters is populated from string " + + "values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/floatval/test02.json"); + }); + + FloatRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(FloatRoot.class); + }); + + Assertions.assertEquals(12345.625f, root.getMember1()); + Assertions.assertEquals(-0.125f, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with float/Float setters is not populated from " + + "non-numeric String values") + public void test03() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/floatval/test03.json"); + }); + + FloatRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(FloatRoot.class); + }); + + Assertions.assertEquals(0.0f, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/FloatRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/FloatRoot.java new file mode 100644 index 0000000..3d6e346 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/floatval/FloatRoot.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.floatval; + +import daxi.moe.app.MapFrom; + +public class FloatRoot { + + private float member1; + private Float member2; + + public FloatRoot() { + //NOOP + } + + public float getMember1() { + return member1; + } + + public Float getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(float value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Float value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/AllTests.java new file mode 100644 index 0000000..c49943a --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/AllTests.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.intval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with int/Integer Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with int/Integer setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/intval/test01.json"); + }); + + IntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(IntegerRoot.class); + }); + + Assertions.assertEquals(100, root.getMember1()); + Assertions.assertEquals(200, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with int/Integer setters is populated from string " + + "values") + public void test02() throws Exception { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/intval/test02.json"); + }); + + IntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(IntegerRoot.class); + }); + + Assertions.assertEquals(1000, root.getMember1()); + Assertions.assertEquals(2000, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with int/Integer setters is not populated from " + + "non-numeric String values") + public void test03() throws Exception { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/intval/test03.json"); + }); + + IntegerRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(IntegerRoot.class); + }); + + Assertions.assertEquals(0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/IntegerRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/IntegerRoot.java new file mode 100644 index 0000000..a88da02 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/intval/IntegerRoot.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.intval; + +import daxi.moe.app.MapFrom; + +public class IntegerRoot { + + private int member1; + private Integer member2; + + public IntegerRoot() { + //NOOP + } + + public int getMember1() { + return member1; + } + + public Integer getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(int value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Integer value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/AllTests.java new file mode 100644 index 0000000..594e7a1 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/AllTests.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.longval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with long/Long Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with long/Long setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/longval/test01.json"); + }); + + LongRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(LongRoot.class); + }); + + Assertions.assertEquals(1234567890123L, root.getMember1()); + Assertions.assertEquals(9876543210987L, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with long/Long setters is populated from string " + + "values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/longval/test02.json"); + }); + + LongRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(LongRoot.class); + }); + + Assertions.assertEquals(12345678901234L, root.getMember1()); + Assertions.assertEquals(98765432109876L, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with long/Long setters is not populated from " + + "non-numeric String values") + public void test03() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/longval/test03.json"); + }); + + LongRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(LongRoot.class); + }); + + Assertions.assertEquals(0L, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/LongRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/LongRoot.java new file mode 100644 index 0000000..970f60e --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/longval/LongRoot.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.longval; + +import daxi.moe.app.MapFrom; + +public class LongRoot { + + private long member1; + private Long member2; + + public LongRoot() { + //NOOP + } + + public long getMember1() { + return member1; + } + + public Long getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(long value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Long value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/AllTests.java new file mode 100644 index 0000000..3b8aa05 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/AllTests.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.shortval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with short/Short Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with short/Short setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/shortval/test01.json"); + }); + + ShortRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ShortRoot.class); + }); + + Assertions.assertEquals((short) 16343, root.getMember1()); + Assertions.assertEquals(Short.valueOf((short) 2048), root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[JSON Model2Object] Entity with short/Short setters is populated from String " + + "values") + public void test02() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/shortval/test02.json"); + }); + + ShortRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ShortRoot.class); + }); + + Assertions.assertEquals(Short.MIN_VALUE, root.getMember1()); + Assertions.assertEquals(Short.valueOf(Short.MAX_VALUE), root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[JSON Model2Object] Entity with short/Short setters is not populated from " + + "non-numeric String values") + public void test03() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/shortval/test03.json"); + }); + + ShortRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ShortRoot.class); + }); + + Assertions.assertEquals((short) 0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } + + @Test + @Order(4) + @DisplayName("[JSON Model2Object] Entity with short/Short setters is populated with loss of " + + "precision") + public void test04() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/shortval/test04.json"); + }); + + ShortRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(ShortRoot.class); + }); + + Assertions.assertEquals((short) -32767, root.getMember1()); + Assertions.assertEquals(Short.valueOf((short) -32766), root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/ShortRoot.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/ShortRoot.java new file mode 100644 index 0000000..5eb8405 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/shortval/ShortRoot.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.shortval; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class ShortRoot { + + private short member1; + private Short member2; + + public ShortRoot() { + //NOOP + } + + public short getMember1() { + return member1; + } + + public Short getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(short value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Short value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/strval/AllTests.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/strval/AllTests.java new file mode 100644 index 0000000..68fbe56 --- /dev/null +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/strval/AllTests.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.json.mod2obj.setter.simple.strval; + +import daxi.moe.test.json.mod2obj.JsonMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +/** + * @author indroneel + */ + +@DisplayName("[JSON Model2Object] Setter methods with String Values") +public class AllTests extends JsonMod2ObjTests { + + @Test + @Order(1) + @DisplayName("[JSON Model2Object] Entity with String setters is populated") + public void test01() { + Assertions.assertDoesNotThrow(() -> { + loadExternal("testdata/json/mod2obj/setter/simple/strval/test01.json"); + }); + + StringRoot root = Assertions.assertDoesNotThrow(() -> { + return external().convert(StringRoot.class); + }); + + Assertions.assertEquals("str-val-01", root.getMember1()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity03.java b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/strval/StringRoot.java similarity index 80% rename from src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity03.java rename to src/test/java/daxi/moe/test/json/mod2obj/setter/simple/strval/StringRoot.java index 6f004e7..b032da5 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity03.java +++ b/src/test/java/daxi/moe/test/json/mod2obj/setter/simple/strval/StringRoot.java @@ -12,24 +12,20 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn02; +package daxi.moe.test.json.mod2obj.setter.simple.strval; import daxi.moe.app.MapFrom; -public class NopopEntity03 { +public class StringRoot { private String member1; - public NopopEntity03() { - //NOOP - } - public String getMember1() { return member1; } @MapFrom("member1") - private void _setMember(String value, boolean flag) { + private void _setMember1(String value) { member1 = value; } } diff --git a/src/test/java/daxi/moe/test/scenario/delta/AllTests.java b/src/test/java/daxi/moe/test/mem/AllTests.java similarity index 63% rename from src/test/java/daxi/moe/test/scenario/delta/AllTests.java rename to src/test/java/daxi/moe/test/mem/AllTests.java index 975f389..d7f4f00 100644 --- a/src/test/java/daxi/moe/test/scenario/delta/AllTests.java +++ b/src/test/java/daxi/moe/test/mem/AllTests.java @@ -12,11 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.delta; +package daxi.moe.test.mem; +import daxi.moe.app.External; +import daxi.moe.app.Internal; +import daxi.moe.app.Moe; import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.logging.Logger; @@ -25,20 +30,21 @@ import java.util.logging.Logger; * @author indroneel */ -@DisplayName("Tests Delta") +@Tag("mem-mod2obj") +@DisplayName("[MEM Codec] The codec is loaded to convert data between JSON and the model") public class AllTests extends AbstractTests { private static final Logger L = Logger.getLogger(AllTests.class.getName()); @Test @Order(1) + @DisplayName("[JSON Codec] Codec is loaded") public void test01() { + Moe moe = Moe.create(); + External extern = moe.external("mem"); + Assertions.assertNotNull(extern); - } - - @Test - @Order(2) - public void test02() { - + Internal intern = moe.internal("mem"); + Assertions.assertNotNull(intern); } } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/MemMod2ObjTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/MemMod2ObjTests.java new file mode 100644 index 0000000..c82d9b7 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/MemMod2ObjTests.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj; + +import daxi.moe.app.External; +import daxi.moe.app.Moe; +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; + +import java.util.logging.Logger; + +/** + * This class is a placeholder for the test suite that will be used to test the model to object + * transfer functionalities. It extends AbstractTests, which provides common setup and utility + * methods for the tests. + * + * @author indroneel + */ + +@Tag("mem-mod2obj") +public class MemMod2ObjTests extends AbstractTests { + + private static final Logger L = Logger.getLogger(MemMod2ObjTests.class.getName()); + + private External extern; + private MappedData mainData; + + @BeforeEach + public final void beforeEach() { + L.info("beforeEach - resetting the test environment"); + Moe moe = Moe.create(); + extern = moe.external("mem"); + AnyData model = extern.getModel(); + mainData = model.asMapped(); + Assertions.assertNotNull(mainData); + } + + protected final External external() { + return extern; + } + + protected final MappedData mainData() { + return mainData; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/semantics/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/AllTests.java new file mode 100644 index 0000000..f54a64a --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/AllTests.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.semantics; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Basic validity checks for root entities") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity without @MapFrom annotations is not created") + public void test01() { + mainData().put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("member2", new AnyData(new SimpleData("string-value-02"))); + + InvalidRoot01 root = + Assertions.assertDoesNotThrow(() -> external().convert(InvalidRoot01.class)); + Assertions.assertNull(root); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity without a default constructor is not created") + public void test02() { + mainData().put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("member2", new AnyData(new SimpleData("string-value-02"))); + + InvalidRoot02 root = + Assertions.assertDoesNotThrow(() -> external().convert(InvalidRoot02.class)); + Assertions.assertNull(root); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity without a public default constructor is not created") + public void test03() { + mainData().put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("member2", new AnyData(new SimpleData("string-value-02"))); + + InvalidRoot03 root = + Assertions.assertDoesNotThrow(() -> external().convert(InvalidRoot03.class)); + Assertions.assertNull(root); + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot01.java b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot01.java new file mode 100644 index 0000000..52c99a7 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot01.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.semantics; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, but + * does not have any setter, blank mapped, or blank linear method. + * + * @author indroneel + */ + +public class InvalidRoot01 { + + private String member1; + private String member2; + + public InvalidRoot01() { + //NOOP + } + + public String getMember1() { + return member1; + } + + public String getMember2() { + return member2; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot02.java b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot02.java new file mode 100644 index 0000000..bff803e --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot02.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.semantics; + +import daxi.moe.app.MapFrom; + +/** + * An invalid root entity during model to object transfer. It has setter methods, but does not have + * a default constructor. + * + * @author indroneel + */ + +public class InvalidRoot02 { + + private String member1; + private String member2; + + public InvalidRoot02(String member1, String member2) { + this.member1 = member1; + this.member2 = member2; + } + + public String getMember1() { + return member1; + } + + public String getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMember1(String value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMember2(String value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity03.java b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot03.java similarity index 76% rename from src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity03.java rename to src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot03.java index 9d4b4af..6d90750 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity03.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/semantics/InvalidRoot03.java @@ -12,16 +12,23 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn01; +package daxi.moe.test.mem.mod2obj.semantics; import daxi.moe.app.MapFrom; -public class InvalidEntity03 { +/** + * An invalid root entity during model to object transfer. It has setter methods, but does not have + * a default constructor that is public. + * + * @author indroneel + */ + +public class InvalidRoot03 { private String member1; private String member2; - protected InvalidEntity03() { + protected InvalidRoot03() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/AllTests.java new file mode 100644 index 0000000..937e25e --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/AllTests.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.ConvertException; +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mod2obj.Check; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple setter semantics") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] setter method requires a @MapFrom annotation") + public void test01() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Root01 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNull(root); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] setter method must have private visibility") + public void test02() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Root02 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNull(root); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] setter method must return void") + public void test03() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Root03 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root03.class)); + Assertions.assertNull(root); + } + + @Test + @Order(4) + @DisplayName("[MEM Model2Object] setter method cannot have zero parameters") + public void test04() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Root04 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root04.class)); + Assertions.assertNull(root); + } + + @Test + @Order(5) + @DisplayName("[MEM Model2Object] setter method cannot have more than two parameters") + public void test05() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Root05 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root05.class)); + Assertions.assertNull(root); + } + + @Test + @Order(6) + @DisplayName("[MEM Model2Object] setter method cannot map SimpleData to objects") + public void test06() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Check.reset(); + Root06 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root06.class)); + Assertions.assertNotNull(root); + Assertions.assertFalse(Check.isSet()); + } + + @Test + @Order(7) + @DisplayName("[MEM Model2Object] setter method can throw an exception") + public void test07() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Check.reset(); + ConvertException exep = + Assertions.assertThrows( + ConvertException.class, () -> external().convert(Root07.class)); + } + + @Test + @Order(8) + @DisplayName("[MEM Model2Object] Two setter methods mapped to the same data key throw an exception") + public void test08() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + Check.reset(); + ConvertException exep = + Assertions.assertThrows( + ConvertException.class, () -> external().convert(Root08.class)); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity02.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Nested.java similarity index 82% rename from src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity02.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Nested.java index 055af62..ca10bd6 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity02.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Nested.java @@ -12,24 +12,24 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn02; +package daxi.moe.test.mem.mod2obj.setter.semantics; import daxi.moe.app.MapFrom; -public class NopopEntity02 { +/** + * @author indroneel + */ + +public class Nested { private String member1; - public NopopEntity02() { - //NOOP - } - public String getMember1() { return member1; } @MapFrom("member1") - private void _set(String value) { + private void _setMember1(String value) { member1 = value; } } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root01.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root01.java new file mode 100644 index 0000000..d4730dd --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root01.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, but + * does not have a setter that is annotated with {@link daxi.moe.app.MapFrom}. + * + * @author indroneel + */ + +public class Root01 { + + private String member; + + public Root01() { + //NOOP + } + + public String getMember() { + return member; + } + + private void _setMember(String value) { + member = value; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root02.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root02.java new file mode 100644 index 0000000..5cd5c49 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root02.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.MapFrom; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, and + * a setter method with public visibility. + * + * @author indroneel + */ + +public class Root02 { + + private String member; + + public Root02() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + public void _setMember(String value) { + member = value; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root03.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root03.java new file mode 100644 index 0000000..51eb9d8 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root03.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.MapFrom; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, and + * a setter method with private visibility that returns a value. + * + * @author indroneel + */ + +public class Root03 { + + private String member; + + public Root03() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + private int _setMember(String value) { + member = value; + return 0; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root04.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root04.java new file mode 100644 index 0000000..05f2372 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root04.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.MapFrom; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, and + * a setter method with private visibility and no parameters. + * + * @author indroneel + */ + +public class Root04 { + + private String member; + + public Root04() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + private void _setMember() { + member = "some value"; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root05.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root05.java new file mode 100644 index 0000000..bd9d98b --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root05.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.MapFrom; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, and + * a setter method with private visibility that takes multiple parameters. + * + * @author indroneel + */ + +public class Root05 { + + private String member; + + public Root05() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + private void _setMember(String value1, String value2, String value3) { + member = value1; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root06.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root06.java new file mode 100644 index 0000000..1443f87 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root06.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.MapFrom; +import daxi.moe.test.mod2obj.Check; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, and + * a setter method with private visibility and an object parameter. + * + * @author indroneel + */ + +public class Root06 { + + private String member; + + public Root06() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + private void _setMember(Nested nested) { + Check.set(); + member = "some value"; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root07.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root07.java new file mode 100644 index 0000000..e4b9c0d --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root07.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.MapFrom; + +/** + * An invalid root entity during model to object transfer. It has a public default constructor, and + * a setter method that throws an exception. + * + * @author indroneel + */ + +public class Root07 { + + private String member; + + public Root07() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + private void _setMember(String value) { + throw new RuntimeException("some-error"); + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root08.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root08.java new file mode 100644 index 0000000..45d68eb --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/semantics/Root08.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.semantics; + +import daxi.moe.app.MapFrom; + +/** + * An invalid root entity during model to object transfer. It has two setters mapped to the same + * data key. + * + * @author indroneel + */ + +public class Root08 { + + private String member; + + public Root08() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + private void _setMember1(String value) { + member = value; + } + + @MapFrom("member") + private void _setMember2(String value) { + member = value; + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bdecval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bdecval/AllTests.java new file mode 100644 index 0000000..3211d5d --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bdecval/AllTests.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.bdecval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.scenario.mem.MemCodecTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.util.Random; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple big decimal setters") +public class AllTests extends MemCodecTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with BigDecimal setters is created from double values") + public void test01() { + Random random = new Random(); + double val1 = random.nextDouble(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigDecimalRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigDecimalRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(BigDecimal.valueOf(val1), root.getMember1()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with BigDecimal setters is created from long values") + public void test02() { + Random random = new Random(); + long val1 = random.nextLong(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigDecimalRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigDecimalRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(BigDecimal.valueOf(val1), root.getMember1()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with BigDecimal setters is created from string values") + public void test03() { + Random random = new Random(); + String val1 = "123456789012345678901234567890.123"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigDecimalRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigDecimalRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(new BigDecimal(val1), root.getMember1()); + } + + @Test + @Order(4) + @DisplayName("[MEM Model2Object] Entity with BigDecimal setters is not created from " + + "non-numeric string values") + public void test04() { + String val1 = "bad big decimal"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigDecimalRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigDecimalRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertNull(root.getMember1()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn11/BigDecimalEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bdecval/BigDecimalRoot.java similarity index 87% rename from src/test/java/daxi/moe/test/scenario/alfa/scn11/BigDecimalEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bdecval/BigDecimalRoot.java index de95f2e..baa24e5 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn11/BigDecimalEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bdecval/BigDecimalRoot.java @@ -12,7 +12,7 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn11; +package daxi.moe.test.mem.mod2obj.setter.simple.bdecval; import daxi.moe.app.MapFrom; @@ -22,11 +22,11 @@ import java.math.BigDecimal; * @author indroneel */ -public class BigDecimalEntity { +public class BigDecimalRoot { private BigDecimal member1; - public BigDecimalEntity() { + public BigDecimalRoot() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bintval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bintval/AllTests.java new file mode 100644 index 0000000..c6af7a4 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bintval/AllTests.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.bintval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.math.BigInteger; +import java.util.Random; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple big integer setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with BigInteger setters is created from long values") + public void test01() { + Random random = new Random(); + long val1 = random.nextLong(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigIntegerRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigIntegerRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(BigInteger.valueOf(val1), root.getMember1()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with BigInteger setters is created from double values") + public void test02() { + Random random = new Random(); + double val1 = random.nextDouble(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigIntegerRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigIntegerRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(BigInteger.valueOf((long) val1), root.getMember1()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with BigInteger setters is created from string values") + public void test03() { + Random random = new Random(); + String val1 = "123456789012345678901234567890"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigIntegerRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigIntegerRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(new BigInteger(val1), root.getMember1()); + } + + @Test + @Order(4) + @DisplayName("[MEM Model2Object] Entity with BigInteger setters is not created from " + + "non-numeric string values") + public void test04() { + String val1 = "bad big integer"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + + BigIntegerRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BigIntegerRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertNull(root.getMember1()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn10/BigIntegerEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bintval/BigIntegerRoot.java similarity index 87% rename from src/test/java/daxi/moe/test/scenario/alfa/scn10/BigIntegerEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bintval/BigIntegerRoot.java index 78b22ae..5b1da16 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn10/BigIntegerEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/bintval/BigIntegerRoot.java @@ -12,7 +12,7 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn10; +package daxi.moe.test.mem.mod2obj.setter.simple.bintval; import daxi.moe.app.MapFrom; @@ -22,11 +22,11 @@ import java.math.BigInteger; * @author indroneel */ -public class BigIntegerEntity { +public class BigIntegerRoot { private BigInteger member1; - public BigIntegerEntity() { + public BigIntegerRoot() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/boolval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/boolval/AllTests.java new file mode 100644 index 0000000..b9b3a6d --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/boolval/AllTests.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.boolval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple boolean setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with boolean/Boolean setters is created") + public void test01() { + mainData().put("member1", new AnyData(new SimpleData(true))); + mainData().put("member2", new AnyData(new SimpleData(Boolean.TRUE))); + + BooleanRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BooleanRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertTrue(root.isMember1()); + Assertions.assertNotNull(root.getMember2()); + Assertions.assertEquals(Boolean.TRUE, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with boolean/Boolean setters is created from " + + "true/false string values") + public void test02() { + String val1 = "true"; + String val2 = "tRUe"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + BooleanRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BooleanRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertTrue(root.isMember1()); + Assertions.assertNotNull(root.getMember2()); + Assertions.assertEquals(Boolean.TRUE, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with boolean/Boolean setters is created from number " + + "values") + public void test03() { + int val1 = 100; + int val2 = 0; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + BooleanRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(BooleanRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertTrue(root.isMember1()); + Assertions.assertNotNull(root.getMember2()); + Assertions.assertEquals(Boolean.FALSE, root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn03/BooleanEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/boolval/BooleanRoot.java similarity index 81% rename from src/test/java/daxi/moe/test/scenario/alfa/scn03/BooleanEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/boolval/BooleanRoot.java index c84c862..65cefd5 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn03/BooleanEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/boolval/BooleanRoot.java @@ -12,16 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn03; +package daxi.moe.test.mem.mod2obj.setter.simple.boolval; import daxi.moe.app.MapFrom; -public class BooleanEntity { +public class BooleanRoot { private boolean member1; private Boolean member2; - public BooleanEntity() { + public BooleanRoot() { //NOOP } @@ -34,12 +34,12 @@ public class BooleanEntity { } @MapFrom("member1") - private void _setMe1(boolean value) { + private void first(boolean value) { member1 = value; } @MapFrom("member2") - private void _setMe2(Boolean value) { + private void second(Boolean value) { member2 = value; } } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/byteval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/byteval/AllTests.java new file mode 100644 index 0000000..a0888b9 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/byteval/AllTests.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.byteval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple byte setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with byte/Byte setters is created") + public void test01() { + byte val1 = 0x1A; + byte val2 = 0x1B; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + ByteRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(ByteRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(val1, root.getMember1()); + Assertions.assertEquals(val2, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with byte/Byte setters is created from String values") + public void test02() { + String val1 = "26"; + String val2 = "27"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + ByteRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(ByteRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals((byte) 26, root.getMember1()); + Assertions.assertEquals(Byte.valueOf((byte) 27), root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with byte/Byte setters is not created from " + + "non-numeric String values") + public void test03() { + String val1 = "bad byte 1"; + String val2 = "bad byte 2"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + ByteRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(ByteRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn04/ByteEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/byteval/ByteRoot.java similarity index 81% rename from src/test/java/daxi/moe/test/scenario/alfa/scn04/ByteEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/byteval/ByteRoot.java index 3c4f4db..4edf3e4 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn04/ByteEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/byteval/ByteRoot.java @@ -12,16 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn04; +package daxi.moe.test.mem.mod2obj.setter.simple.byteval; import daxi.moe.app.MapFrom; -public class ByteEntity { +public class ByteRoot { private byte member1; private Byte member2; - public ByteEntity() { + public ByteRoot() { //NOOP } @@ -34,12 +34,12 @@ public class ByteEntity { } @MapFrom("member1") - private void _setMe1(byte value) { + private void _setMember1(byte value) { member1 = value; } @MapFrom("member2") - private void _setMe2(Byte value) { + private void _setMember2(Byte value) { member2 = value; } } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/doubleval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/doubleval/AllTests.java new file mode 100644 index 0000000..78f6db9 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/doubleval/AllTests.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.doubleval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.Random; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple double setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with double/Double setters is created") + public void test01() { + Random random = new Random(); + double val1 = random.nextDouble(); + Double val2 = random.nextDouble(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + DoubleRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(DoubleRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(val1, root.getMember1()); + Assertions.assertEquals(val2, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with double/Double setters is created from string " + + "values") + public void test02() { + Random random = new Random(); + double d1 = random.nextDouble(); + double d2 = random.nextDouble(); + String val1 = String.valueOf(d1); + String val2 = String.valueOf(d2); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + DoubleRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(DoubleRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(d1, root.getMember1()); + Assertions.assertEquals(d2, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with double/Double setters is not created from " + + "non-numeric String values") + public void test03() { + String val1 = "bad double 1"; + String val2 = "bad double 2"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + DoubleRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(DoubleRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn09/DoubleEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/doubleval/DoubleRoot.java similarity index 89% rename from src/test/java/daxi/moe/test/scenario/alfa/scn09/DoubleEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/doubleval/DoubleRoot.java index 93667c9..789144e 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn09/DoubleEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/doubleval/DoubleRoot.java @@ -12,16 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn09; +package daxi.moe.test.mem.mod2obj.setter.simple.doubleval; import daxi.moe.app.MapFrom; -public class DoubleEntity { +public class DoubleRoot { private double member1; private Double member2; - public DoubleEntity() { + public DoubleRoot() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/floatval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/floatval/AllTests.java new file mode 100644 index 0000000..22ee31f --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/floatval/AllTests.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.floatval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.Random; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple float setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with float/Float setters is created") + public void test01() { + Random random = new Random(); + float val1 = random.nextFloat(); + Float val2 = random.nextFloat(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + FloatRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(FloatRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(val1, root.getMember1()); + Assertions.assertEquals(val2, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with float/Float setters is created from string values") + public void test02() { + Random random = new Random(); + float f1 = random.nextFloat(); + float f2 = random.nextFloat(); + String val1 = String.valueOf(f1); + String val2 = String.valueOf(f2); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + FloatRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(FloatRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(f1, root.getMember1()); + Assertions.assertEquals(f2, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with float/Float setters is not created from " + + "non-numeric String values") + public void test03() { + String val1 = "bad float 1"; + String val2 = "bad float 2"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + FloatRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(FloatRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn07/FloatEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/floatval/FloatRoot.java similarity index 89% rename from src/test/java/daxi/moe/test/scenario/alfa/scn07/FloatEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/floatval/FloatRoot.java index 7c6772c..5423f0e 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn07/FloatEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/floatval/FloatRoot.java @@ -12,16 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn07; +package daxi.moe.test.mem.mod2obj.setter.simple.floatval; import daxi.moe.app.MapFrom; -public class FloatEntity { +public class FloatRoot { private float member1; private Float member2; - public FloatEntity() { + public FloatRoot() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/intval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/intval/AllTests.java new file mode 100644 index 0000000..55d9916 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/intval/AllTests.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.intval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.util.Random; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple integer setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with int/Integer setters is created") + public void test01() { + Random random = new Random(); + int val1 = random.nextInt(); + Integer val2 = random.nextInt(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + IntegerRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(IntegerRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(val1, root.getMember1()); + Assertions.assertEquals(val2, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with int/Integer setters is created from string values") + public void test02() { + Random random = new Random(); + int i1 = random.nextInt(); + int i2 = random.nextInt(); + String val1 = String.valueOf(i1); + String val2 = String.valueOf(i2); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + IntegerRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(IntegerRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(i1, root.getMember1()); + Assertions.assertEquals(i2, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with int/Integer setters is not created from " + + "non-numeric String values") + public void test03() { + String val1 = "bad int 1"; + String val2 = "bad int 2"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + IntegerRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(IntegerRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn06/IntegerEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/intval/IntegerRoot.java similarity index 89% rename from src/test/java/daxi/moe/test/scenario/alfa/scn06/IntegerEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/intval/IntegerRoot.java index cd2b62c..29aa606 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn06/IntegerEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/intval/IntegerRoot.java @@ -12,16 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn06; +package daxi.moe.test.mem.mod2obj.setter.simple.intval; import daxi.moe.app.MapFrom; -public class IntegerEntity { +public class IntegerRoot { private int member1; private Integer member2; - public IntegerEntity() { + public IntegerRoot() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/longval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/longval/AllTests.java new file mode 100644 index 0000000..659bbdd --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/longval/AllTests.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.longval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.Random; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple long setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with long/Long setters is created") + public void test01() { + Random random = new Random(); + long val1 = random.nextLong(); + Long val2 = random.nextLong(); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + LongRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(LongRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(val1, root.getMember1()); + Assertions.assertEquals(val2, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with long/Long setters is created from string values") + public void test02() { + Random random = new Random(); + long l1 = random.nextLong(); + long l2 = random.nextLong(); + String val1 = String.valueOf(l1); + String val2 = String.valueOf(l2); + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + LongRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(LongRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(l1, root.getMember1()); + Assertions.assertEquals(l2, root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with long/Long setters is not created from " + + "non-numeric String values") + public void test03() { + String val1 = "bad long 1"; + String val2 = "bad long 2"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + LongRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(LongRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn08/LongEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/longval/LongRoot.java similarity index 89% rename from src/test/java/daxi/moe/test/scenario/alfa/scn08/LongEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/longval/LongRoot.java index b699f16..9dc7b27 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn08/LongEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/longval/LongRoot.java @@ -12,16 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn08; +package daxi.moe.test.mem.mod2obj.setter.simple.longval; import daxi.moe.app.MapFrom; -public class LongEntity { +public class LongRoot { private long member1; private Long member2; - public LongEntity() { + public LongRoot() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/shortval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/shortval/AllTests.java new file mode 100644 index 0000000..0a9f122 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/shortval/AllTests.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.shortval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple short setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with short/Short setters is created") + public void test01() { + short val1 = 16343; + short val2 = 2048; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + ShortRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(ShortRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals(val1, root.getMember1()); + Assertions.assertEquals(val2, root.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[MEM Model2Object] Entity with short/Short setters is created from String values") + public void test02() { + String val1 = "16343"; + String val2 = "2048"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + ShortRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(ShortRoot.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals((short) 16343, root.getMember1()); + Assertions.assertEquals(Short.valueOf((short)2048), root.getMember2()); + } + + @Test + @Order(3) + @DisplayName("[MEM Model2Object] Entity with short/Short setters is not created from " + + "non-numeric String values") + public void test03() { + String val1 = "bad short 1"; + String val2 = "bad short 2"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + mainData().put("member2", new AnyData(new SimpleData(val2))); + + ShortRoot root = + Assertions.assertDoesNotThrow(() -> external().convert(ShortRoot.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getMember1()); + Assertions.assertNull(root.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn05/ShortEntity.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/shortval/ShortRoot.java similarity index 89% rename from src/test/java/daxi/moe/test/scenario/alfa/scn05/ShortEntity.java rename to src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/shortval/ShortRoot.java index ee487c2..b0bbe9c 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn05/ShortEntity.java +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/shortval/ShortRoot.java @@ -12,16 +12,16 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn05; +package daxi.moe.test.mem.mod2obj.setter.simple.shortval; import daxi.moe.app.MapFrom; -public class ShortEntity { +public class ShortRoot { private short member1; private Short member2; - public ShortEntity() { + public ShortRoot() { //NOOP } diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/AllTests.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/AllTests.java new file mode 100644 index 0000000..602a772 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/AllTests.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.strval; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[MEM Model2Object] Simple string setters") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[MEM Model2Object] Entity with string setters is created") + public void test01() { + mainData().put("member", new AnyData(new SimpleData("string-value-01"))); + + StringRoot entity = + Assertions.assertDoesNotThrow(() -> external().convert(StringRoot.class)); + Assertions.assertNotNull(entity); + Assertions.assertEquals("string-value-01", entity.getMember()); + } +} diff --git a/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/StringRoot.java b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/StringRoot.java new file mode 100644 index 0000000..8aa4a6d --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/mod2obj/setter/simple/strval/StringRoot.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.mod2obj.setter.simple.strval; + +import daxi.moe.app.MapFrom; + +public class StringRoot { + + private String member; + + public StringRoot() { + //NOOP + } + + public String getMember() { + return member; + } + + @MapFrom("member") + private void _someMethod(String value) { + member = value; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/MemObj2ModTests.java b/src/test/java/daxi/moe/test/mem/obj2mod/MemObj2ModTests.java new file mode 100644 index 0000000..6533882 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/MemObj2ModTests.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod; + +import daxi.moe.app.Internal; +import daxi.moe.app.Moe; +import daxi.moe.model.AnyData; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@Tag("mem-obj2mod") +public class MemObj2ModTests extends AbstractTests { + + private static Logger L = Logger.getLogger(MemObj2ModTests.class.getName()); + + private Internal intern; + + @BeforeEach + public final void beforeEach() { + L.info("beforeEach - resetting the test environment"); + Moe moe = Moe.create(); + intern = moe.internal("mem"); + Assertions.assertNotNull(intern); + } + + protected final void retrieve(Object srcObj) throws Exception { + intern.from(srcObj); + } + + protected final AnyData getModel() { + return intern.getModel(); + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/AllTests.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/AllTests.java new file mode 100644 index 0000000..c406312 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/AllTests.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.numitem; + +import daxi.moe.model.AnyData; +import daxi.moe.model.LinearData; +import daxi.moe.test.mem.obj2mod.MemObj2ModTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.Set; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Object2Model] Linear data retrieval tests") +public class AllTests extends MemObj2ModTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Object2Model] Array of integers is retrieved correctly") + public void test01() { + IntArrayRoot srcObj = new IntArrayRoot(); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + AnyData data = getModel(); + Assertions.assertNotNull(data); + + AnyData alData = data.asMapped().get("values"); + Assertions.assertNotNull(alData); + + LinearData ldata = alData.asLinear(); + Assertions.assertNotNull(ldata); + + Assertions.assertEquals(3, ldata.size()); + Assertions.assertEquals(100, ldata.get(0).asSimple().getNumber().intValue()); + Assertions.assertEquals(101, ldata.get(1).asSimple().getNumber().intValue()); + Assertions.assertEquals(102, ldata.get(2).asSimple().getNumber().intValue()); + } + + @Test + @Order(2) + @DisplayName("[Object2Model] List of integers is retrieved correctly") + public void test02() { + IntListRoot srcObj = new IntListRoot(); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + AnyData data = getModel(); + Assertions.assertNotNull(data); + + AnyData alData = data.asMapped().get("values"); + Assertions.assertNotNull(alData); + + LinearData ldata = alData.asLinear(); + Assertions.assertNotNull(ldata); + + Assertions.assertEquals(3, ldata.size()); + Assertions.assertEquals(100, ldata.get(0).asSimple().getNumber().intValue()); + Assertions.assertEquals(101, ldata.get(1).asSimple().getNumber().intValue()); + Assertions.assertEquals(102, ldata.get(2).asSimple().getNumber().intValue()); + } + + @Test + @Order(3) + @DisplayName("[Object2Model] Set of integers is retrieved correctly") + public void test03() { + IntSetRoot srcObj = new IntSetRoot(); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + AnyData data = getModel(); + Assertions.assertNotNull(data); + + AnyData alData = data.asMapped().get("values"); + Assertions.assertNotNull(alData); + + LinearData ldata = alData.asLinear(); + Assertions.assertNotNull(ldata); + + Assertions.assertEquals(3, ldata.size()); + Set expectedValues = Set.of(100, 101, 102); + for (int i = 0; i < 3; i++) { + Assertions.assertTrue(expectedValues.contains( + ldata.get(i).asSimple().getNumber().intValue())); + } + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntArrayRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntArrayRoot.java new file mode 100644 index 0000000..e8c44cd --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntArrayRoot.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.numitem; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class IntArrayRoot { + + private final int[] values; + + public IntArrayRoot() { + values = new int[]{100, 101, 102}; + } + + @MapTo("values") + private int[] _values() { + return values; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntListRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntListRoot.java new file mode 100644 index 0000000..4535f45 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntListRoot.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.numitem; + +import daxi.moe.app.MapTo; + +import java.util.List; + +/** + * @author indroneel + */ + +public class IntListRoot { + + private final List values; + + public IntListRoot() { + values = List.of(100, 101, 102); + } + + @MapTo("values") + private List _values() { + return values; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntSetRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntSetRoot.java new file mode 100644 index 0000000..1e36e31 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/numitem/IntSetRoot.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.numitem; + +import daxi.moe.app.MapTo; + +import java.util.Set; + +/** + * @author indroneel + */ + +public class IntSetRoot { + + private final Set values; + + public IntSetRoot() { + values = Set.of(100, 101, 102); + } + + @MapTo("values") + private Set _values() { + return values; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/AllTests.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/AllTests.java new file mode 100644 index 0000000..2eccc6e --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/AllTests.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.stritem; + +import daxi.moe.model.AnyData; +import daxi.moe.model.LinearData; +import daxi.moe.test.mem.obj2mod.MemObj2ModTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.Set; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Object2Model] Linear data retrieval tests") +public class AllTests extends MemObj2ModTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Object2Model] Array of strings is retrieved correctly") + public void test01() { + StringArrayRoot srcObj = new StringArrayRoot(); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + AnyData data = getModel(); + Assertions.assertNotNull(data); + + AnyData alData = data.asMapped().get("values"); + Assertions.assertNotNull(alData); + + LinearData ldata = alData.asLinear(); + Assertions.assertNotNull(ldata); + + Assertions.assertEquals(3, ldata.size()); + Assertions.assertEquals("value1", ldata.get(0).asSimple().getString()); + Assertions.assertEquals("value2", ldata.get(1).asSimple().getString()); + Assertions.assertEquals("value3", ldata.get(2).asSimple().getString()); + } + + @Test + @Order(2) + @DisplayName("[Object2Model] List of strings is retrieved correctly") + public void test02() { + StringListRoot srcObj = new StringListRoot(); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + AnyData data = getModel(); + Assertions.assertNotNull(data); + + AnyData alData = data.asMapped().get("values"); + Assertions.assertNotNull(alData); + + LinearData ldata = alData.asLinear(); + Assertions.assertNotNull(ldata); + + Assertions.assertEquals(3, ldata.size()); + Assertions.assertEquals("value1", ldata.get(0).asSimple().getString()); + Assertions.assertEquals("value2", ldata.get(1).asSimple().getString()); + Assertions.assertEquals("value3", ldata.get(2).asSimple().getString()); + } + + @Test + @Order(3) + @DisplayName("[Object2Model] Set of strings is retrieved correctly") + public void test03() { + StringSetRoot srcObj = new StringSetRoot(); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + AnyData data = getModel(); + Assertions.assertNotNull(data); + + AnyData alData = data.asMapped().get("values"); + Assertions.assertNotNull(alData); + + LinearData ldata = alData.asLinear(); + Assertions.assertNotNull(ldata); + + Assertions.assertEquals(3, ldata.size()); + Set expectedValues = Set.of("value1", "value2", "value3"); + for (int i = 0; i < 3; i++) { + Assertions.assertTrue(expectedValues.contains(ldata.get(i).asSimple().getString())); + } + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringArrayRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringArrayRoot.java new file mode 100644 index 0000000..14f68f6 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringArrayRoot.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.stritem; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class StringArrayRoot { + + private final String[] values; + + public StringArrayRoot() { + values = new String[]{"value1", "value2", "value3"}; + } + + @MapTo("values") + private String[] _values() { + return values; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringListRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringListRoot.java new file mode 100644 index 0000000..dbc546f --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringListRoot.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.stritem; + +import daxi.moe.app.MapTo; + +import java.util.List; + +/** + * @author indroneel + */ + +public class StringListRoot { + + private final List values; + + public StringListRoot() { + values = List.of("value1", "value2", "value3"); + } + + @MapTo("values") + private List _values() { + return values; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringSetRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringSetRoot.java new file mode 100644 index 0000000..d084e6b --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/linear/stritem/StringSetRoot.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.linear.stritem; + +import daxi.moe.app.MapTo; + +import java.util.Set; + +/** + * @author indroneel + */ + +public class StringSetRoot { + + private final Set values; + + public StringSetRoot() { + values = Set.of("value1", "value2", "value3"); + } + + @MapTo("values") + private Set _values() { + return values; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/semantics/AllTests.java b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/AllTests.java new file mode 100644 index 0000000..35263e4 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/AllTests.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.semantics; + +import daxi.moe.app.ConvertException; +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.obj2mod.MemObj2ModTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Object2Model] Basic Semantics Tests") +public class AllTests extends MemObj2ModTests { + + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Object2Model] Methods without MapTo annotations are not used for retrieval") + public void test01() { + BlankObject01 srcObj = new BlankObject01("str-val-01", "str-val-02"); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + AnyData data = getModel(); + Assertions.assertNull(data); + } + + @Test + @Order(2) + @DisplayName("[Object2Model] Public methods with MapTo annotations are not used for retrieval") + public void test02() { + BlankObject02 srcObj = new BlankObject02("str-val-01", "str-val-02"); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + AnyData data = getModel(); + Assertions.assertNull(data); + } + + @Test + @Order(3) + @DisplayName("[Object2Model] Methods with MapTo annotations that have non-zero parameters " + + "are not used for retrieval") + public void test03() { + BlankObject03 srcObj = new BlankObject03("str-val-01"); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + AnyData data = getModel(); + Assertions.assertNull(data); + } + + @Test + @Order(4) + @DisplayName("[Object2Model] Methods with blank MapTo annotations are not used for retrieval") + public void test04() { + BlankObject04 srcObj = new BlankObject04("str-val-01"); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + AnyData data = getModel(); + Assertions.assertNull(data); + } + + @Test + @Order(5) + @DisplayName("[Object2Model] Methods with duplicate keys in MapTo annotations is an error") + public void test05() { + BadObject01 srcObj = new BadObject01("str-val-01", 42); + ConvertException exep + = Assertions.assertThrows(ConvertException.class, () -> retrieve(srcObj)); + Assertions.assertEquals(BadObject01.class.getName(), exep.getType()); + } + + @Test + @Order(6) + @DisplayName("[Object2Model] Methods with correct semantics are used for retrieval") + public void test06() { + GoodObject srcObj = new GoodObject("str-val-01"); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + AnyData data = getModel(); + Assertions.assertNotNull(data); + MappedData mdata = data.asMapped(); + Assertions.assertNotNull(mdata); + List keys = mdata.getKeys(); + Assertions.assertFalse(keys.isEmpty()); + AnyData pdata = mdata.get("member1"); + Assertions.assertNotNull(pdata); + SimpleData sd = pdata.asSimple(); + Assertions.assertNotNull(sd); + String value = sd.getString(); + Assertions.assertEquals("str-val-01", value); + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BadObject01.java b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BadObject01.java new file mode 100644 index 0000000..fd78e85 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BadObject01.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.semantics; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class BadObject01 { + + private final String member1; + private final int member2; + + public BadObject01(String m1, int m2) { + member1 = m1; + member2 = m2; + } + + @MapTo("member") + private String _getMember1() { + return member1; + } + + @MapTo("member") + private int _getMember2() { + return member2; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity01.java b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject01.java similarity index 72% rename from src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity01.java rename to src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject01.java index a42afd8..ac40d3c 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity01.java +++ b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject01.java @@ -12,16 +12,20 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn01; +package daxi.moe.test.mem.obj2mod.semantics; +/** + * @author indroneel + */ -public class InvalidEntity01 { +public class BlankObject01 { - private String member1; - private String member2; + private final String member1; + private final String member2; - public InvalidEntity01() { - //NOOP + public BlankObject01(String m1, String m2) { + member1 = m1; + member2 = m2; } public String getMember1() { diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject02.java b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject02.java new file mode 100644 index 0000000..67b457a --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject02.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.semantics; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class BlankObject02 { + + private final String member1; + private final String member2; + + public BlankObject02(String m1, String m2) { + member1 = m1; + member2 = m2; + } + + @MapTo("member1") + public String _getMember1() { + return member1; + } + + @MapTo("member2") + public String _getMember2() { + return member2; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject03.java b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject03.java new file mode 100644 index 0000000..ded7ea7 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject03.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.semantics; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class BlankObject03 { + + private final String member1; + + public BlankObject03(String m1) { + member1 = m1; + } + + @MapTo("member1") + private String _getMember1(String value) { + return member1; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject04.java b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject04.java new file mode 100644 index 0000000..d1745e7 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/BlankObject04.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.semantics; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class BlankObject04 { + + private final String member1; + + public BlankObject04(String m1) { + member1 = m1; + } + + @MapTo + private String _getMember1() { + return member1; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/semantics/GoodObject.java b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/GoodObject.java new file mode 100644 index 0000000..133ec49 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/semantics/GoodObject.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.semantics; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class GoodObject { + + private final String member1; + + public GoodObject(String m1) { + member1 = m1; + } + + @MapTo("member1") + private String _getMember1() { + return member1; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/AllTests.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/AllTests.java new file mode 100644 index 0000000..7f529a4 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/AllTests.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.obj2mod.MemObj2ModTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Object2Model] Simple Retrieval Tests") +public class AllTests extends MemObj2ModTests { + + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Object2Model] Method to retrieve boolean values") + public void test01() { + BooleanRoot srcObj = new BooleanRoot(true); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + MappedData mdata = getRoot(); + + AnyData pdata1 = mdata.get("member1"); + Assertions.assertNotNull(pdata1); + SimpleData sd1 = pdata1.asSimple(); + Assertions.assertNotNull(sd1); + + Boolean value1 = sd1.getBoolean(); + Assertions.assertEquals(true, value1); + + AnyData pdata2 = mdata.get("member2"); + Assertions.assertNotNull(pdata2); + SimpleData sd2 = pdata2.asSimple(); + Assertions.assertNotNull(sd2); + + Boolean value2 = sd2.getBoolean(); + Assertions.assertEquals(true, value2); + } + + @Test + @Order(2) + @DisplayName("[Object2Model] Method to retrieve integer values") + public void test02() { + IntegerRoot srcObj = new IntegerRoot(42); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + MappedData mdata = getRoot(); + assertNumber(mdata, "member1", 42); + assertNumber(mdata, "member2", 42); + } + + @Test + @Order(3) + @DisplayName("[Object2Model] Method to retrieve long values") + public void test03() { + LongRoot srcObj = new LongRoot(9876543210L); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + MappedData mdata = getRoot(); + assertNumber(mdata, "member1", 9876543210L); + assertNumber(mdata, "member2", 9876543210L); + } + + @Test + @Order(4) + @DisplayName("[Object2Model] Method to retrieve float values") + public void test04() { + FloatRoot srcObj = new FloatRoot(12.5F); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + MappedData mdata = getRoot(); + assertNumber(mdata, "member1", 12.5F); + assertNumber(mdata, "member2", 12.5F); + } + + @Test + @Order(5) + @DisplayName("[Object2Model] Method to retrieve double values") + public void test05() { + DoubleRoot srcObj = new DoubleRoot(123.456789012345); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + MappedData mdata = getRoot(); + assertNumber(mdata, "member1", 123.456789012345); + assertNumber(mdata, "member2", 123.456789012345); + } + + @Test + @Order(6) + @DisplayName("[Object2Model] Method to retrieve BigInteger values") + public void test06() { + BigInteger value = new BigInteger("123456789012345678901234567890"); + BigIntegerRoot srcObj = new BigIntegerRoot(value); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + MappedData mdata = getRoot(); + assertNumber(mdata, "member", value); + } + + @Test + @Order(7) + @DisplayName("[Object2Model] Method to retrieve BigDecimal values") + public void test07() { + BigDecimal value = new BigDecimal("12345678901234567890.123456789"); + BigDecimalRoot srcObj = new BigDecimalRoot(value); + Assertions.assertDoesNotThrow(() -> retrieve(srcObj)); + + MappedData mdata = getRoot(); + assertNumber(mdata, "member", value); + } + + //////////////////////////////////////////////////////////////////////////////////////////////// + // Helper methods + + private MappedData getRoot() { + AnyData data = getModel(); + Assertions.assertNotNull(data); + MappedData mdata = data.asMapped(); + Assertions.assertNotNull(mdata); + return mdata; + } + + private void assertNumber(MappedData mdata, String member, Number expected) { + AnyData data = mdata.get(member); + Assertions.assertNotNull(data); + SimpleData simpleData = data.asSimple(); + Assertions.assertNotNull(simpleData); + Assertions.assertEquals(expected, simpleData.getNumber()); + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/BigDecimalRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/BigDecimalRoot.java new file mode 100644 index 0000000..b0eadca --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/BigDecimalRoot.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the full text of the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.app.MapTo; + +import java.math.BigDecimal; + +/** + * @author indroneel + */ + +public class BigDecimalRoot { + + private final BigDecimal member; + + public BigDecimalRoot(BigDecimal value) { + member = value; + } + + @MapTo("member") + private BigDecimal _getMember() { + return member; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/BigIntegerRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/BigIntegerRoot.java new file mode 100644 index 0000000..cf630c5 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/BigIntegerRoot.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the full text of the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.app.MapTo; + +import java.math.BigInteger; + +public class BigIntegerRoot { + + private final BigInteger member; + + public BigIntegerRoot(BigInteger value) { + member = value; + } + + @MapTo("member") + private BigInteger _getMember() { + return member; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/BooleanRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/BooleanRoot.java new file mode 100644 index 0000000..584c548 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/BooleanRoot.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class BooleanRoot { + + private final boolean member; + + public BooleanRoot(boolean flag) { + member = flag; + } + + @MapTo("member1") + private boolean _getMember1() { + return member; + } + + @MapTo("member2") + private Boolean _getMember2() { + return member; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/DoubleRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/DoubleRoot.java new file mode 100644 index 0000000..bbbea44 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/DoubleRoot.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the full text of the License. + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the full text of the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class DoubleRoot { + + private final double member; + + public DoubleRoot(double value) { + member = value; + } + + @MapTo("member1") + private double _getMember1() { + return member; + } + + @MapTo("member2") + private Double _getMember2() { + return member; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/FloatRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/FloatRoot.java new file mode 100644 index 0000000..fe15608 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/FloatRoot.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class FloatRoot { + + private final float member; + + public FloatRoot(float value) { + member = value; + } + + @MapTo("member1") + private float _getMember1() { + return member; + } + + @MapTo("member2") + private Float _getMember2() { + return member; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/IntegerRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/IntegerRoot.java new file mode 100644 index 0000000..9482825 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/IntegerRoot.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class IntegerRoot { + + private final int member; + + public IntegerRoot(int value) { + member = value; + } + + @MapTo("member1") + private int _getMember1() { + return member; + } + + @MapTo("member2") + private Integer _getMember2() { + return member; + } +} diff --git a/src/test/java/daxi/moe/test/mem/obj2mod/simple/LongRoot.java b/src/test/java/daxi/moe/test/mem/obj2mod/simple/LongRoot.java new file mode 100644 index 0000000..9f1d2b9 --- /dev/null +++ b/src/test/java/daxi/moe/test/mem/obj2mod/simple/LongRoot.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mem.obj2mod.simple; + +import daxi.moe.app.MapTo; + +/** + * @author indroneel + */ + +public class LongRoot { + + private final long member; + + public LongRoot(long value) { + member = value; + } + + @MapTo("member1") + private long _getMember1() { + return member; + } + + @MapTo("member2") + private Long _getMember2() { + return member; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/Check.java b/src/test/java/daxi/moe/test/mod2obj/Check.java new file mode 100644 index 0000000..85fe14f --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/Check.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj; + +public class Check { + + private static boolean set = false; + + public static boolean isSet() { + return set; + } + + public static void reset() { + set = false; + } + + public static void set() { + set = true; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/generic/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/generic/AllTests.java new file mode 100644 index 0000000..6962a00 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/generic/AllTests.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.generic; + +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Model2Object] Basic validity checks for root entities") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] Entity with at least one setter method is created") + public void test01() { + ValidRoot01 root = + Assertions.assertDoesNotThrow(() -> external().convert(ValidRoot01.class)); + Assertions.assertNotNull(root); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] Entity with at least one blank linear method is created") + public void test02() { + ValidRoot02 root = + Assertions.assertDoesNotThrow(() -> external().convert(ValidRoot02.class)); + Assertions.assertNotNull(root); + } + + @Test + @Order(3) + @DisplayName("[Model2Object] Entity with at least one blank adder method is created") + public void test03() { + ValidRoot03 root = + Assertions.assertDoesNotThrow(() -> external().convert(ValidRoot03.class)); + Assertions.assertNotNull(root); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/generic/Nested.java b/src/test/java/daxi/moe/test/mod2obj/generic/Nested.java new file mode 100644 index 0000000..f48f2fc --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/generic/Nested.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.generic; + +public class Nested { +} diff --git a/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot01.java b/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot01.java new file mode 100644 index 0000000..3d8f349 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot01.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.generic; + +import daxi.moe.app.MapFrom; + +/** + * A valid root entity during model to object transfer. It has a public default constructor and a + * setter method. + * + * @author indroneel + */ + +public class ValidRoot01 { + + public ValidRoot01() { + //NOOP + } + + @MapFrom("member1") + private void _member1(String value) { + //NOOP + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot02.java b/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot02.java new file mode 100644 index 0000000..bb27752 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot02.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.generic; + +import daxi.moe.app.MapFrom; + +/** + * A valid root entity during model to object transfer. It has a public default constructor and a + * blank linear method. + * + * @author indroneel + */ + +public class ValidRoot02 { + + public ValidRoot02() { + //NOOP + } + + @MapFrom + private void _member1(String value) { + //NOOP + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot03.java b/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot03.java new file mode 100644 index 0000000..1bc5ff0 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/generic/ValidRoot03.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.generic; + +import daxi.moe.app.MapFrom; + +/** + * A valid root entity during model to object transfer. It has a public default constructor and a + * blank mapped method. + * + * @author indroneel + */ + +public class ValidRoot03 { + + public ValidRoot03() { + //NOOP + } + + @MapFrom + private void _blankMapper(String key, Nested value) { + //NOOP + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/generic/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/linear/generic/AllTests.java new file mode 100644 index 0000000..b36d618 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/generic/AllTests.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.generic; + +import daxi.moe.model.AnyData; +import daxi.moe.model.LinearData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Model2Object] Your Name here") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] Test Name Here") + public void test01() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + Root01 root = Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(root); + Assertions.assertTrue(root.getItems().isEmpty()); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] Test Name Here") + public void test02() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + Root02 root = Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNotNull(root); + Assertions.assertTrue(root.getItems().isEmpty()); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem01.java b/src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem01.java new file mode 100644 index 0000000..4d29390 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem01.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.generic; + +import daxi.moe.app.MapFrom; +import daxi.moe.test.mod2obj.Check; + +public class ListItem01 { + + public ListItem01() { + //NOOP + } + + @MapFrom + private void _setItem(T val) { + Check.set(); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem02.java b/src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem02.java new file mode 100644 index 0000000..6130bdf --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/generic/ListItem02.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.generic; + +import daxi.moe.app.MapFrom; +import daxi.moe.test.mod2obj.Check; + +public class ListItem02 { + + public ListItem02() { + //NOOP + } + + @MapFrom + private void _setItem(String[] val) { + Check.set(); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/generic/Root01.java b/src/test/java/daxi/moe/test/mod2obj/linear/generic/Root01.java new file mode 100644 index 0000000..dc6d7c1 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/generic/Root01.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.generic; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * A simple test class to demonstrate the mapping of a list of strings from the data model to an + * object. + * + * @author indroneel + */ + +public class Root01 { + + private final List items; + + public Root01() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem01 value) { + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/generic/Root02.java b/src/test/java/daxi/moe/test/mod2obj/linear/generic/Root02.java new file mode 100644 index 0000000..05606c5 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/generic/Root02.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.generic; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * A simple test class to demonstrate the mapping of a list of strings from the data model to an + * object. + * + * @author indroneel + */ + +public class Root02 { + + private final List items; + + public Root02() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem02 value) { + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/AllTests.java new file mode 100644 index 0000000..558bac3 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/AllTests.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.ConvertException; +import daxi.moe.model.AnyData; +import daxi.moe.model.LinearData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Model2Object] Linear member with linear data items") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] Linear Data holding Linear data items cannot be converted if " + + "the nested entities have setter methods") + public void test01() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + Root01 root = Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getItems().size()); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] Linear Data holding Linear data items cannot be converted if the " + + "nested entities does not have a blank linear method") + public void test02() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + Root02 root = Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNotNull(root); + List topItems = root.getItems(); + Assertions.assertEquals(0, topItems.size()); + } + + @Test + @Order(3) + @DisplayName("[Model2Object] Linear Data holding Linear data items cannot be converted if the " + + "nested entities does not have a default constructor") + public void test03() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + Root03 root = Assertions.assertDoesNotThrow(() -> external().convert(Root03.class)); + Assertions.assertNotNull(root); + List topItems = root.getItems(); + Assertions.assertEquals(0, topItems.size()); + } + + @Test + @Order(4) + @DisplayName("[Model2Object] Conversion of linear Data holding Linear data items can throw " + + "an exception that stops the process") + public void test04() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + ConvertException exep = Assertions.assertThrows( + ConvertException.class, + () -> external().convert(Root04.class)); + Throwable cause = exep.getCause().getCause(); + Assertions.assertEquals("some-error", cause.getMessage()); + } + + @Test + @Order(5) + @DisplayName("[Model2Object] Linear Data holding Linear data items throws an exception in " + + "case there are multiple blank linear methods in the nested entity") + public void test05() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + ConvertException exep = Assertions.assertThrows( + ConvertException.class, + () -> external().convert(Root05.class)); + System.out.printf("exep: %s : %s = %s%n", + exep.getType(), exep.getMethod(), exep.getMessage()); + } + + @Test + @Order(6) + @DisplayName("[Model2Object] Linear Data holding Linear data items can be converted if the " + + "nested entities have blank linear methods") + public void test06() { + LinearData topLinear = new LinearData(); + mainData().put("items", new AnyData(topLinear)); + + LinearData ldata = new LinearData(); + topLinear.add(new AnyData(ldata)); + + MappedData mdata1 = new MappedData(); + mdata1.put("member1", new AnyData(new SimpleData("item1-str"))); + mdata1.put("member2", new AnyData(new SimpleData(101))); + ldata.add(new AnyData(mdata1)); + + MappedData mdata2 = new MappedData(); + mdata2.put("member1", new AnyData(new SimpleData("item2-str"))); + mdata2.put("member2", new AnyData(new SimpleData(102))); + ldata.add(new AnyData(mdata2)); + + Root06 root = Assertions.assertDoesNotThrow(() -> external().convert(Root06.class)); + Assertions.assertNotNull(root); + List topItems = root.getItems(); + Assertions.assertEquals(1, topItems.size()); + + List nestedItems = topItems.get(0).getItems(); + Assertions.assertEquals(2, nestedItems.size()); + + Assertions.assertEquals("item1-str", nestedItems.get(0).getMember1()); + Assertions.assertEquals(101, nestedItems.get(0).getMember2()); + + Assertions.assertEquals("item2-str", nestedItems.get(1).getMember1()); + Assertions.assertEquals(102, nestedItems.get(1).getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem01.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem01.java new file mode 100644 index 0000000..098af9b --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem01.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class ListItem01 { + + private String member1; + private final List items; + + public ListItem01() { + items = new ArrayList<>(); + } + + public String getMember1() { + return member1; + } + + public List getItems() { + return items; + } + + @MapFrom("member1") + private void _setMember1(String val) { + member1 = val; + } + + @MapFrom + private void _setItems(NestedItem val) { + items.add(val); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem02.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem02.java new file mode 100644 index 0000000..eb54d34 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem02.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class ListItem02 { + + private final List items; + + public ListItem02() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom + private void _setItem(String key, NestedItem val) { + items.add(val); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem03.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem03.java new file mode 100644 index 0000000..23bc80a --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem03.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class ListItem03 { + + private final List items; + + public ListItem03(boolean flag) { + // the flag is just to differentiate the constructor from the default one, which is used by + // the mapping framework + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom + private void _setItems(NestedItem val) { + items.add(val); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem04.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem04.java new file mode 100644 index 0000000..8b39596 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem04.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class ListItem04 { + + private final List items; + + public ListItem04() { + items = new ArrayList<>(); + throw new RuntimeException("some-error"); + } + + public List getItems() { + return items; + } + + @MapFrom + private void _setItems(NestedItem val) { + items.add(val); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem05.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem05.java new file mode 100644 index 0000000..df45264 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem05.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class ListItem05 { + + private final List items; + + public ListItem05() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom + private void _setItem1(NestedItem val) { + items.add(val); + } + + @MapFrom + private void _setItem2(NestedItem val) { + items.add(val); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem06.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem06.java new file mode 100644 index 0000000..5749395 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/ListItem06.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +public class ListItem06 { + + private final List items; + + public ListItem06() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom + private void _setItems(NestedItem val) { + items.add(val); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/NestedItem.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/NestedItem.java new file mode 100644 index 0000000..ff10708 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/NestedItem.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +public class NestedItem { + + private String member1; + private int member2; + + public String getMember1() { + return member1; + } + + public int getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMember1(String val) { + member1 = val; + } + + @MapFrom("member2") + private void _setMember2(int val) { + member2 = val; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root01.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root01.java new file mode 100644 index 0000000..e0023ed --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root01.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root01 { + + private final List items; + + public Root01() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem01 value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root02.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root02.java new file mode 100644 index 0000000..32a6b30 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root02.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root02 { + + private final List items; + + public Root02() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem02 value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root03.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root03.java new file mode 100644 index 0000000..4def965 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root03.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root03 { + + private final List items; + + public Root03() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem03 value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root04.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root04.java new file mode 100644 index 0000000..7d20e58 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root04.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root04 { + + private final List items; + + public Root04() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem04 value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root05.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root05.java new file mode 100644 index 0000000..5ea0788 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root05.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root05 { + + private final List items; + + public Root05() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem05 value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root06.java b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root06.java new file mode 100644 index 0000000..f4136b0 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nlinear/Root06.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nlinear; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root06 { + + private final List items; + + public Root06() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem06 value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nmap/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/linear/nmap/AllTests.java new file mode 100644 index 0000000..71e7666 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nmap/AllTests.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nmap; + +import daxi.moe.model.AnyData; +import daxi.moe.model.LinearData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Model2Object] Linear member with mapped data items") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] Linear Data holding Mapped data items can be converted") + public void test01() { + LinearData tlData = new LinearData(); + + MappedData item1 = new MappedData(); + item1.put("member1", new AnyData(new SimpleData("item1-str"))); + item1.put("member2", new AnyData(new SimpleData(101))); + tlData.add(new AnyData(item1)); + + MappedData item2 = new MappedData(); + item2.put("member1", new AnyData(new SimpleData("item2-str"))); + item2.put("member2", new AnyData(new SimpleData(102))); + tlData.add(new AnyData(item2)); + + mainData().put("items", new AnyData(tlData)); + + Root01 root = Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(2, root.getItems().size()); + + ListItem item = root.getItems().get(0); + Assertions.assertEquals("item1-str", item.getMember1()); + Assertions.assertEquals(101, item.getMember2()); + + item = root.getItems().get(1); + Assertions.assertEquals("item2-str", item.getMember1()); + Assertions.assertEquals(102, item.getMember2()); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] Linear Data holding Mapped data items converted with mismatch") + public void test02() { + LinearData tlData = new LinearData(); + + MappedData item1 = new MappedData(); + item1.put("member1", new AnyData(new SimpleData("item1-str"))); + // Mismatch: member2 is expected to be a SimpleData, but we provide a MappedData + item1.put("member2", new AnyData(new MappedData())); + tlData.add(new AnyData(item1)); + + MappedData item2 = new MappedData(); + item2.put("member1", new AnyData(new SimpleData("item2-str"))); + item2.put("member2", new AnyData(new LinearData())); + // Mismatch: member2 is expected to be a SimpleData, but we provide a LinearData + tlData.add(new AnyData(item2)); + + mainData().put("items", new AnyData(tlData)); + + Root01 root = Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(2, root.getItems().size()); + + ListItem item = root.getItems().get(0); + Assertions.assertEquals("item1-str", item.getMember1()); + Assertions.assertEquals(0, item.getMember2()); + + item = root.getItems().get(1); + Assertions.assertEquals("item2-str", item.getMember1()); + Assertions.assertEquals(0, item.getMember2()); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nmap/ListItem.java b/src/test/java/daxi/moe/test/mod2obj/linear/nmap/ListItem.java new file mode 100644 index 0000000..bfc550d --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nmap/ListItem.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nmap; + +import daxi.moe.app.MapFrom; + +public class ListItem { + + private String member1; + private int member2; + + public String getMember1() { + return member1; + } + + public int getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMember1(String val) { + member1 = val; + } + + @MapFrom("member2") + private void _setMember2(int val) { + member2 = val; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/nmap/Root01.java b/src/test/java/daxi/moe/test/mod2obj/linear/nmap/Root01.java new file mode 100644 index 0000000..5cd3776 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/nmap/Root01.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.nmap; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root01 { + + private final List items; + + public Root01() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ListItem value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/simple/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/linear/simple/AllTests.java new file mode 100644 index 0000000..eac9174 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/simple/AllTests.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.simple; + +import daxi.moe.app.ConvertException; +import daxi.moe.model.AnyData; +import daxi.moe.model.LinearData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Model2Object] Linear String items") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] Setters to add String items to a list") + public void test01() { + LinearData tlData = new LinearData(); + tlData.add(new AnyData(new SimpleData("item1"))); + tlData.add(new AnyData(new SimpleData("item2"))); + mainData().put("items", new AnyData(tlData)); + + Root01 root = Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(2, root.getItems().size()); + Assertions.assertEquals("item1", root.getItems().get(0)); + Assertions.assertEquals("item2", root.getItems().get(1)); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] Setters to add String items to a list, on an entity with other " + + "mapped members") + public void test02() { + LinearData tlData = new LinearData(); + tlData.add(new AnyData(new SimpleData("item1"))); + tlData.add(new AnyData(new SimpleData("item2"))); + mainData().put("items", new AnyData(tlData)); + mainData().put("member1", new AnyData(new SimpleData("value1"))); + + Root02 root = Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(2, root.getItems().size()); + Assertions.assertEquals("item1", root.getItems().get(0)); + Assertions.assertEquals("item2", root.getItems().get(1)); + Assertions.assertEquals("value1", root.getMember1()); + } + + @Test + @Order(3) + @DisplayName("[Model2Object] Setters cannot add String items to a list where the type does " + + "not match the setter parameter type") + public void test03() { + LinearData tlData = new LinearData(); + tlData.add(new AnyData(new SimpleData("item1"))); + tlData.add(new AnyData(new SimpleData("item2"))); + mainData().put("items", new AnyData(tlData)); + + Root03 root = Assertions.assertDoesNotThrow(() -> external().convert(Root03.class)); + Assertions.assertNotNull(root); + Assertions.assertEquals(0, root.getItems().size()); + } + + @Test + @Order(4) + @DisplayName("[Model2Object] Setters to add String items to a list can throw an exception") + public void test04() { + LinearData tlData = new LinearData(); + tlData.add(new AnyData(new SimpleData("item1"))); + tlData.add(new AnyData(new SimpleData("item2"))); + mainData().put("items", new AnyData(tlData)); + + ConvertException exep = Assertions.assertThrows( + ConvertException.class, () -> external().convert(Root04.class)); + Throwable cause = exep.getCause().getCause(); + Assertions.assertNotNull(cause); + Assertions.assertEquals("some-error", cause.getMessage()); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root01.java b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root01.java new file mode 100644 index 0000000..1651ad8 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root01.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.simple; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * A simple test class to demonstrate the mapping of a list of strings from the data model to an + * object. + * + * @author indroneel + */ + +public class Root01 { + + private final List items; + + public Root01() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(String value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root02.java b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root02.java new file mode 100644 index 0000000..9d94deb --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root02.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.simple; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author indroneel + */ + +public class Root02 { + + private String member1; + private final List items; + + public Root02() { + items = new ArrayList<>(); + } + + public String getMember1() { + return member1; + } + + public List getItems() { + return items; + } + + @MapFrom("member1") + private void _setMember1(String value) { + member1 = value; + } + + @MapFrom("items") + private void _setItem(String value) { + System.out.println("item: " + value); + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root03.java b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root03.java new file mode 100644 index 0000000..6a03fe6 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root03.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.simple; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * A simple test class to demonstrate the mapping of a list of strings from the data model to an + * object. + * + * @author indroneel + */ + +public class Root03 { + + private final List items; + + public Root03() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(ValueObject value) { + items.add(value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root04.java b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root04.java new file mode 100644 index 0000000..9f5ebc4 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/simple/Root04.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.simple; + +import daxi.moe.app.MapFrom; + +import java.util.ArrayList; +import java.util.List; + +/** + * A simple test class to demonstrate the mapping of a list of strings from the data model to an + * object. + * + * @author indroneel + */ + +public class Root04 { + + private final List items; + + public Root04() { + items = new ArrayList<>(); + } + + public List getItems() { + return items; + } + + @MapFrom("items") + private void _setItem(String value) { + throw new RuntimeException("some-error"); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/linear/simple/ValueObject.java b/src/test/java/daxi/moe/test/mod2obj/linear/simple/ValueObject.java new file mode 100644 index 0000000..37a8b46 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/linear/simple/ValueObject.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.linear.simple; + +import daxi.moe.app.MapFrom; + +public class ValueObject { + + private String value; + + public String getValue() { + return value; + } + + @MapFrom("value") + private void _setValue(String value) { + this.value = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/AllTests.java new file mode 100644 index 0000000..947dc02 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/AllTests.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.pstr; + +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +@DisplayName("[Model2Object] Mapped nested setter semantics for string") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] Mapped Data -> Nested entity with no setters and blank mappers " + + "- not created") + public void test01() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("nested", new AnyData(nested)); + + StringRoot entity = + Assertions.assertDoesNotThrow(() -> external().convert(StringRoot.class)); + Assertions.assertNotNull(entity); + Assertions.assertNotNull(entity.getNested()); + + String nestedMember1 = entity.getNested().getMember1(); + Assertions.assertEquals("string-value-01", nestedMember1); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringNested.java b/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringNested.java new file mode 100644 index 0000000..0dbb1d5 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringNested.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.pstr; + +import daxi.moe.app.MapFrom; + +public class StringNested { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringRoot.java b/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringRoot.java new file mode 100644 index 0000000..0ebd77d --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/pstr/StringRoot.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.pstr; + +import daxi.moe.app.MapFrom; + +public class StringRoot { + + private StringNested nested; + + public StringNested getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(StringNested nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/AllTests.java new file mode 100644 index 0000000..2014fe0 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/AllTests.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.ConvertException; +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.InvocationTargetException; +import java.util.logging.Logger; + +@DisplayName("[Model2Object] Mapped nested setter semantics") +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] Mapped Data -> Nested entity with no setters and blank mappers " + + "- not created") + public void test01() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("nested", new AnyData(nested)); + + Root01 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(entity); + Assertions.assertNull(entity.getNested()); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] Mapped data -> Nested entity without default constructor " + + "- not created") + public void test02() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("nested", new AnyData(nested)); + + Root02 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNotNull(entity); + Assertions.assertNull(entity.getNested()); + } + + @Test + @Order(3) + @DisplayName("[Model2Object] Mapped Data -> Nested entity - constructor throws Exception") + public void test03() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + + mainData().put("nested", new AnyData(nested)); + + ConvertException exep = + Assertions.assertThrows( + ConvertException.class, () -> external().convert(Root03.class)); + Throwable cause1 = exep.getCause(); + Assertions.assertEquals(InvocationTargetException.class, cause1.getClass()); + Throwable cause2 = cause1.getCause(); + Assertions.assertEquals("some-error", cause2.getMessage()); + } + + @Test + @Order(4) + @DisplayName("[Model2Object] Mapped Data -> Nested entity - array value for setter") + public void test04() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("nested", new AnyData(nested)); + + Root04 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root04.class)); + Assertions.assertNotNull(entity); + Assertions.assertNotNull(entity.getNested()); + Assertions.assertNull(entity.getNested().getMember1()); + } + + @Test + @Order(5) + @DisplayName("[Model2Object] Mapped Data -> Nested entity - parameterized value for setter") + public void test05() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("nested", new AnyData(nested)); + + Root05 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root05.class)); + Assertions.assertNotNull(entity); + Assertions.assertNotNull(entity.getNested()); + Assertions.assertNull(entity.getNested().getMember1()); + } + + @Test + @Order(6) + @DisplayName("[Model2Object] Mapped Data -> Nested entity - duplicate key name for setter") + public void test06() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("nested", new AnyData(nested)); + + ConvertException exep = + Assertions.assertThrows( + ConvertException.class, () -> external().convert(Root06.class)); + } + + @Test + @Order(7) + @DisplayName("[Model2Object] Mapped Data -> Nested entity is created") + public void test07() { + MappedData nested = new MappedData(); + nested.put("member1", new AnyData(new SimpleData("string-value-01"))); + nested.put("member2", new AnyData(new SimpleData(100))); + + mainData().put("nested", new AnyData(nested)); + + GoodRoot entity = + Assertions.assertDoesNotThrow(() -> external().convert(GoodRoot.class)); + Assertions.assertNotNull(entity); + + Assertions.assertNotNull(entity.getNested()); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodNested.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodNested.java new file mode 100644 index 0000000..f93e786 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodNested.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +public class GoodNested { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("some-key") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodRoot.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodRoot.java new file mode 100644 index 0000000..76fe1d5 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/GoodRoot.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +public class GoodRoot { + + private GoodNested nested; + + public GoodNested getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(GoodNested nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested01.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested01.java new file mode 100644 index 0000000..4a2c83c --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested01.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +/** + * @author indroneel + */ + +public class Nested01 { +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested02.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested02.java new file mode 100644 index 0000000..4715a81 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested02.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Nested02 { + + public Nested02(String param) { + //NOOP + } + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested03.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested03.java new file mode 100644 index 0000000..5df5036 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested03.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Nested03 { + + public Nested03() { + throw new RuntimeException("some-error"); + } + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested04.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested04.java new file mode 100644 index 0000000..9e60752 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested04.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Nested04 { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("some-other-key") + private void applyMember(String value) { + member1 = value; + } + + @MapFrom("member1") + private void applyMember1(String[] value) { + member1 = value[0]; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested05.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested05.java new file mode 100644 index 0000000..6ed5cef --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested05.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Nested05 { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("some-other-key") + private void applyMember(String value) { + member1 = value; + } + + @MapFrom("member1") + private void applyMember1(PType value) { + member1 = value.getValue(); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested06.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested06.java new file mode 100644 index 0000000..9755c72 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Nested06.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Nested06 { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void applyMember1(String value) { + member1 = value; + } + + @MapFrom("member1") + private void applyMember2(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/NestedEntity10.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/NestedEntity10.java new file mode 100644 index 0000000..ff1c9a0 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/NestedEntity10.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +public class NestedEntity10 { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("some-key") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/PType.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/PType.java new file mode 100644 index 0000000..34b4d07 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/PType.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +public class PType { + + private T value; + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root01.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root01.java new file mode 100644 index 0000000..2ba27b2 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root01.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Root01 { + + private Nested01 nested; + + public Nested01 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(Nested01 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root02.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root02.java new file mode 100644 index 0000000..8ec6048 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root02.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Root02 { + + private Nested02 nested; + + public Nested02 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(Nested02 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root03.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root03.java new file mode 100644 index 0000000..7a8629a --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root03.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Root03 { + + private Nested03 nested; + + public Nested03 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(Nested03 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root04.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root04.java new file mode 100644 index 0000000..6d9726a --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root04.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Root04 { + + private Nested04 nested; + + public Nested04 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(Nested04 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root05.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root05.java new file mode 100644 index 0000000..abef60a --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root05.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Root05 { + + private Nested05 nested; + + public Nested05 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(Nested05 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root06.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root06.java new file mode 100644 index 0000000..b03335b --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/Root06.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Root06 { + + private Nested06 nested; + + public Nested06 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(Nested06 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/RootEntity10.java b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/RootEntity10.java new file mode 100644 index 0000000..b9a72ed --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/mapped/semantic/RootEntity10.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.mapped.semantic; + +import daxi.moe.app.MapFrom; + +public class RootEntity10 { + + private NestedEntity10 nested1; + + public NestedEntity10 getNested1() { + return nested1; + } + + @MapFrom("nested1") + private void doNested1(NestedEntity10 nested) { + nested1 = nested; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/AllTests.java new file mode 100644 index 0000000..89b2e95 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/AllTests.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.pstr; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mod2obj.Check; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Model2Object] Simple blank mapped for string values") +@Order(11) +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] blank mapped method is invoked for a string key-value pair") + public void test01() { + mainData().put("key-1", new AnyData(new SimpleData("string-value-01"))); + + StringRoot01 root = + Assertions.assertDoesNotThrow(() -> external().convert(StringRoot01.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals("string-value-01", root.getValue("key-1")); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] blank mapped method is invoked for each key-value pair in the " + + "model data") + public void test02() { + mainData().put("key-1", new AnyData(new SimpleData("string-value-01"))); + mainData().put("key-2", new AnyData(new SimpleData("string-value-02"))); + + StringRoot01 root = + Assertions.assertDoesNotThrow(() -> external().convert(StringRoot01.class)); + Assertions.assertNotNull(root); + + Assertions.assertEquals("string-value-01", root.getValue("key-1")); + Assertions.assertEquals("string-value-02", root.getValue("key-2")); + } + + @Test + @Order(3) + @DisplayName("[Model2Object] simple string data cannot be mapped to a custom object type " + + "using blank mapped method") + public void test03() { + mainData().put("key-1", new AnyData(new SimpleData("string-value-01"))); + + Check.reset(); + StringRoot02 root = + Assertions.assertDoesNotThrow(() -> external().convert(StringRoot02.class)); + Assertions.assertNotNull(root); + + Assertions.assertFalse(Check.isSet()); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/Nested.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/Nested.java new file mode 100644 index 0000000..630d2f7 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/Nested.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.pstr; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +public class Nested { + + private final Map theMap = new HashMap<>(); + + public String getValue(String key) { + return theMap.get(key); + } + + @MapFrom + private void setValue(String key, String value) { + theMap.put(key, value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot01.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot01.java new file mode 100644 index 0000000..2d59c46 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot01.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.pstr; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +public class StringRoot01 { + + private final Map theMap = new HashMap<>(); + + public String getValue(String key) { + return theMap.get(key); + } + + @MapFrom + private void setValue(String key, String value) { + theMap.put(key, value); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot02.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot02.java new file mode 100644 index 0000000..73314a1 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/pstr/StringRoot02.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.pstr; + +import daxi.moe.app.MapFrom; +import daxi.moe.test.mod2obj.Check; + +public class StringRoot02 { + + @MapFrom + private void setValue(String key, Nested value) { + Check.set(); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/AllTests.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/AllTests.java new file mode 100644 index 0000000..c47dec6 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/AllTests.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.semantic; + +import daxi.moe.app.ConvertException; +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.mem.mod2obj.MemMod2ObjTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.InvocationTargetException; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("[Model2Object] Simple blank mapped semantic tests") +@Order(13) +public class AllTests extends MemMod2ObjTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @Order(1) + @DisplayName("[Model2Object] blank mapped method requires a blank @MapFrom annotation") + public void test01() { + Root01 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNull(root); + } + + @Test + @Order(2) + @DisplayName("[Model2Object] blank mapped method must have private visibility") + public void test02() { + Root02 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNull(root); + } + + @Test + @Order(3) + @DisplayName("[Model2Object] blank mapped method must return void") + public void test03() { + Root03 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root03.class)); + Assertions.assertNull(root); + } + + @Test + @Order(4) + @DisplayName("[Model2Object] blank mapped method must have the first parameter as string") + public void test04() { + String val1 = "bad big decimal"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + + Root04 root = + Assertions.assertDoesNotThrow(() -> external().convert(Root04.class)); + Assertions.assertNull(root); + } + + @Test + @Order(5) + @DisplayName("[Model2Object] blank mapped method can throw an exception") + public void test05() { + String val1 = "bad big decimal"; + mainData().put("member1", new AnyData(new SimpleData(val1))); + + ConvertException exep = + Assertions.assertThrows(ConvertException.class, () -> external().convert(Root05.class)); + Throwable cause1 = exep.getCause(); + Assertions.assertEquals(InvocationTargetException.class, cause1.getClass()); + Throwable cause2 = cause1.getCause(); + Assertions.assertEquals("some-error", cause2.getMessage()); + } + + @Test + @Order(6) + @DisplayName("[Model2Object] Multiple blank mapped methods on the same entity throw " + + "an exception") + public void test06() { + mainData().put("member1", new AnyData(new SimpleData("str-val-01"))); + + ConvertException exep = + Assertions.assertThrows(ConvertException.class, () -> external().convert(Root06.class)); + /* + Throwable cause1 = exep.getCause(); + Assertions.assertEquals(InvocationTargetException.class, cause1.getClass()); + Throwable cause2 = cause1.getCause(); + Assertions.assertEquals("some-error", cause2.getMessage()); + */ + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root01.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root01.java new file mode 100644 index 0000000..5562e2e --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root01.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.semantic; + +import daxi.moe.app.MapFrom; + +public class Root01 { + + @MapFrom("some-key") + private void _blankMap(String key, String value) { + //NOOP + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root02.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root02.java new file mode 100644 index 0000000..538a4fd --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root02.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.semantic; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +public class Root02 { + + @MapFrom + public void _blankMap(String key, String value) { + //NOOP + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root03.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root03.java new file mode 100644 index 0000000..42cb522 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root03.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.semantic; + +import daxi.moe.app.MapFrom; + +public class Root03 { + + @MapFrom + private boolean _blankMap(String key, String value) { + return true; + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root04.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root04.java new file mode 100644 index 0000000..799e823 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root04.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.semantic; + +import daxi.moe.app.MapFrom; + +import java.math.BigInteger; + +public class Root04 { + + @MapFrom + private void _blankMap(BigInteger key, String value) { + //NOOP + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root05.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root05.java new file mode 100644 index 0000000..f44b714 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root05.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.semantic; + +import daxi.moe.app.MapFrom; + +public class Root05 { + + @MapFrom + private void _blankMap(String key, String value) { + throw new RuntimeException("some-error"); + } +} diff --git a/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root06.java b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root06.java new file mode 100644 index 0000000..96402e0 --- /dev/null +++ b/src/test/java/daxi/moe/test/mod2obj/simple/blankmap/semantic/Root06.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.mod2obj.simple.blankmap.semantic; + +import daxi.moe.app.MapFrom; +import daxi.moe.test.mod2obj.Check; +import daxi.moe.test.mod2obj.simple.blankmap.pstr.Nested; + +public class Root06 { + + @MapFrom + private void _setValue1(String key, Nested value) { + Check.set(); + } + + @MapFrom + private void _setValue2(String key, Nested value) { + Check.set(); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn01/MemInvalidEntityTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn01/MemInvalidEntityTests.java deleted file mode 100644 index 82a04ef..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn01/MemInvalidEntityTests.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn01; - -import daxi.moe.app.External; -import daxi.moe.app.Internal; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - invalid entity classes") -@Order(1) -public class MemInvalidEntityTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemInvalidEntityTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Create Moe and support for in-memory external data") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - Assertions.assertNotNull(extern); - Internal intern = moe.internal("mem"); - Assertions.assertNotNull(intern); - } - - @Test - @Order(2) - @DisplayName("Ext2Obj - Entity with no mapping annotations is not created") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - mainData.put("member2", new AnyData(new SimpleData("string-value-02"))); - - InvalidEntity01 entity = extern.convert(InvalidEntity01.class); - Assertions.assertNull(entity); - } - - @Test - @Order(3) - @DisplayName("Ext2Obj - Entity with no default constructor is not created") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - mainData.put("member2", new AnyData(new SimpleData("string-value-02"))); - - InvalidEntity02 entity = extern.convert(InvalidEntity02.class); - Assertions.assertNull(entity); - } - - @Test - @Order(4) - @DisplayName("Ext2Obj - Entity with no public default constructor is not created") - public void test04() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - mainData.put("member2", new AnyData(new SimpleData("string-value-02"))); - - InvalidEntity03 entity = extern.convert(InvalidEntity03.class); - Assertions.assertNull(entity); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/MemIncorrectSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn02/MemIncorrectSetterTests.java deleted file mode 100644 index caf7528..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn02/MemIncorrectSetterTests.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn02; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.logging.Logger; - -@DisplayName("Memory Codec - incorrect setter methods") -@Order(2) -public class MemIncorrectSetterTests { - - private static final Logger L = Logger.getLogger(MemIncorrectSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Ext2Obj - Setter method that does not start with '_set' is not populated") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - mainData.put("member2", new AnyData(new SimpleData("string-value-02"))); - - NopopEntity01 entity = extern.convert(NopopEntity01.class); - Assertions.assertNotNull(entity); - - Assertions.assertNull(entity.getMember1()); - } - - @Test - @Order(2) - @DisplayName("Ext2Obj - Setter method '_set' is not populated") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - mainData.put("member2", new AnyData(new SimpleData("string-value-02"))); - - NopopEntity02 entity = extern.convert(NopopEntity02.class); - Assertions.assertNotNull(entity); - - Assertions.assertNull(entity.getMember1()); - } - - @Test - @Order(3) - @DisplayName("Ext2Obj - Setter method with wrong parameter count is not populated") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - mainData.put("member2", new AnyData(new SimpleData("string-value-02"))); - - NopopEntity03 entity = extern.convert(NopopEntity03.class); - Assertions.assertNotNull(entity); - - Assertions.assertNull(entity.getMember1()); - } - - @Test - @Order(4) - @DisplayName("Ext2Obj - Setter method with missing MapFrom key is not populated") - public void test04() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - mainData.put("member3", new AnyData(new SimpleData("string-value-02"))); - - ValidEntity entity = extern.convert(ValidEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals("string-value-01", entity.getMember1()); - Assertions.assertNull(entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn03/MemSimpleSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn03/MemSimpleSetterTests.java deleted file mode 100644 index b54739e..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn03/MemSimpleSetterTests.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn03; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - simple setter methods") -@Order(3) -public class MemSimpleSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemSimpleSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with a string member is created") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - mainData.put("member1", new AnyData(new SimpleData("string-value-01"))); - - StringEntity entity = extern.convert(StringEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals("string-value-01", entity.getMember1()); - } - - @Test - @Order(2) - @DisplayName("Entity with boolean/Boolean members is created") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - mainData.put("member1", new AnyData(new SimpleData(true))); - mainData.put("member2", new AnyData(new SimpleData(Boolean.TRUE))); - - BooleanEntity entity = extern.convert(BooleanEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertTrue(entity.isMember1()); - Assertions.assertNotNull(entity.getMember2()); - Assertions.assertEquals(Boolean.TRUE, entity.getMember2()); - } - - @Test - @Order(3) - @DisplayName("Entity with boolean/Boolean members is created from true/false string values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "true"; - String val2 = "tRUe"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - BooleanEntity entity = extern.convert(BooleanEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertTrue(entity.isMember1()); - Assertions.assertNotNull(entity.getMember2()); - Assertions.assertEquals(Boolean.TRUE, entity.getMember2()); - } - - @Test - @Order(4) - @DisplayName("Entity with boolean/Boolean members is created from number values") - public void test04() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - int val1 = 100; - int val2 = 0; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - BooleanEntity entity = extern.convert(BooleanEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertTrue(entity.isMember1()); - Assertions.assertNotNull(entity.getMember2()); - Assertions.assertEquals(Boolean.FALSE, entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn04/MemByteSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn04/MemByteSetterTests.java deleted file mode 100644 index b8c375f..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn04/MemByteSetterTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn04; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - byte setter methods") -@Order(4) -public class MemByteSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemByteSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with byte/Byte members is created") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - byte val1 = 0x1A; - byte val2 = 0x1B; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - ByteEntity entity = extern.convert(ByteEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals(val1, entity.getMember1()); - Assertions.assertEquals(val2, entity.getMember2()); - } - - @Test - @Order(2) - @DisplayName("Entity with byte/Byte members is created from String values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "26"; - String val2 = "27"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - ByteEntity entity = extern.convert(ByteEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals((byte) 26, entity.getMember1()); - Assertions.assertEquals(Byte.valueOf((byte) 27), entity.getMember2()); - } - - @Test - @Order(3) - @DisplayName("Entity with byte/Byte members is not created from non-numeric String values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad byte 1"; - String val2 = "bad byte 2"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - ByteEntity entity = extern.convert(ByteEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals(0, entity.getMember1()); - Assertions.assertNull(entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn05/MemShortSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn05/MemShortSetterTests.java deleted file mode 100644 index 83e1321..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn05/MemShortSetterTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn05; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - short setter methods") -@Order(5) -public class MemShortSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemShortSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with short/Short members is created") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - short val1 = 16343; - short val2 = 2048; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - ShortEntity entity = extern.convert(ShortEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(val1, entity.getMember1()); - Assertions.assertEquals(val2, entity.getMember2()); - } - - @Test - @Order(2) - @DisplayName("Entity with short/Short members is created from String values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - String val1 = "16343"; - String val2 = "2048"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - ShortEntity entity = extern.convert(ShortEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals((short) 16343, entity.getMember1()); - Assertions.assertEquals(Short.valueOf((short)2048), entity.getMember2()); - } - - @Test - @Order(3) - @DisplayName("Entity with short/Short members is not created from non-numeric String values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad short 1"; - String val2 = "bad short 2"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - ShortEntity entity = extern.convert(ShortEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals(0, entity.getMember1()); - Assertions.assertNull(entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn06/MemIntegerSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn06/MemIntegerSetterTests.java deleted file mode 100644 index e8588e3..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn06/MemIntegerSetterTests.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn06; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.Random; -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - integer setter methods") -@Order(6) -public class MemIntegerSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemIntegerSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with int/Integer members is created") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - int val1 = random.nextInt(); - Integer val2 = random.nextInt(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - IntegerEntity entity = extern.convert(IntegerEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(val1, entity.getMember1()); - Assertions.assertEquals(val2, entity.getMember2()); - } - - @Test - @Order(2) - @DisplayName("Entity with int/Integer members is created from string values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - int i1 = random.nextInt(); - int i2 = random.nextInt(); - String val1 = String.valueOf(i1); - String val2 = String.valueOf(i2); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - IntegerEntity entity = extern.convert(IntegerEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(i1, entity.getMember1()); - Assertions.assertEquals(i2, entity.getMember2()); - } - - @Test - @Order(3) - @DisplayName("Entity with int/Integer members is not created from non-numeric String values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad int 1"; - String val2 = "bad int 2"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - IntegerEntity entity = extern.convert(IntegerEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals(0, entity.getMember1()); - Assertions.assertNull(entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn07/MemFloatSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn07/MemFloatSetterTests.java deleted file mode 100644 index be6f08a..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn07/MemFloatSetterTests.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn07; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.Random; -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - float setter methods") -@Order(7) -public class MemFloatSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemFloatSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with float/Float members is created") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - float val1 = random.nextFloat(); - Float val2 = random.nextFloat(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - FloatEntity entity = extern.convert(FloatEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(val1, entity.getMember1()); - Assertions.assertEquals(val2, entity.getMember2()); - } - - @Test - @Order(2) - @DisplayName("Entity with float/Float members is created from string values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - float f1 = random.nextFloat(); - float f2 = random.nextFloat(); - String val1 = String.valueOf(f1); - String val2 = String.valueOf(f2); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - FloatEntity entity = extern.convert(FloatEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(f1, entity.getMember1()); - Assertions.assertEquals(f2, entity.getMember2()); - } - - @Test - @Order(3) - @DisplayName("Entity with float/Float members is not created from non-numeric String values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad float 1"; - String val2 = "bad float 2"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - FloatEntity entity = extern.convert(FloatEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals(0, entity.getMember1()); - Assertions.assertNull(entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn08/MemLongSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn08/MemLongSetterTests.java deleted file mode 100644 index 5de8217..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn08/MemLongSetterTests.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn08; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.Random; -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - long setter methods") -@Order(8) -public class MemLongSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemLongSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with long/Long members is created") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - long val1 = random.nextLong(); - Long val2 = random.nextLong(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - LongEntity entity = extern.convert(LongEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(val1, entity.getMember1()); - Assertions.assertEquals(val2, entity.getMember2()); - } - - @Test - @Order(2) - @DisplayName("Entity with long/Long members is created from string values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - long l1 = random.nextLong(); - long l2 = random.nextLong(); - String val1 = String.valueOf(l1); - String val2 = String.valueOf(l2); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - LongEntity entity = extern.convert(LongEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(l1, entity.getMember1()); - Assertions.assertEquals(l2, entity.getMember2()); - } - - @Test - @Order(3) - @DisplayName("Entity with long/Long members is not created from non-numeric String values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad long 1"; - String val2 = "bad long 2"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - LongEntity entity = extern.convert(LongEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals(0, entity.getMember1()); - Assertions.assertNull(entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn09/MemDoubleSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn09/MemDoubleSetterTests.java deleted file mode 100644 index 436cd25..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn09/MemDoubleSetterTests.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn09; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.util.Random; -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - double setter methods") -@Order(9) -public class MemDoubleSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemDoubleSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with double/Double members is created") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - double val1 = random.nextDouble(); - Double val2 = random.nextDouble(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - DoubleEntity entity = extern.convert(DoubleEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(val1, entity.getMember1()); - Assertions.assertEquals(val2, entity.getMember2()); - } - - @Test - @Order(2) - @DisplayName("Entity with double/Double members is created from string values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - double d1 = random.nextDouble(); - double d2 = random.nextDouble(); - String val1 = String.valueOf(d1); - String val2 = String.valueOf(d2); - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - DoubleEntity entity = extern.convert(DoubleEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(d1, entity.getMember1()); - Assertions.assertEquals(d2, entity.getMember2()); - } - - @Test - @Order(3) - @DisplayName("Entity with double/Double members is not created from non-numeric String values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad double 1"; - String val2 = "bad double 2"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - mainData.put("member2", new AnyData(new SimpleData(val2))); - - DoubleEntity entity = extern.convert(DoubleEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertEquals(0, entity.getMember1()); - Assertions.assertNull(entity.getMember2()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn10/MemBigIntegerSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn10/MemBigIntegerSetterTests.java deleted file mode 100644 index 2cc2d55..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn10/MemBigIntegerSetterTests.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn10; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.math.BigInteger; -import java.util.Random; -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - big integer setter methods") -@Order(10) -public class MemBigIntegerSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemBigIntegerSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with BigInteger members is created from long values") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - long val1 = random.nextLong(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigIntegerEntity entity = extern.convert(BigIntegerEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(BigInteger.valueOf(val1), entity.getMember1()); - } - - @Test - @Order(2) - @DisplayName("Entity with BigInteger members is created from double values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - double val1 = random.nextDouble(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigIntegerEntity entity = extern.convert(BigIntegerEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(BigInteger.valueOf((long) val1), entity.getMember1()); - } - - @Test - @Order(3) - @DisplayName("Entity with BigInteger members is created from string values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - String val1 = "123456789012345678901234567890"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigIntegerEntity entity = extern.convert(BigIntegerEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(new BigInteger(val1), entity.getMember1()); - } - - @Test - @Order(4) - @DisplayName("Entity with BigInteger members is not created from non-numeric string values") - public void test04() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad big integer"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigIntegerEntity entity = extern.convert(BigIntegerEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertNull(entity.getMember1()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn11/MemBigDecimalSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn11/MemBigDecimalSetterTests.java deleted file mode 100644 index 34432ff..0000000 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn11/MemBigDecimalSetterTests.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) DuxTechnica - * - * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not - * use this file except in compliance with the License. You may obtain a copy of the License by - * contacting: - * - * Dux Technica, contact@duxtechnica.com - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package daxi.moe.test.scenario.alfa.scn11; - -import daxi.moe.app.External; -import daxi.moe.app.Moe; -import daxi.moe.model.AnyData; -import daxi.moe.model.MappedData; -import daxi.moe.model.SimpleData; -import daxi.moe.test.setup.AbstractTests; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import java.math.BigDecimal; -import java.util.Random; -import java.util.logging.Logger; - -/** - * @author indroneel - */ - -@DisplayName("Memory Codec - big decimal setter methods") -@Order(11) -public class MemBigDecimalSetterTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(MemBigDecimalSetterTests.class.getName()); - - @Test - @Order(1) - @DisplayName("Entity with BigDecimal members is created from double values") - public void test01() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - double val1 = random.nextDouble(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigDecimalEntity entity = extern.convert(BigDecimalEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(BigDecimal.valueOf(val1), entity.getMember1()); - } - - @Test - @Order(2) - @DisplayName("Entity with BigDecimal members is created from long values") - public void test02() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - long val1 = random.nextLong(); - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigDecimalEntity entity = extern.convert(BigDecimalEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(BigDecimal.valueOf(val1), entity.getMember1()); - } - - @Test - @Order(3) - @DisplayName("Entity with BigDecimal members is created from string values") - public void test03() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - Random random = new Random(); - String val1 = "123456789012345678901234567890.123"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigDecimalEntity entity = extern.convert(BigDecimalEntity.class); - Assertions.assertNotNull(entity); - - Assertions.assertEquals(new BigDecimal(val1), entity.getMember1()); - } - - @Test - @Order(4) - @DisplayName("Entity with BigDecimal members is not created from non-numeric string values") - public void test04() { - Moe moe = Moe.create(); - External extern = moe.external("mem"); - AnyData model = extern.getModel(); - MappedData mainData = model.asMapped(); - Assertions.assertNotNull(mainData); - - String val1 = "bad big decimal"; - mainData.put("member1", new AnyData(new SimpleData(val1))); - - BigDecimalEntity entity = extern.convert(BigDecimalEntity.class); - Assertions.assertNotNull(entity); - Assertions.assertNull(entity.getMember1()); - } -} diff --git a/src/test/java/daxi/moe/test/scenario/mem/MemCodecTests.java b/src/test/java/daxi/moe/test/scenario/mem/MemCodecTests.java new file mode 100644 index 0000000..be633eb --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/MemCodecTests.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem; + +import daxi.moe.app.External; +import daxi.moe.app.Moe; +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; + +import java.util.logging.Logger; + +/** + * This class is a placeholder for the test suite that will be used to test the memory codec + * functionality. It extends AbstractTests, which provides common setup and utility methods for the + * tests. + * + * @author indroneel + */ + +public class MemCodecTests extends AbstractTests { + + private static final Logger L = Logger.getLogger(MemCodecTests.class.getName()); + + private External extern; + private MappedData mainData; + + @BeforeEach + public final void beforeEach() { + L.info("beforeEach - resetting the test environment"); + Moe moe = Moe.create(); + extern = moe.external("mem"); + AnyData model = extern.getModel(); + mainData = model.asMapped(); + Assertions.assertNotNull(mainData); + } + + protected final External external() { + return extern; + } + + protected final MappedData mainData() { + return mainData; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/MappedSetterTests.java b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/MappedSetterTests.java new file mode 100644 index 0000000..97f975a --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/MappedSetterTests.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0402_mapped_setter; + +import daxi.moe.app.ConvertException; +import daxi.moe.app.External; +import daxi.moe.app.Moe; +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.scenario.mem.MemCodecTests; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +@DisplayName("Memory Codec - mapped setter basic methods") +@Order(402) +public class MappedSetterTests extends MemCodecTests { + + private static final Logger L = Logger.getLogger(MappedSetterTests.class.getName()); + + @Test + @Order(1) + @DisplayName("Non-matching MapFrom key in a nested entity will not be populated") + public void test01() { + MappedData nested = new MappedData(); + nested.put("some-key-1", new AnyData(new MappedData())); + + mainData().put("nested", new AnyData(nested)); + + RootEntity01 entity = + Assertions.assertDoesNotThrow(() -> external().convert(RootEntity01.class)); + Assertions.assertNotNull(entity); + + NestedEntity01 nent = entity.getNested(); + Assertions.assertNotNull(nent); + Assertions.assertNull(nent.getMember2()); + } + + @Test + @Order(2) + @DisplayName("Nested entity with matching MapFrom keys will be populated for string members") + public void test02() { + MappedData nested = new MappedData(); + nested.put("some-key", new AnyData(new SimpleData("string-value-01"))); + nested.put("some-other-key", new AnyData(new SimpleData("string-value-02"))); + + mainData().put("nested", new AnyData(nested)); + + RootEntity01 entity = + Assertions.assertDoesNotThrow(() -> external().convert(RootEntity01.class)); + Assertions.assertNotNull(entity); + + NestedEntity01 nent = entity.getNested(); + Assertions.assertNotNull(nent); + + Assertions.assertEquals("string-value-01", nent.getMember1()); + Assertions.assertEquals("string-value-02", nent.getMember2()); + } + + @Test + @Order(3) + @DisplayName("Mapped Data -> Nested entity - setter method throws exception") + public void test03() { + MappedData nested = new MappedData(); + nested.put("some-key", new AnyData(new SimpleData("string-value-01"))); + mainData().put("nested", new AnyData(nested)); + + ConvertException exep = + Assertions.assertThrows( + ConvertException.class, () -> external().convert(RootEntity02.class)); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/ValidEntity.java b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/NestedEntity01.java similarity index 74% rename from src/test/java/daxi/moe/test/scenario/alfa/scn02/ValidEntity.java rename to src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/NestedEntity01.java index 1873cb8..eee33db 100644 --- a/src/test/java/daxi/moe/test/scenario/alfa/scn02/ValidEntity.java +++ b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/NestedEntity01.java @@ -12,34 +12,31 @@ * limitations under the License. */ -package daxi.moe.test.scenario.alfa.scn02; +package daxi.moe.test.scenario.mem.s0402_mapped_setter; import daxi.moe.app.MapFrom; -public class ValidEntity { +public class NestedEntity01 { private String member1; - private String member2; - public ValidEntity() { - //NOOP - } + private String member2; public String getMember1() { return member1; } - public String getMember2() { + public String getMember2() { return member2; } - @MapFrom("member1") - private void _set1(String value) { + @MapFrom("some-key") + private void applyMember1(String value) { member1 = value; } - @MapFrom("member2") - private void _set2(String value) { + @MapFrom("some-other-key") + private void applyMember2(String value) { member2 = value; } } diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/NestedEntity02.java b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/NestedEntity02.java new file mode 100644 index 0000000..2b34728 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/NestedEntity02.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0402_mapped_setter; + +import daxi.moe.app.MapFrom; + +public class NestedEntity02 { + + private String member1; + + private String member2; + + public String getMember1() { + return member1; + } + + @MapFrom("some-key") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity01.java b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity01.java new file mode 100644 index 0000000..2d158af --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity01.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0402_mapped_setter; + +import daxi.moe.app.MapFrom; + +public class RootEntity01 { + + private NestedEntity01 nested; + + public NestedEntity01 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(NestedEntity01 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity02.java b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity02.java new file mode 100644 index 0000000..af1e3cb --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0402_mapped_setter/RootEntity02.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0402_mapped_setter; + +import daxi.moe.app.MapFrom; + +public class RootEntity02 { + + private NestedEntity02 nested; + + public NestedEntity02 getNested() { + return nested; + } + + @MapFrom("nested") + private void doNested(NestedEntity02 nested) { + this.nested = nested; + throw new RuntimeException("some-error"); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/charlie/AllTests.java b/src/test/java/daxi/moe/test/scenario/mem/s0403_mapped_setter_bool/MappedSetterBooleanTests.java similarity index 64% rename from src/test/java/daxi/moe/test/scenario/charlie/AllTests.java rename to src/test/java/daxi/moe/test/scenario/mem/s0403_mapped_setter_bool/MappedSetterBooleanTests.java index 462d1f6..3bc5fae 100644 --- a/src/test/java/daxi/moe/test/scenario/charlie/AllTests.java +++ b/src/test/java/daxi/moe/test/scenario/mem/s0403_mapped_setter_bool/MappedSetterBooleanTests.java @@ -12,7 +12,7 @@ * limitations under the License. */ -package daxi.moe.test.scenario.charlie; +package daxi.moe.test.scenario.mem.s0403_mapped_setter_bool; import daxi.moe.test.setup.AbstractTests; import org.junit.jupiter.api.DisplayName; @@ -21,23 +21,22 @@ import org.junit.jupiter.api.Test; import java.util.logging.Logger; -/** - * @author indroneel - */ +@DisplayName("Memory Codec - mapped setter basic methods") +@Order(402) +public class MappedSetterBooleanTests extends AbstractTests { -@DisplayName("Tests Charlie") -public class AllTests extends AbstractTests { - - private static final Logger L = Logger.getLogger(AllTests.class.getName()); + private static final Logger L = Logger.getLogger(MappedSetterBooleanTests.class.getName()); @Test @Order(1) + @DisplayName("Non-matching MapFrom key in a nested entity will not be populated") public void test01() { } @Test @Order(2) + @DisplayName("Nested entity with matching MapFrom keys will be populated") public void test02() { } diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/BadBlankMapperTests.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/BadBlankMapperTests.java new file mode 100644 index 0000000..f375c18 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/BadBlankMapperTests.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.External; +import daxi.moe.app.Moe; +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.scenario.mem.MemCodecTests; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("Memory Codec - bad blank mapped methods") +@Order(501) +public class BadBlankMapperTests extends MemCodecTests { + + private static final Logger L = Logger.getLogger(BadBlankMapperTests.class.getName()); + + @Test + @Order(1) + @DisplayName("Mapped Data -> Nested entity blank adder - wrong convention") + public void test01() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested = new MappedData(); + snested.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested", new AnyData(snested)); + + State.reset(); + Root01 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(entity); + + Nested01 nst = entity.getNested(); + Assertions.assertNotNull(nst); + Assertions.assertFalse(State.isCalled()); + } + + @Test + @Order(2) + @DisplayName("Mapped Data -> Nested entity blank adder - wrong convention") + public void test02() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested = new MappedData(); + snested.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested", new AnyData(snested)); + + State.reset(); + Root02 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNotNull(entity); + + Nested02 nst = entity.getNested(); + Assertions.assertNotNull(nst); + Assertions.assertFalse(State.isCalled()); + } + + @Test + @Order(3) + @DisplayName("Mapped Data -> Nested entity blank adder - wrong convention") + public void test03() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested = new MappedData(); + snested.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested", new AnyData(snested)); + + State.reset(); + Root03 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root03.class)); + Assertions.assertNotNull(entity); + + Nested03 nst = entity.getNested(); + Assertions.assertNotNull(nst); + Assertions.assertFalse(State.isCalled()); + } + + @Test + @Order(4) + @DisplayName("Mapped Data -> Nested entity blank adder - wrong convention") + public void test04() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested = new MappedData(); + snested.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested", new AnyData(snested)); + + State.reset(); + Root04 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root04.class)); + Assertions.assertNotNull(entity); + + Nested04 nst = entity.getNested(); + Assertions.assertNotNull(nst); + Assertions.assertFalse(State.isCalled()); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested01.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested01.java new file mode 100644 index 0000000..84cc6c5 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested01.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +/** + * @author indroneel + */ + +public class Nested01 { + + @MapFrom + private void _addNested(SubNested subn) { + State.setCalled(); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested02.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested02.java new file mode 100644 index 0000000..55fa9e8 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested02.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +import java.math.BigInteger; + +public class Nested02 { + + @MapFrom + private void _addNested(SubNested subn) { + // NOOP + } + + @MapFrom + private void _addNested(BigInteger key, SubNested subn) { + State.setCalled(); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested03.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested03.java new file mode 100644 index 0000000..aba726a --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested03.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class Nested03 { + + @MapFrom + private void _addNested(SubNested subn) { + // NOOP + } + + @MapFrom + private void _addNested(String key, SubNestedP subn) { + State.setCalled(); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested04.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested04.java new file mode 100644 index 0000000..786b479 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Nested04.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class Nested04 { + + @MapFrom + private void _addNested(SubNested subn) { + // NOOP + } + + @MapFrom + private void _addNested(String key, SubNested[] subn) { + State.setCalled(); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root01.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root01.java new file mode 100644 index 0000000..23e5cbf --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root01.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class Root01 { + + private Nested01 nested; + + public Nested01 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested01 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root02.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root02.java new file mode 100644 index 0000000..4a72aa7 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root02.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class Root02 { + + private Nested02 nested; + + public Nested02 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested02 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root03.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root03.java new file mode 100644 index 0000000..a582b02 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root03.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class Root03 { + + private Nested03 nested; + + public Nested03 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested03 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root04.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root04.java new file mode 100644 index 0000000..70f9e55 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/Root04.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class Root04 { + + private Nested04 nested; + + public Nested04 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested04 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/State.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/State.java new file mode 100644 index 0000000..3eae4dc --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/State.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +public class State { + + private static boolean called = false; + + public static boolean isCalled() { + return called; + } + + public static void reset() { + called = false; + } + + public static void setCalled() { + called = true; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNested.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNested.java new file mode 100644 index 0000000..dad4f2f --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNested.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class SubNested { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("some-key") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNestedP.java b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNestedP.java new file mode 100644 index 0000000..87e6fe4 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0501_mapped_blank_bad/SubNestedP.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0501_mapped_blank_bad; + +import daxi.moe.app.MapFrom; + +public class SubNestedP { + + private T member1; + + public T getMember1() { + return member1; + } + + @MapFrom("some-key") + private void applyMember1(T value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/MappedBlankTests.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/MappedBlankTests.java new file mode 100644 index 0000000..78e6716 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/MappedBlankTests.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.ConvertException; +import daxi.moe.app.External; +import daxi.moe.app.Moe; +import daxi.moe.model.AnyData; +import daxi.moe.model.MappedData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.scenario.mem.MemCodecTests; +import daxi.moe.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +@DisplayName("Memory Codec - mapped blank basic methods") +@Order(403) +public class MappedBlankTests extends MemCodecTests { + + private static final Logger L = Logger.getLogger(MappedBlankTests.class.getName()); + + @Test + @Order(1) + @DisplayName("Mapped Blank - setter methods eclipse blank mapping methods") + public void test01() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested01 = new MappedData(); + snested01.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested", new AnyData(snested01)); + + MappedData snested02 = new MappedData(); + snested02.put("some-key", new AnyData(new SimpleData("some-value-02"))); + nested.put("blank-key", new AnyData(snested02)); + + Root01 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root01.class)); + Assertions.assertNotNull(entity); + + Nested01 nst = entity.getNested(); + Assertions.assertNotNull(nst); + + SubNestedA sna = nst.getSubNested1(); + SubNestedB snb = nst.getSubNested2(); + Assertions.assertNotNull(sna); + Assertions.assertNull(snb); + } + + @Test + @Order(2) + @DisplayName("Mapped Blank - blank mapped method success") + public void test02() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested01 = new MappedData(); + snested01.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested-1", new AnyData(snested01)); + + Root02 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNotNull(entity); + + Nested02 nst = entity.getNested(); + Assertions.assertNotNull(nst); + + SubNestedA sn1 = nst.getSubNested("sub-nested-1"); + Assertions.assertNotNull(sn1); + + Assertions.assertEquals("some-value-01", sn1.getMember1()); + } + + @Test + @Order(3) + @DisplayName("Mapped Blank - blank mapped method called multiple times") + public void test03() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested01 = new MappedData(); + snested01.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested-1", new AnyData(snested01)); + + MappedData snested02 = new MappedData(); + snested02.put("some-key", new AnyData(new SimpleData("some-value-02"))); + nested.put("sub-nested-2", new AnyData(snested02)); + + Root02 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root02.class)); + Assertions.assertNotNull(entity); + + Nested02 nst = entity.getNested(); + Assertions.assertNotNull(nst); + + SubNestedA sn1 = nst.getSubNested("sub-nested-1"); + Assertions.assertNotNull(sn1); + + Assertions.assertEquals("some-value-01", sn1.getMember1()); + + SubNestedA sn2 = nst.getSubNested("sub-nested-2"); + Assertions.assertNotNull(sn2); + Assertions.assertEquals("some-value-02", sn2.getMember1()); + } + + @Test + @Order(4) + @DisplayName("Mapped Blank - blank mapped method not called for simple types") + @Disabled + public void test04() { + MappedData nested = new MappedData(); + nested.put("sub-nested-1", new AnyData(new SimpleData("some-value-01"))); + + mainData().put("nested", new AnyData(nested)); + + Root03 entity = + Assertions.assertDoesNotThrow(() -> external().convert(Root03.class)); + Assertions.assertNotNull(entity); + + Nested03 nst = entity.getNested(); + Assertions.assertNotNull(nst); + + String sn1 = nst.getNestedValue("sub-nested-1"); + Assertions.assertNull(sn1); + } + + @Test + @Order(5) + @DisplayName("Mapped Blank - blank mapped method can throw exception") + public void test05() { + MappedData nested = new MappedData(); + mainData().put("nested", new AnyData(nested)); + + MappedData snested01 = new MappedData(); + snested01.put("some-key", new AnyData(new SimpleData("some-value-01"))); + nested.put("sub-nested-1", new AnyData(snested01)); + + ConvertException exep = Assertions.assertThrows( + ConvertException.class, () -> external().convert(Root04.class)); + Assertions.assertNotNull(exep); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested01.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested01.java new file mode 100644 index 0000000..a49d32e --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested01.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +public class Nested01 { + + private SubNestedA subNested1; + private SubNestedB subNested2; + + public SubNestedA getSubNested1() { + return subNested1; + } + + public SubNestedB getSubNested2() { + return subNested2; + } + + @MapFrom("sub-nested") + private void _setSubNested1(SubNestedA subNested1) { + this.subNested1 = subNested1; + } + + @MapFrom + private void _setBlank(String key, SubNestedB subNested2) { + this.subNested2 = subNested2; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested02.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested02.java new file mode 100644 index 0000000..15b393c --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested02.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +public class Nested02 { + + private Map nestedMap = new HashMap<>(); + + public SubNestedA getSubNested(String key) { + return nestedMap.get(key); + } + + @MapFrom + private void _setBlank(String key, SubNestedA subNested1) { + nestedMap.put(key, subNested1); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested03.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested03.java new file mode 100644 index 0000000..0943dae --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested03.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +public class Nested03 { + + private final Map nestedMap = new HashMap<>(); + + public String getNestedValue(String key) { + return nestedMap.get(key); + } + + @MapFrom + private void _setBlank(String key, String value) { + nestedMap.put(key, value); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested04.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested04.java new file mode 100644 index 0000000..4a5224c --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Nested04.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +public class Nested04 { + + private Map nestedMap = new HashMap<>(); + + public SubNestedA getSubNested(String key) { + return nestedMap.get(key); + } + + @MapFrom + private void _setBlank(String key, SubNestedA subNested1) { + throw new RuntimeException("some-error"); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root01.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root01.java new file mode 100644 index 0000000..4a29fed --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root01.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +public class Root01 { + + private Nested01 nested; + + public Nested01 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested01 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root02.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root02.java new file mode 100644 index 0000000..873b384 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root02.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +public class Root02 { + + private Nested02 nested; + + public Nested02 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested02 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root03.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root03.java new file mode 100644 index 0000000..5a11ac8 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root03.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +public class Root03 { + + private Nested03 nested; + + public Nested03 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested03 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root04.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root04.java new file mode 100644 index 0000000..b7fc7a0 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/Root04.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +public class Root04 { + + private Nested04 nested; + + public Nested04 getNested() { + return nested; + } + + @MapFrom("nested") + private void _setNested(Nested04 nested) { + this.nested = nested; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedA.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedA.java new file mode 100644 index 0000000..a469e56 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedA.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +public class SubNestedA { + + private String member1; + + public String getMember1() { + return member1; + } + + @MapFrom("some-key") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedB.java b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedB.java new file mode 100644 index 0000000..3e034eb --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/s0502_mapped_blank/SubNestedB.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.s0502_mapped_blank; + +import daxi.moe.app.MapFrom; + +public class SubNestedB { + + private String member1; + + private String member2; + + public String getMember1() { + return member1; + } + + @MapFrom("some-key") + private void applyMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/simple/strput/AllTests.java b/src/test/java/daxi/moe/test/scenario/mem/simple/strput/AllTests.java new file mode 100644 index 0000000..bde49ce --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/simple/strput/AllTests.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.simple.strput; + +import daxi.moe.model.AnyData; +import daxi.moe.model.SimpleData; +import daxi.moe.test.scenario.mem.MemCodecTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +@DisplayName("XXX") +public class AllTests extends MemCodecTests { + + private static final Logger L = Logger.getLogger(AllTests.class.getName()); + + @Test + @DisplayName("") + @Order(1) + public void test01() { + mainData().put("key-01", new AnyData(new SimpleData("string-value-01"))); + + Root rootEntity = + Assertions.assertDoesNotThrow(() -> external().convert(Root.class)); + Assertions.assertNotNull(rootEntity); + Assertions.assertEquals("string-value-01", rootEntity.getValue("key-01")); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/mem/simple/strput/Root.java b/src/test/java/daxi/moe/test/scenario/mem/simple/strput/Root.java new file mode 100644 index 0000000..2dc5b74 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/mem/simple/strput/Root.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package daxi.moe.test.scenario.mem.simple.strput; + +import daxi.moe.app.MapFrom; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author indroneel + */ + +public class Root { + + private final Map map = new HashMap<>(); + + public String getValue(String key) { + return map.get(key); + } + + @MapFrom + private void _putValue(String key, String value) { + System.out.println(key + ": " + value); + map.put(key, value); + } +} diff --git a/src/test/java/daxi/moe/test/scenario/bravo/AllTests.java b/src/test/java/daxi/moe/test/scenario/mem/simple/strset/AllTests.java similarity index 66% rename from src/test/java/daxi/moe/test/scenario/bravo/AllTests.java rename to src/test/java/daxi/moe/test/scenario/mem/simple/strset/AllTests.java index 5bb260f..c44c843 100644 --- a/src/test/java/daxi/moe/test/scenario/bravo/AllTests.java +++ b/src/test/java/daxi/moe/test/scenario/mem/simple/strset/AllTests.java @@ -12,33 +12,15 @@ * limitations under the License. */ -package daxi.moe.test.scenario.bravo; +package daxi.moe.test.scenario.mem.simple.strset; -import daxi.moe.test.setup.AbstractTests; +import daxi.moe.test.scenario.mem.MemCodecTests; import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; import java.util.logging.Logger; -/** - * @author indroneel - */ - -@DisplayName("Tests Bravo") -public class AllTests extends AbstractTests { +@DisplayName("") +public class AllTests extends MemCodecTests { private static final Logger L = Logger.getLogger(AllTests.class.getName()); - - @Test - @Order(1) - public void test01() { - - } - - @Test - @Order(2) - public void test02() { - - } } diff --git a/testdata/json/mod2obj/semantics/bad01.json b/testdata/json/mod2obj/semantics/bad01.json new file mode 100644 index 0000000..e5a2fab --- /dev/null +++ b/testdata/json/mod2obj/semantics/bad01.json @@ -0,0 +1 @@ +does not have json data diff --git a/testdata/json/mod2obj/semantics/good.json b/testdata/json/mod2obj/semantics/good.json new file mode 100644 index 0000000..6b4de28 --- /dev/null +++ b/testdata/json/mod2obj/semantics/good.json @@ -0,0 +1,5 @@ +{ + "member1" : "str-val-01", + "member2" : "str-val-02", + "member3" : 100 +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/linear/boolval/test01.json b/testdata/json/mod2obj/setter/linear/boolval/test01.json new file mode 100644 index 0000000..c3a8630 --- /dev/null +++ b/testdata/json/mod2obj/setter/linear/boolval/test01.json @@ -0,0 +1,3 @@ +{ + "members": [true, false, "true"] +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/linear/intval/test01.json b/testdata/json/mod2obj/setter/linear/intval/test01.json new file mode 100644 index 0000000..fff3b5d --- /dev/null +++ b/testdata/json/mod2obj/setter/linear/intval/test01.json @@ -0,0 +1,3 @@ +{ + "members": [100, 112, 120] +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/linear/objval/test01.json b/testdata/json/mod2obj/setter/linear/objval/test01.json new file mode 100644 index 0000000..23baf52 --- /dev/null +++ b/testdata/json/mod2obj/setter/linear/objval/test01.json @@ -0,0 +1,8 @@ +{ + "nested" : [{ + "member1" : "str-val-01" + },{ + "member1" : "str-val-02" + } + ] +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/linear/objval/test02.json b/testdata/json/mod2obj/setter/linear/objval/test02.json new file mode 100644 index 0000000..9e83f18 --- /dev/null +++ b/testdata/json/mod2obj/setter/linear/objval/test02.json @@ -0,0 +1,19 @@ +{ + "nested" : + [ + { + "items" : + [ + { "member1" : "str-val-01" }, + { "member1" : "str-val-02" } + ] + }, + { + "items" : + [ + { "member1" : "str-val-03" }, + { "member1" : "str-val-04" } + ] + } + ] +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/linear/strval/test01.json b/testdata/json/mod2obj/setter/linear/strval/test01.json new file mode 100644 index 0000000..64bcd06 --- /dev/null +++ b/testdata/json/mod2obj/setter/linear/strval/test01.json @@ -0,0 +1,3 @@ +{ + "members": ["first", "second", "third"] +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/mapped/blank/test01.json b/testdata/json/mod2obj/setter/mapped/blank/test01.json new file mode 100644 index 0000000..e9f0fba --- /dev/null +++ b/testdata/json/mod2obj/setter/mapped/blank/test01.json @@ -0,0 +1,6 @@ +{ + "nested": { + "member1": "str-val-01", + "member2": "str-val-02" + } +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/mapped/intval/test01.json b/testdata/json/mod2obj/setter/mapped/intval/test01.json new file mode 100644 index 0000000..c8a1a8a --- /dev/null +++ b/testdata/json/mod2obj/setter/mapped/intval/test01.json @@ -0,0 +1,6 @@ +{ + "nested": { + "member1": 100, + "member2": 200 + } +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/mapped/intval/test02.json b/testdata/json/mod2obj/setter/mapped/intval/test02.json new file mode 100644 index 0000000..a92fcb5 --- /dev/null +++ b/testdata/json/mod2obj/setter/mapped/intval/test02.json @@ -0,0 +1,6 @@ +{ + "nested": { + "member1": "1000", + "member2": "2000" + } +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/mapped/intval/test03.json b/testdata/json/mod2obj/setter/mapped/intval/test03.json new file mode 100644 index 0000000..8f0f49e --- /dev/null +++ b/testdata/json/mod2obj/setter/mapped/intval/test03.json @@ -0,0 +1,6 @@ +{ + "nested" : { + "member1": "abc", + "member2": "def" + } +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/mapped/strval/test01.json b/testdata/json/mod2obj/setter/mapped/strval/test01.json new file mode 100644 index 0000000..026e37e --- /dev/null +++ b/testdata/json/mod2obj/setter/mapped/strval/test01.json @@ -0,0 +1,5 @@ +{ + "nested": { + "member1": "str-val-01" + } +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/mapped/strval/test02.json b/testdata/json/mod2obj/setter/mapped/strval/test02.json new file mode 100644 index 0000000..04ad4f7 --- /dev/null +++ b/testdata/json/mod2obj/setter/mapped/strval/test02.json @@ -0,0 +1,3 @@ +{ + "nested": "str-val-01" +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/simple/bdecval/test01.json b/testdata/json/mod2obj/setter/simple/bdecval/test01.json new file mode 100644 index 0000000..702c8d9 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bdecval/test01.json @@ -0,0 +1,3 @@ +{ + "member1": 12345.6789 +} diff --git a/testdata/json/mod2obj/setter/simple/bdecval/test02.json b/testdata/json/mod2obj/setter/simple/bdecval/test02.json new file mode 100644 index 0000000..c69799d --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bdecval/test02.json @@ -0,0 +1,3 @@ +{ + "member1": 12345678901234567890 +} diff --git a/testdata/json/mod2obj/setter/simple/bdecval/test03.json b/testdata/json/mod2obj/setter/simple/bdecval/test03.json new file mode 100644 index 0000000..a7ae3de --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bdecval/test03.json @@ -0,0 +1,3 @@ +{ + "member1": "123456789012345678901234567890.123" +} diff --git a/testdata/json/mod2obj/setter/simple/bdecval/test04.json b/testdata/json/mod2obj/setter/simple/bdecval/test04.json new file mode 100644 index 0000000..c7eb05e --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bdecval/test04.json @@ -0,0 +1,3 @@ +{ + "member1": "bad big decimal" +} diff --git a/testdata/json/mod2obj/setter/simple/bintval/test01.json b/testdata/json/mod2obj/setter/simple/bintval/test01.json new file mode 100644 index 0000000..04b1e11 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bintval/test01.json @@ -0,0 +1,3 @@ +{ + "member1": 1234567890123 +} diff --git a/testdata/json/mod2obj/setter/simple/bintval/test02.json b/testdata/json/mod2obj/setter/simple/bintval/test02.json new file mode 100644 index 0000000..247595f --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bintval/test02.json @@ -0,0 +1,3 @@ +{ + "member1": 123.75 +} diff --git a/testdata/json/mod2obj/setter/simple/bintval/test03.json b/testdata/json/mod2obj/setter/simple/bintval/test03.json new file mode 100644 index 0000000..cb00cc3 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bintval/test03.json @@ -0,0 +1,3 @@ +{ + "member1": "123456789012345678901234567890" +} diff --git a/testdata/json/mod2obj/setter/simple/bintval/test04.json b/testdata/json/mod2obj/setter/simple/bintval/test04.json new file mode 100644 index 0000000..9c4ffb9 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bintval/test04.json @@ -0,0 +1,3 @@ +{ + "member1": "bad big integer" +} diff --git a/testdata/json/mod2obj/setter/simple/bintval/test05.json b/testdata/json/mod2obj/setter/simple/bintval/test05.json new file mode 100644 index 0000000..7cd0a83 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/bintval/test05.json @@ -0,0 +1,3 @@ +{ + "member1": 123456789012345678901234567890 +} diff --git a/testdata/json/mod2obj/setter/simple/boolval/test01.json b/testdata/json/mod2obj/setter/simple/boolval/test01.json new file mode 100644 index 0000000..976563f --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/boolval/test01.json @@ -0,0 +1,4 @@ +{ + "member1": true, + "member2": true +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/simple/boolval/test02.json b/testdata/json/mod2obj/setter/simple/boolval/test02.json new file mode 100644 index 0000000..a303ad4 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/boolval/test02.json @@ -0,0 +1,4 @@ +{ + "member1": "truE", + "member2": "tRUe" +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/simple/byteval/test01.json b/testdata/json/mod2obj/setter/simple/byteval/test01.json new file mode 100644 index 0000000..9e032c1 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/byteval/test01.json @@ -0,0 +1,4 @@ +{ + "member1": 26, + "member2": 27 +} diff --git a/testdata/json/mod2obj/setter/simple/byteval/test02.json b/testdata/json/mod2obj/setter/simple/byteval/test02.json new file mode 100644 index 0000000..e7f6920 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/byteval/test02.json @@ -0,0 +1,4 @@ +{ + "member1": "-128", + "member2": "127" +} diff --git a/testdata/json/mod2obj/setter/simple/byteval/test03.json b/testdata/json/mod2obj/setter/simple/byteval/test03.json new file mode 100644 index 0000000..ba00747 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/byteval/test03.json @@ -0,0 +1,4 @@ +{ + "member1": "abc", + "member2": "def" +} diff --git a/testdata/json/mod2obj/setter/simple/byteval/test04.json b/testdata/json/mod2obj/setter/simple/byteval/test04.json new file mode 100644 index 0000000..c3b1ba0 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/byteval/test04.json @@ -0,0 +1,4 @@ +{ + "member1": 257, + "member2": 258 +} diff --git a/testdata/json/mod2obj/setter/simple/doubleval/test01.json b/testdata/json/mod2obj/setter/simple/doubleval/test01.json new file mode 100644 index 0000000..d9ffee8 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/doubleval/test01.json @@ -0,0 +1,4 @@ +{ + "member1": 12.234, + "member2": -987 +} diff --git a/testdata/json/mod2obj/setter/simple/doubleval/test02.json b/testdata/json/mod2obj/setter/simple/doubleval/test02.json new file mode 100644 index 0000000..dbe7fd3 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/doubleval/test02.json @@ -0,0 +1,4 @@ +{ + "member1": "12345.625", + "member2": "-0.125" +} diff --git a/testdata/json/mod2obj/setter/simple/doubleval/test03.json b/testdata/json/mod2obj/setter/simple/doubleval/test03.json new file mode 100644 index 0000000..ba00747 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/doubleval/test03.json @@ -0,0 +1,4 @@ +{ + "member1": "abc", + "member2": "def" +} diff --git a/testdata/json/mod2obj/setter/simple/floatval/test01.json b/testdata/json/mod2obj/setter/simple/floatval/test01.json new file mode 100644 index 0000000..a2e39d8 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/floatval/test01.json @@ -0,0 +1,4 @@ +{ + "member1": 12, + "member2": -987 +} diff --git a/testdata/json/mod2obj/setter/simple/floatval/test02.json b/testdata/json/mod2obj/setter/simple/floatval/test02.json new file mode 100644 index 0000000..dbe7fd3 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/floatval/test02.json @@ -0,0 +1,4 @@ +{ + "member1": "12345.625", + "member2": "-0.125" +} diff --git a/testdata/json/mod2obj/setter/simple/floatval/test03.json b/testdata/json/mod2obj/setter/simple/floatval/test03.json new file mode 100644 index 0000000..ba00747 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/floatval/test03.json @@ -0,0 +1,4 @@ +{ + "member1": "abc", + "member2": "def" +} diff --git a/testdata/json/mod2obj/setter/simple/intval/test01.json b/testdata/json/mod2obj/setter/simple/intval/test01.json new file mode 100644 index 0000000..04f7800 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/intval/test01.json @@ -0,0 +1,4 @@ +{ + "member1": 100, + "member2": 200 +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/simple/intval/test02.json b/testdata/json/mod2obj/setter/simple/intval/test02.json new file mode 100644 index 0000000..1b4b2b3 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/intval/test02.json @@ -0,0 +1,4 @@ +{ + "member1": "1000", + "member2": "2000" +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/simple/intval/test03.json b/testdata/json/mod2obj/setter/simple/intval/test03.json new file mode 100644 index 0000000..a868915 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/intval/test03.json @@ -0,0 +1,4 @@ +{ + "member1": "abc", + "member2": "def" +} \ No newline at end of file diff --git a/testdata/json/mod2obj/setter/simple/longval/test01.json b/testdata/json/mod2obj/setter/simple/longval/test01.json new file mode 100644 index 0000000..24cb6fb --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/longval/test01.json @@ -0,0 +1,4 @@ +{ + "member1": 1234567890123, + "member2": 9876543210987 +} diff --git a/testdata/json/mod2obj/setter/simple/longval/test02.json b/testdata/json/mod2obj/setter/simple/longval/test02.json new file mode 100644 index 0000000..0ae25ba --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/longval/test02.json @@ -0,0 +1,4 @@ +{ + "member1": "12345678901234", + "member2": "98765432109876" +} diff --git a/testdata/json/mod2obj/setter/simple/longval/test03.json b/testdata/json/mod2obj/setter/simple/longval/test03.json new file mode 100644 index 0000000..ba00747 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/longval/test03.json @@ -0,0 +1,4 @@ +{ + "member1": "abc", + "member2": "def" +} diff --git a/testdata/json/mod2obj/setter/simple/shortval/test01.json b/testdata/json/mod2obj/setter/simple/shortval/test01.json new file mode 100644 index 0000000..38463bc --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/shortval/test01.json @@ -0,0 +1,4 @@ +{ + "member1": 16343, + "member2": 2048 +} diff --git a/testdata/json/mod2obj/setter/simple/shortval/test02.json b/testdata/json/mod2obj/setter/simple/shortval/test02.json new file mode 100644 index 0000000..40a9d21 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/shortval/test02.json @@ -0,0 +1,4 @@ +{ + "member1": "-32768", + "member2": "32767" +} diff --git a/testdata/json/mod2obj/setter/simple/shortval/test03.json b/testdata/json/mod2obj/setter/simple/shortval/test03.json new file mode 100644 index 0000000..ba00747 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/shortval/test03.json @@ -0,0 +1,4 @@ +{ + "member1": "abc", + "member2": "def" +} diff --git a/testdata/json/mod2obj/setter/simple/shortval/test04.json b/testdata/json/mod2obj/setter/simple/shortval/test04.json new file mode 100644 index 0000000..9bcdb33 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/shortval/test04.json @@ -0,0 +1,4 @@ +{ + "member1": 32769, + "member2": 32770 +} diff --git a/testdata/json/mod2obj/setter/simple/strval/test01.json b/testdata/json/mod2obj/setter/simple/strval/test01.json new file mode 100644 index 0000000..b4689c5 --- /dev/null +++ b/testdata/json/mod2obj/setter/simple/strval/test01.json @@ -0,0 +1,3 @@ +{ + "member1" : "str-val-01" +} \ No newline at end of file