the first commit

This commit is contained in:
2026-10-05 20:54:46 +05:30
parent a3c0a8caef
commit 9a3d916656
39 changed files with 2400 additions and 0 deletions
+9
View File
@@ -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
+62
View File
@@ -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
+90
View File
@@ -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, [email protected]
*
* 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)
))
}
}
+15
View File
@@ -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, [email protected]
*
* 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"
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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);
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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;
}
}
@@ -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, [email protected]
*
* 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());
}
}
@@ -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, [email protected]
*
* 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() {
}
}
@@ -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, [email protected]
*
* 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() {
}
}
@@ -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, [email protected]
*
* 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() {
}
}
@@ -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, [email protected]
*
* 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);
}
}
}
@@ -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, [email protected]
*
* 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");
}
}
@@ -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, [email protected]
#
# 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
+63
View File
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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, [email protected]
~
~ 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.
-->
<!DOCTYPE configuration>
<configuration debug="false">
<import class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<contextListener class="LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%logger{0}.%method [%4line]: %msg%n
</pattern>
</encoder>
</appender>
<appender name="STDOUT_TEST" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
[%4line]: %msg%n
</pattern>
</encoder>
</appender>
<appender name="STDOUT_MIN" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%n%msg%n
</pattern>
</encoder>
</appender>
<root level="WARN">
<appender-ref ref="STDOUT"/>
</root>
<logger name="daxi.moe.test.setup" level="TRACE" additivity="false">
<appender-ref ref="STDOUT_MIN"/>
</logger>
<logger name="daxi.moe.test" level="TRACE" additivity="false">
<appender-ref ref="STDOUT_TEST"/>
</logger>
<logger name="daxi.moe" level="TRACE" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
</configuration>