From 9a3d916656d56e24b188c466fbe5b7dc8ada1a06 Mon Sep 17 00:00:00 2001 From: indroneel Date: Mon, 5 Oct 2026 20:54:46 +0530 Subject: [PATCH] the first commit --- .editorconfig | 9 ++ .gitignore | 62 +++++++++ build.gradle | 90 +++++++++++++ settings.gradle | 15 +++ .../scenario/alfa/scn01/InvalidEntity01.java | 34 +++++ .../scenario/alfa/scn01/InvalidEntity02.java | 46 +++++++ .../scenario/alfa/scn01/InvalidEntity03.java | 45 +++++++ .../alfa/scn01/MemInvalidEntityTests.java | 99 ++++++++++++++ .../alfa/scn02/MemIncorrectSetterTests.java | 107 +++++++++++++++ .../scenario/alfa/scn02/NopopEntity01.java | 35 +++++ .../scenario/alfa/scn02/NopopEntity02.java | 35 +++++ .../scenario/alfa/scn02/NopopEntity03.java | 35 +++++ .../test/scenario/alfa/scn02/ValidEntity.java | 45 +++++++ .../scenario/alfa/scn03/BooleanEntity.java | 45 +++++++ .../alfa/scn03/MemSimpleSetterTests.java | 123 ++++++++++++++++++ .../scenario/alfa/scn03/StringEntity.java | 35 +++++ .../test/scenario/alfa/scn04/ByteEntity.java | 45 +++++++ .../alfa/scn04/MemByteSetterTests.java | 102 +++++++++++++++ .../alfa/scn05/MemShortSetterTests.java | 102 +++++++++++++++ .../test/scenario/alfa/scn05/ShortEntity.java | 45 +++++++ .../scenario/alfa/scn06/IntegerEntity.java | 45 +++++++ .../alfa/scn06/MemIntegerSetterTests.java | 109 ++++++++++++++++ .../test/scenario/alfa/scn07/FloatEntity.java | 45 +++++++ .../alfa/scn07/MemFloatSetterTests.java | 109 ++++++++++++++++ .../test/scenario/alfa/scn08/LongEntity.java | 45 +++++++ .../alfa/scn08/MemLongSetterTests.java | 109 ++++++++++++++++ .../scenario/alfa/scn09/DoubleEntity.java | 45 +++++++ .../alfa/scn09/MemDoubleSetterTests.java | 109 ++++++++++++++++ .../scenario/alfa/scn10/BigIntegerEntity.java | 41 ++++++ .../alfa/scn10/MemBigIntegerSetterTests.java | 119 +++++++++++++++++ .../scenario/alfa/scn11/BigDecimalEntity.java | 41 ++++++ .../alfa/scn11/MemBigDecimalSetterTests.java | 119 +++++++++++++++++ .../moe/test/scenario/bravo/AllTests.java | 44 +++++++ .../moe/test/scenario/charlie/AllTests.java | 44 +++++++ .../moe/test/scenario/delta/AllTests.java | 44 +++++++ .../daxi/moe/test/setup/AbstractTests.java | 57 ++++++++ .../test/setup/LauncherSessionHandler.java | 43 ++++++ ....platform.launcher.LauncherSessionListener | 15 +++ src/test/resources/logback.xml | 63 +++++++++ 39 files changed, 2400 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 build.gradle create mode 100644 settings.gradle create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity01.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity02.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity03.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn01/MemInvalidEntityTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn02/MemIncorrectSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity01.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity02.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity03.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn02/ValidEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn03/BooleanEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn03/MemSimpleSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn03/StringEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn04/ByteEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn04/MemByteSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn05/MemShortSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn05/ShortEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn06/IntegerEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn06/MemIntegerSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn07/FloatEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn07/MemFloatSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn08/LongEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn08/MemLongSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn09/DoubleEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn09/MemDoubleSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn10/BigIntegerEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn10/MemBigIntegerSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn11/BigDecimalEntity.java create mode 100644 src/test/java/daxi/moe/test/scenario/alfa/scn11/MemBigDecimalSetterTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/bravo/AllTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/charlie/AllTests.java create mode 100644 src/test/java/daxi/moe/test/scenario/delta/AllTests.java create mode 100644 src/test/java/daxi/moe/test/setup/AbstractTests.java create mode 100644 src/test/java/daxi/moe/test/setup/LauncherSessionHandler.java create mode 100644 src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener create mode 100644 src/test/resources/logback.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..94e001b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +indent_style = tab +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fdc9df --- /dev/null +++ b/.gitignore @@ -0,0 +1,62 @@ +## OS Generated + +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +Desktop.ini + +## Eclipse IDE + +.project +.classpath +.settings/ +.metadata +bin/ +*.tmp +*.bak +*.swp +local.properties +.externalToolBuilders/ +*.launch +.pmd +.eclipse-pmd + +# Intellij Idea +.idea +*.iml + +# Maven +target/ + +# Gradle +.gradle +/build/ +/gradle/ +/gradlew +/gradlew.bat + +## Project specific +deploy + +# Default by github for Java projects + +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Maven versionsBackup + +*.versionsBackup diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..1b4ce5d --- /dev/null +++ b/build.gradle @@ -0,0 +1,90 @@ +/* + * 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. + */ + +plugins { + id "java" + id "jacoco" +} + +version = "v1-SNAPSHOT" + +repositories { + mavenLocal() + mavenCentral() + maven { + url "https://maven.indroneel.co/repo/snapshots" + } +} + +dependencies { + implementation "daxi.moe:daxi.moe.main: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 "org.codehaus.janino:janino:3.1.9" +} + +tasks.named("test", Test) { + useJUnitPlatform() + systemProperty "junit.jupiter.extensions.autodetection.enabled", "true" + + /* + filter { + includeTestsMatching("fully.qualified.package.*") + } + */ + + testLogging { + events "started", "passed", "failed", "skipped" + showStandardStreams = true + displayGranularity 2 + reports + finalizedBy jacocoTestReport + } +} + +jacocoTestReport { + dependsOn test + reports { + xml.required = true + csv.required = false + //html.outputLocation = layout.buildDirectory.dir('jacocoHtml') + } + + afterEvaluate { + def classDir = file("${projectDir}/../scanpath-v1/target/classes") + def sourceDir = file("${projectDir}/../scanpath-v1/src/main/java") + + def mainSrcDir = file("${projectDir}/../moe/moe-main/src/main/java") + def jsonSrcDir = file("${projectDir}/../moe/moe-json/src/main/java") + def yamlSrcDir = file("${projectDir}/../moe/moe-yaml/src/main/java") + def tomlSrcDir = file("${projectDir}/../moe/moe-toml/src/main/java") + + def mainClsDir = file("${projectDir}/../moe/moe-main/target/classes") + def jsonClsDir = file("${projectDir}/../moe/moe-json/target/classes") + def yamlClsDir = file("${projectDir}/../moe/moe-yaml/target/classes") + def tomlClsDir = file("${projectDir}/../moe/moe-toml/target/classes") + + sourceDirectories.setFrom(files(sourceDir, mainSrcDir, jsonSrcDir, yamlSrcDir, tomlSrcDir)) + classDirectories.setFrom(files( + fileTree(dir: mainClsDir), + fileTree(dir: jsonClsDir), + fileTree(dir: yamlClsDir), + fileTree(dir: tomlClsDir) + )) + } +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..c475156 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,15 @@ +/* + * 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. + */ + +rootProject.name = "moe-tests" diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity01.java b/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity01.java new file mode 100644 index 0000000..a42afd8 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity01.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.alfa.scn01; + + +public class InvalidEntity01 { + + private String member1; + private String member2; + + public InvalidEntity01() { + //NOOP + } + + public String getMember1() { + return member1; + } + + public String getMember2() { + return member2; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity02.java b/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity02.java new file mode 100644 index 0000000..57a5c05 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity02.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.scenario.alfa.scn01; + +import daxi.moe.app.MapFrom; + +public class InvalidEntity02 { + + private String member1; + private String member2; + + public InvalidEntity02(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/scenario/alfa/scn01/InvalidEntity03.java new file mode 100644 index 0000000..9d4b4af --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn01/InvalidEntity03.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.scenario.alfa.scn01; + +import daxi.moe.app.MapFrom; + +public class InvalidEntity03 { + + private String member1; + private String member2; + + protected InvalidEntity03() { + //NOOP + } + + 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/MemInvalidEntityTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn01/MemInvalidEntityTests.java new file mode 100644 index 0000000..82a04ef --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn01/MemInvalidEntityTests.java @@ -0,0 +1,99 @@ +/* + * 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 new file mode 100644 index 0000000..caf7528 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn02/MemIncorrectSetterTests.java @@ -0,0 +1,107 @@ +/* + * 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/scn02/NopopEntity01.java b/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity01.java new file mode 100644 index 0000000..3f4cf60 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity01.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.scenario.alfa.scn02; + +import daxi.moe.app.MapFrom; + +public class NopopEntity01 { + + private String member1; + + public NopopEntity01() { + //NOOP + } + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void setMember1(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity02.java b/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity02.java new file mode 100644 index 0000000..055af62 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity02.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.scenario.alfa.scn02; + +import daxi.moe.app.MapFrom; + +public class NopopEntity02 { + + private String member1; + + public NopopEntity02() { + //NOOP + } + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void _set(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity03.java b/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity03.java new file mode 100644 index 0000000..6f004e7 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn02/NopopEntity03.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.scenario.alfa.scn02; + +import daxi.moe.app.MapFrom; + +public class NopopEntity03 { + + private String member1; + + public NopopEntity03() { + //NOOP + } + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void _setMember(String value, boolean flag) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn02/ValidEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn02/ValidEntity.java new file mode 100644 index 0000000..1873cb8 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn02/ValidEntity.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.scenario.alfa.scn02; + +import daxi.moe.app.MapFrom; + +public class ValidEntity { + + private String member1; + private String member2; + + public ValidEntity() { + //NOOP + } + + public String getMember1() { + return member1; + } + + public String getMember2() { + return member2; + } + + @MapFrom("member1") + private void _set1(String value) { + member1 = value; + } + + @MapFrom("member2") + private void _set2(String value) { + member2 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn03/BooleanEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn03/BooleanEntity.java new file mode 100644 index 0000000..c84c862 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn03/BooleanEntity.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.scenario.alfa.scn03; + +import daxi.moe.app.MapFrom; + +public class BooleanEntity { + + private boolean member1; + private Boolean member2; + + public BooleanEntity() { + //NOOP + } + + public boolean isMember1() { + return member1; + } + + public Boolean getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(boolean value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Boolean value) { + member2 = value; + } +} 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 new file mode 100644 index 0000000..b54739e --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn03/MemSimpleSetterTests.java @@ -0,0 +1,123 @@ +/* + * 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/scn03/StringEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn03/StringEntity.java new file mode 100644 index 0000000..5b8a776 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn03/StringEntity.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.scenario.alfa.scn03; + +import daxi.moe.app.MapFrom; + +public class StringEntity { + + private String member1; + + public StringEntity() { + //NOOP + } + + public String getMember1() { + return member1; + } + + @MapFrom("member1") + private void _setMe(String value) { + member1 = value; + } +} diff --git a/src/test/java/daxi/moe/test/scenario/alfa/scn04/ByteEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn04/ByteEntity.java new file mode 100644 index 0000000..3c4f4db --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn04/ByteEntity.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.scenario.alfa.scn04; + +import daxi.moe.app.MapFrom; + +public class ByteEntity { + + private byte member1; + private Byte member2; + + public ByteEntity() { + //NOOP + } + + public byte getMember1() { + return member1; + } + + public Byte getMember2() { + return member2; + } + + @MapFrom("member1") + private void _setMe1(byte value) { + member1 = value; + } + + @MapFrom("member2") + private void _setMe2(Byte value) { + member2 = value; + } +} 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 new file mode 100644 index 0000000..b8c375f --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn04/MemByteSetterTests.java @@ -0,0 +1,102 @@ +/* + * 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 new file mode 100644 index 0000000..83e1321 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn05/MemShortSetterTests.java @@ -0,0 +1,102 @@ +/* + * 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/scn05/ShortEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn05/ShortEntity.java new file mode 100644 index 0000000..ee487c2 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn05/ShortEntity.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.scenario.alfa.scn05; + +import daxi.moe.app.MapFrom; + +public class ShortEntity { + + private short member1; + private Short member2; + + public ShortEntity() { + //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/scenario/alfa/scn06/IntegerEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn06/IntegerEntity.java new file mode 100644 index 0000000..cd2b62c --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn06/IntegerEntity.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.scenario.alfa.scn06; + +import daxi.moe.app.MapFrom; + +public class IntegerEntity { + + private int member1; + private Integer member2; + + public IntegerEntity() { + //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/scenario/alfa/scn06/MemIntegerSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn06/MemIntegerSetterTests.java new file mode 100644 index 0000000..e8588e3 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn06/MemIntegerSetterTests.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.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/FloatEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn07/FloatEntity.java new file mode 100644 index 0000000..7c6772c --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn07/FloatEntity.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.scenario.alfa.scn07; + +import daxi.moe.app.MapFrom; + +public class FloatEntity { + + private float member1; + private Float member2; + + public FloatEntity() { + //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/scenario/alfa/scn07/MemFloatSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn07/MemFloatSetterTests.java new file mode 100644 index 0000000..be6f08a --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn07/MemFloatSetterTests.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.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/LongEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn08/LongEntity.java new file mode 100644 index 0000000..b699f16 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn08/LongEntity.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.scenario.alfa.scn08; + +import daxi.moe.app.MapFrom; + +public class LongEntity { + + private long member1; + private Long member2; + + public LongEntity() { + //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/scenario/alfa/scn08/MemLongSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn08/MemLongSetterTests.java new file mode 100644 index 0000000..5de8217 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn08/MemLongSetterTests.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.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/DoubleEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn09/DoubleEntity.java new file mode 100644 index 0000000..93667c9 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn09/DoubleEntity.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.scenario.alfa.scn09; + +import daxi.moe.app.MapFrom; + +public class DoubleEntity { + + private double member1; + private Double member2; + + public DoubleEntity() { + //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/scenario/alfa/scn09/MemDoubleSetterTests.java b/src/test/java/daxi/moe/test/scenario/alfa/scn09/MemDoubleSetterTests.java new file mode 100644 index 0000000..436cd25 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn09/MemDoubleSetterTests.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.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/BigIntegerEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn10/BigIntegerEntity.java new file mode 100644 index 0000000..78b22ae --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn10/BigIntegerEntity.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.alfa.scn10; + +import daxi.moe.app.MapFrom; + +import java.math.BigInteger; + +/** + * @author indroneel + */ + +public class BigIntegerEntity { + + private BigInteger member1; + + public BigIntegerEntity() { + //NOOP + } + + public BigInteger getMember1() { + return member1; + } + + @MapFrom("member1") + private void _setMe(BigInteger value) { + member1 = value; + } +} 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 new file mode 100644 index 0000000..2cc2d55 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn10/MemBigIntegerSetterTests.java @@ -0,0 +1,119 @@ +/* + * 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/BigDecimalEntity.java b/src/test/java/daxi/moe/test/scenario/alfa/scn11/BigDecimalEntity.java new file mode 100644 index 0000000..de95f2e --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn11/BigDecimalEntity.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.alfa.scn11; + +import daxi.moe.app.MapFrom; + +import java.math.BigDecimal; + +/** + * @author indroneel + */ + +public class BigDecimalEntity { + + private BigDecimal member1; + + public BigDecimalEntity() { + //NOOP + } + + public BigDecimal getMember1() { + return member1; + } + + @MapFrom("member1") + private void _setMe(BigDecimal value) { + member1 = value; + } +} 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 new file mode 100644 index 0000000..34432ff --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/alfa/scn11/MemBigDecimalSetterTests.java @@ -0,0 +1,119 @@ +/* + * 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/bravo/AllTests.java b/src/test/java/daxi/moe/test/scenario/bravo/AllTests.java new file mode 100644 index 0000000..5bb260f --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/bravo/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.scenario.bravo; + +import daxi.moe.test.setup.AbstractTests; +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 { + + 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/src/test/java/daxi/moe/test/scenario/charlie/AllTests.java b/src/test/java/daxi/moe/test/scenario/charlie/AllTests.java new file mode 100644 index 0000000..462d1f6 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/charlie/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.scenario.charlie; + +import daxi.moe.test.setup.AbstractTests; +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 Charlie") +public class AllTests extends AbstractTests { + + 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/src/test/java/daxi/moe/test/scenario/delta/AllTests.java b/src/test/java/daxi/moe/test/scenario/delta/AllTests.java new file mode 100644 index 0000000..975f389 --- /dev/null +++ b/src/test/java/daxi/moe/test/scenario/delta/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.scenario.delta; + +import daxi.moe.test.setup.AbstractTests; +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 Delta") +public class AllTests extends AbstractTests { + + 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/src/test/java/daxi/moe/test/setup/AbstractTests.java b/src/test/java/daxi/moe/test/setup/AbstractTests.java new file mode 100644 index 0000000..20c8429 --- /dev/null +++ b/src/test/java/daxi/moe/test/setup/AbstractTests.java @@ -0,0 +1,57 @@ +/* + * 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.setup; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestMethodOrder; + +import java.util.Locale; +import java.util.logging.Logger; + +/** + * Base class for all test suites. Provides common setup and utilities for tests. + * + * @author indroneel + */ + +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public abstract class AbstractTests { + + private static final Logger L = Logger.getLogger(AbstractTests.class.getName()); + + @BeforeEach + public void beforeEach(TestInfo info) { + String clsName = "UnknownClass"; + String mthdName = "unknownMethod"; + if(info.getTestClass().isPresent()) { + clsName = info.getTestClass().get().getSimpleName(); + } + if(info.getTestMethod().isPresent()) { + mthdName = info.getTestMethod().get().getName(); + } + + L.info("%s.%s(): %s".formatted( + clsName, mthdName, info.getDisplayName().toUpperCase(Locale.getDefault()))); + } + + protected final void logMultiLines(Logger logger, String logout) { + String[] lines = logout.split("\n"); + for(String line : lines) { + logger.info(line); + } + } +} diff --git a/src/test/java/daxi/moe/test/setup/LauncherSessionHandler.java b/src/test/java/daxi/moe/test/setup/LauncherSessionHandler.java new file mode 100644 index 0000000..05618cd --- /dev/null +++ b/src/test/java/daxi/moe/test/setup/LauncherSessionHandler.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.setup; + +import org.junit.platform.launcher.LauncherSession; +import org.junit.platform.launcher.LauncherSessionListener; +import org.slf4j.bridge.SLF4JBridgeHandler; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +public class LauncherSessionHandler implements LauncherSessionListener { + + private static final Logger L = Logger.getLogger(LauncherSessionHandler.class.getName()); + + @Override + public void launcherSessionOpened(LauncherSession session) { + SLF4JBridgeHandler.removeHandlersForRootLogger(); + SLF4JBridgeHandler.install(); + + L.info("launcher session opened"); + } + + @Override + public void launcherSessionClosed(LauncherSession session) { + L.info("launcher session closed"); + } +} diff --git a/src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener b/src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener new file mode 100644 index 0000000..eb51cf9 --- /dev/null +++ b/src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener @@ -0,0 +1,15 @@ +# +# 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. +# + +daxi.moe.test.setup.LauncherSessionHandler \ No newline at end of file diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml new file mode 100644 index 0000000..2ef1761 --- /dev/null +++ b/src/test/resources/logback.xml @@ -0,0 +1,63 @@ + + + + + + + + + true + + + + + + + + %logger{0}.%method [%4line]: %msg%n + + + + + + + + [%4line]: %msg%n + + + + + + + + %n%msg%n + + + + + + + + + + + + + + + + + + \ No newline at end of file