[DEV] add object not empty constructor
This commit is contained in:
parent
e5db63a06b
commit
99b846be25
@ -0,0 +1,49 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
package test.atriasoft.exml;
|
||||||
|
|
||||||
|
import org.atriasoft.exml.Exml;
|
||||||
|
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class ExmlTestIntrospectionObjectConstructor {
|
||||||
|
static final String NODE_NAME = "elem";
|
||||||
|
@BeforeAll
|
||||||
|
public static void beforeClass() {
|
||||||
|
Log.warning("================================================================");
|
||||||
|
}
|
||||||
|
public class TestMultiConstructor {
|
||||||
|
@XmlAttribute
|
||||||
|
public Integer valueA;
|
||||||
|
public double valueB;
|
||||||
|
public TestMultiConstructor(final Integer valueA, final double valueB) {
|
||||||
|
this.valueA = valueA;
|
||||||
|
this.valueB = valueB;
|
||||||
|
}
|
||||||
|
public TestMultiConstructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testModelMultiConstructor() {
|
||||||
|
TestMultiConstructor elem = new TestMultiConstructor(66, 18523.0);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + builder.toString());
|
||||||
|
Assertions.assertEquals("<elem valueA=\"66\">\n"
|
||||||
|
+ " <valueB>18523.0</valueB>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestMultiConstructor root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestMultiConstructor.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(66, root.valueA);
|
||||||
|
Assertions.assertEquals(18523.0f, root.valueB);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user