[DEV] add enums, correct test bugs and better model ==> need to clean deprecated code ...

This commit is contained in:
Edouard DUPIN 2021-07-07 00:24:06 +02:00
parent a7bdce291d
commit bc83c265b8
27 changed files with 1199 additions and 601 deletions

View File

@ -4,5 +4,24 @@ Atria-soft Exml
[MPL-2] Mozilla public licence (V 2.0) [MPL-2] Mozilla public licence (V 2.0)
Ewol xml tool. Implementation a a XML parser and generator. I create this one, because jackson API is done for JSON and not XML.
The main base of the parser is a simple SAX parser (not streamable right now...)
A DOM parser is available (based on SAX)
A POJO parse is in progress (based on SAX too)
POJO need to implement (TODO list):
- Enumeration reader / writer
- Immutable reader/writer
- Record reader/writer
The model of the Pojo reader is based on reading all sub element and create the object at the end (leaf first and parent node after). This is needed to manage the record and the immutable.
We do not manage the constructor properties. Then right now, the constructor MUST be empty
need to check if the class is an abstract or not...

View File

@ -11,7 +11,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(byte.class, new Converter() { StringSerializer.VALUES_OF.put(byte.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Byte.valueOf(value); return Byte.valueOf(value.trim());
} }
@Override @Override
@ -27,7 +27,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(Byte.class, new Converter() { StringSerializer.VALUES_OF.put(Byte.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Byte.valueOf(value); return Byte.valueOf(value.trim());
} }
@Override @Override
@ -43,7 +43,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(int.class, new Converter() { StringSerializer.VALUES_OF.put(int.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Integer.valueOf(value); return Integer.valueOf(value.trim());
} }
@Override @Override
@ -59,7 +59,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(Integer.class, new Converter() { StringSerializer.VALUES_OF.put(Integer.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Integer.valueOf(value); return Integer.valueOf(value.trim());
} }
@Override @Override
@ -75,7 +75,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(long.class, new Converter() { StringSerializer.VALUES_OF.put(long.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Long.valueOf(value); return Long.valueOf(value.trim());
} }
@Override @Override
@ -91,7 +91,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(Long.class, new Converter() { StringSerializer.VALUES_OF.put(Long.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Long.valueOf(value); return Long.valueOf(value.trim());
} }
@Override @Override
@ -107,7 +107,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(short.class, new Converter() { StringSerializer.VALUES_OF.put(short.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Short.valueOf(value); return Short.valueOf(value.trim());
} }
@Override @Override
@ -123,7 +123,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(Short.class, new Converter() { StringSerializer.VALUES_OF.put(Short.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Short.valueOf(value); return Short.valueOf(value.trim());
} }
@Override @Override
@ -139,7 +139,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(float.class, new Converter() { StringSerializer.VALUES_OF.put(float.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Float.valueOf(value); return Float.valueOf(value.trim());
} }
@Override @Override
@ -155,7 +155,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(Float.class, new Converter() { StringSerializer.VALUES_OF.put(Float.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Float.valueOf(value); return Float.valueOf(value.trim());
} }
@Override @Override
@ -171,7 +171,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(double.class, new Converter() { StringSerializer.VALUES_OF.put(double.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Double.valueOf(value); return Double.valueOf(value.trim());
} }
@Override @Override
@ -187,7 +187,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(Double.class, new Converter() { StringSerializer.VALUES_OF.put(Double.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Double.valueOf(value); return Double.valueOf(value.trim());
} }
@Override @Override
@ -203,7 +203,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(boolean.class, new Converter() { StringSerializer.VALUES_OF.put(boolean.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Boolean.valueOf(value); return Boolean.valueOf(value.trim());
} }
@Override @Override
@ -219,7 +219,7 @@ public class StringSerializer {
StringSerializer.VALUES_OF.put(Boolean.class, new Converter() { StringSerializer.VALUES_OF.put(Boolean.class, new Converter() {
@Override @Override
public Object valueOf(final String value) { public Object valueOf(final String value) {
return Boolean.valueOf(value); return Boolean.valueOf(value.trim());
} }
@Override @Override

View File

@ -7,12 +7,10 @@
package org.atriasoft.exml; package org.atriasoft.exml;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Array;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.exml.builder.Builder; import org.atriasoft.exml.builder.Builder;

View File

@ -1,15 +1,15 @@
package org.atriasoft.exml.builder; package org.atriasoft.exml.builder;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.atriasoft.eStringSerialize.StringSerializer;
import org.atriasoft.exml.exception.ExmlBuilderException; import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.exml.internal.Log; import org.atriasoft.exml.internal.Log;
public class BuilderIntrospection implements Builder { public class BuilderIntrospection implements Builder {
// Keep in cach all the object alredy parsed ==> optimize CPU // Keep in cach all the object alredy parsed ==> optimize CPU
final Map<MapKey, IntrospectionModel> elements = new HashMap<>(); CacheIntrospectionModel cacheModel = new CacheIntrospectionModel();
// The root class (need to keep it if we use 2 time the builder, the root class is no more accessible). // The root class (need to keep it if we use 2 time the builder, the root class is no more accessible).
final Class<?> rootClassType; final Class<?> rootClassType;
final String rootNodeName; final String rootNodeName;
@ -17,27 +17,9 @@ public class BuilderIntrospection implements Builder {
public BuilderIntrospection(final ModelType model, final Class<?> classType, final String rootNodeName) throws Exception { public BuilderIntrospection(final ModelType model, final Class<?> classType, final String rootNodeName) throws Exception {
this.rootNodeName = rootNodeName; this.rootNodeName = rootNodeName;
this.rootClassType = classType; this.rootClassType = classType;
MapKey key = new MapKey(model, classType); this.cacheModel.findOrCreate(model, null, classType);
// TODO pb if it is a List or an Array ...
this.elements.put(key, IntrospectionModelFactory.createModelPlop(key));
} }
IntrospectionModel findOrCreate(final ModelType model, final String name, final Class<?> classType) throws ExmlBuilderException {
MapKey key = new MapKey(model, name, classType);
IntrospectionModel out = this.elements.get(key);
if (out != null) {
return out;
}
if (model == ModelType.ARRAY) {
out = IntrospectionModelFactory.createModelArray(key.nodeName(), key);
} else if (model == ModelType.LIST) {
out = IntrospectionModelFactory.createModelList(key.nodeName(), key);
} else {
out = IntrospectionModelFactory.createModelPlop(key);
}
this.elements.put(key, out);
return out;
}
@Override @Override
public void newComment(final Object element, final String comment) throws ExmlBuilderException { public void newComment(final Object element, final String comment) throws ExmlBuilderException {
@ -77,9 +59,9 @@ public class BuilderIntrospection implements Builder {
Log.verbose("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); Log.verbose("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
IntrospectionModel inferData = null; IntrospectionModel inferData = null;
if (listTreeName == null) { if (listTreeName == null) {
inferData = findOrCreate(ModelType.NORMAL, null, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass);
} else { } else {
inferData = findOrCreate(ModelType.ARRAY, listTreeName, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.ARRAY, listTreeName, subTypeClass);
} }
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
@ -89,15 +71,15 @@ public class BuilderIntrospection implements Builder {
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
IntrospectionModel inferData = null; IntrospectionModel inferData = null;
if (listTreeName == null) { if (listTreeName == null) {
inferData = findOrCreate(ModelType.NORMAL, null, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass);
} else { } else {
inferData = findOrCreate(ModelType.LIST, listTreeName, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass);
} }
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
} }
Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
final IntrospectionModel inferData = findOrCreate(ModelType.NORMAL, listTreeName, typeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, listTreeName, typeClass);
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
@ -112,14 +94,44 @@ public class BuilderIntrospection implements Builder {
if (model.isArray() || model.isList()) { if (model.isArray() || model.isList()) {
throw new ExmlBuilderException("Model (List/Array) can not have property with name '" + propertyName + "'"); throw new ExmlBuilderException("Model (List/Array) can not have property with name '" + propertyName + "'");
} }
// TODO Check here, maybe a big problem with the custum object in properties ... !!!!! Class<?> typeClass = model.getTypeOfProperty(propertyName);
introspectionObject.setProperty(propertyName, propertyValue); if (typeClass != null) {
// specific case for List ==> need to get the subType in introspection ...
if (typeClass.isPrimitive()) {
Object out = StringSerializer.valueOf(typeClass, propertyValue);
introspectionObject.putProperty(propertyName, out);
} else if (typeClass.isArray()) {
String[] elems = propertyValue.split(";");
Class<?> subTypeClass = typeClass.getComponentType();
IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass);
List<Object> out = new ArrayList<Object>();
for (int iii=0; iii<elems.length; iii++) {
Object tmp = inferData.getValueFromText(elems[iii]);
out.add(tmp);
}
introspectionObject.putProperty(propertyName, out);
} else if (List.class.isAssignableFrom(typeClass)) {
String[] elems = propertyValue.split(";");
Class<?> subTypeClass = introspectionObject.getTypeOfSubProperty(propertyName);
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for property '" + propertyName + "'");
IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass);
List<Object> out = new ArrayList<Object>();
for (int iii=0; iii<elems.length; iii++) {
Object tmp = inferData.getValueFromText(elems[iii]);
out.add(tmp);
}
introspectionObject.putProperty(propertyName, out);
} else {
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, typeClass);
Object out = inferData.getValueFromText(propertyValue);
introspectionObject.putProperty(propertyName, out);
}
}
} }
@Override @Override
public Object newRoot() throws ExmlBuilderException { public Object newRoot() throws ExmlBuilderException {
final IntrospectionModel inferData = findOrCreate(ModelType.ARRAY, this.rootNodeName, this.rootClassType); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.ARRAY, this.rootNodeName, this.rootClassType);
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
} }
@ -133,7 +145,7 @@ public class BuilderIntrospection implements Builder {
throw new ExmlBuilderException("Model can not have direct text with model data= '" + text + "'"); throw new ExmlBuilderException("Model can not have direct text with model data= '" + text + "'");
} }
Class<?> arrayType = model.getClassType(); Class<?> arrayType = model.getClassType();
final IntrospectionModel inferData = findOrCreate(ModelType.NORMAL, null, arrayType); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, arrayType);
// Create the data when object is ended created... // Create the data when object is ended created...
IntrospectionObject tmpp = new IntrospectionObject(inferData); IntrospectionObject tmpp = new IntrospectionObject(inferData);
newText(tmpp, text); newText(tmpp, text);

View File

@ -0,0 +1,34 @@
package org.atriasoft.exml.builder;
import java.util.HashMap;
import java.util.Map;
import org.atriasoft.exml.exception.ExmlBuilderException;
public class CacheIntrospectionModel {
final Map<MapKey, IntrospectionModel> elements = new HashMap<>();
IntrospectionModel findOrCreate(final ModelType model, final String name, final Class<?> classType) throws ExmlBuilderException {
MapKey key = new MapKey(model, name, classType);
IntrospectionModel out = this.elements.get(key);
if (out != null) {
return out;
}
if (model == ModelType.ARRAY) {
out = IntrospectionModelFactory.createModelArray(key.nodeName(), key);
} else if (model == ModelType.LIST) {
out = IntrospectionModelFactory.createModelList(key.nodeName(), key);
} else if (classType.isEnum()) {
out = IntrospectionModelFactory.createModelEnum(key);
} else {
out = IntrospectionModelFactory.createModelPlop(key);
}
this.elements.put(key, out);
return out;
}
public CacheIntrospectionModel() {
}
}

View File

@ -44,16 +44,28 @@ public abstract class IntrospectionModel {
return null; return null;
} }
public Class<?> getTypeOfSubNode(final Object data, final String nodeName) throws ExmlBuilderException { public Class<?> getTypeOfSubNode(final String nodeName) throws ExmlBuilderException {
return null; return null;
} }
public Class<?> getTypeOfSubNodeList(final Object data, final String nodeName) throws ExmlBuilderException { public Class<?> getTypeOfSubNodeList(final String nodeName) throws ExmlBuilderException {
return null; return null;
} }
public String getTreeNameOfSubNode(final Object data, final String nodeName) throws ExmlBuilderException { public String getTreeNameOfSubNode(final String nodeName) throws ExmlBuilderException {
return null; return null;
} }
public boolean isEndPoint() { public Class<?> getTypeOfProperty(final String nodeName) throws ExmlBuilderException {
return null;
}
public Class<?> getTypeOfSubProperty(final String nodeName) throws ExmlBuilderException {
return null;
}
public boolean isObject(final String propertyName) {
return Object.class.isAssignableFrom(this.classType);
}
public boolean isRecord(final String propertyName) {
return Record.class.isAssignableFrom(this.classType);
}
public boolean isNative() {
return false; return false;
} }
public boolean isArray() { public boolean isArray() {
@ -62,7 +74,10 @@ public abstract class IntrospectionModel {
public boolean isList() { public boolean isList() {
return false; return false;
} }
public abstract String toString(final Object data); public abstract String toString(final Object data) throws ExmlBuilderException;
public abstract String[] toStringList(final Object data); public abstract String[] toStringList(final Object data);
public boolean isEnum() {
return this.classType.isEnum();
}
} }

View File

@ -5,10 +5,8 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.atriasoft.etk.util.ArraysTools;
import org.atriasoft.exml.exception.ExmlBuilderException; import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
import org.atriasoft.exml.parser.ParseXml;
import org.atriasoft.exml.parser.ParsingProperty;
public class IntrospectionModelArray extends IntrospectionModel { public class IntrospectionModelArray extends IntrospectionModel {
@ -28,21 +26,34 @@ public class IntrospectionModelArray extends IntrospectionModel {
@Override @Override
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException { public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
List<Object> tmp = null; List<Object> tmp = null;
if (nodeName == null) { if (this.nodeName == null) {
tmp = nodes.get(IntrospectionObject.STUPID_TOCKEN); tmp = nodes.get(IntrospectionObject.STUPID_TOCKEN);
} else {
tmp = nodes.get(nodeName);
}
if (tmp == null) { if (tmp == null) {
return null; return null;
} }
return convertList(this.classType, tmp); if (tmp.size() == 1) {
return tmp.get(0);
}
return null;
}
tmp = nodes.get(this.nodeName);
if (tmp == null) {
return null;
}
//return tmp;
// TODO This is not good at all this is bad ...
if (this.classType.isPrimitive()) {
return ArraysTools.listToPrimitiveAuto(this.classType, tmp);
}
return IntrospectionModelArray.convertList(this.classType, tmp);
} }
@Override @Override
public List<String> getNodeAvaillable() { public List<String> getNodeAvaillable() {
if (nodeName != null) { if (this.nodeName != null) {
return Arrays.asList(nodeName); return Arrays.asList(this.nodeName);
} }
return null; return null;
} }

View File

@ -35,7 +35,7 @@ public class IntrospectionModelBaseType extends IntrospectionModel {
} }
@Override @Override
public boolean isEndPoint() { public boolean isNative() {
return true; return true;
} }

View File

@ -35,6 +35,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
// TODO Optimize this with external object for basic types.... // TODO Optimize this with external object for basic types....
private final Method valueof; // used for the set Text if the object is an end point... private final Method valueof; // used for the set Text if the object is an end point...
private final Method tostring; // used for the set Text if the object is an end point...
private final List<IntrospectionProperty> nodes = new ArrayList<>(); private final List<IntrospectionProperty> nodes = new ArrayList<>();
private final List<IntrospectionProperty> attributes = new ArrayList<>(); private final List<IntrospectionProperty> attributes = new ArrayList<>();
@ -105,6 +106,12 @@ public class IntrospectionModelComplex extends IntrospectionModel {
} }
return false; return false;
} }
if (o.getName().equals("toString")) {
if (o.getParameterCount() != 0 || o.getReturnType() != String.class) {
return false;
}
return true;
}
if (o.getName().startsWith("get")) { if (o.getName().startsWith("get")) {
if (o.getParameterCount() != 0 || o.getReturnType() == void.class || o.getReturnType() == Boolean.class || o.getReturnType() == boolean.class) { if (o.getParameterCount() != 0 || o.getReturnType() == void.class || o.getReturnType() == Boolean.class || o.getReturnType() == boolean.class) {
return false; return false;
@ -133,7 +140,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
return false; return false;
} }
if (o.getName().startsWith("is")) { if (o.getName().startsWith("is")) {
if (!(o.getReturnType() == Boolean.class || o.getReturnType() == boolean.class) && o.getParameterCount() != 0) { if ((o.getReturnType() != Boolean.class && o.getReturnType() != boolean.class) || o.getParameterCount() != 0) {
return false; return false;
} }
// check name format // check name format
@ -179,6 +186,14 @@ public class IntrospectionModelComplex extends IntrospectionModel {
this.valueof = null; this.valueof = null;
} }
final List<Method> tostringMethod = methods.stream().filter(o -> o.getName().startsWith("toString")).collect(Collectors.toList());
if (tostringMethod.size() == 1) {
this.tostring = tostringMethod.get(0);
} else {
// some specific model:
this.tostring = null;
}
// associate methods by pair. // associate methods by pair.
final List<OrderData> elements = new ArrayList<>(); final List<OrderData> elements = new ArrayList<>();
for (final Method method : methodsGet) { for (final Method method : methodsGet) {
@ -335,7 +350,11 @@ public class IntrospectionModelComplex extends IntrospectionModel {
try { try {
// pb here, can not create a primitive object with the correct elements... ==> must be generated with a siblist of elements // pb here, can not create a primitive object with the correct elements... ==> must be generated with a siblist of elements
Constructor<?>[] constructors = this.classType.getConstructors(); Constructor<?>[] constructors = this.classType.getConstructors();
if (!Modifier.isStatic(this.classType.getModifiers())) { //Log.critical("Modifiers : " + Modifier.toString(this.classType.getModifiers()) + " ==> " + this.classType.getNestHost());
if (this.classType.getNestHost() == this.classType) {
// if nest class is identical ==> native class declaration.
tmp = constructors[0].newInstance();
} else if (!Modifier.isStatic(this.classType.getModifiers())) {
Object tmp2 = null; Object tmp2 = null;
tmp = constructors[0].newInstance(tmp2); tmp = constructors[0].newInstance(tmp2);
} else { } else {
@ -616,6 +635,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
private void setValue(final Object data, final String name, final Object value) throws ExmlBuilderException { private void setValue(final Object data, final String name, final Object value) throws ExmlBuilderException {
Log.error(" Set value ='" + name + "' propertyValue='" + value + "' " + value.getClass().getCanonicalName()); Log.error(" Set value ='" + name + "' propertyValue='" + value + "' " + value.getClass().getCanonicalName());
{
// by default use setter to set the property // by default use setter to set the property
final IntrospectionProperty propMethode = findNodeDescription(name); final IntrospectionProperty propMethode = findNodeDescription(name);
if (propMethode != null && propMethode.canSetValue()) { if (propMethode != null && propMethode.canSetValue()) {
@ -626,27 +646,9 @@ public class IntrospectionModelComplex extends IntrospectionModel {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Object> tmpp = (List<Object>)value; List<Object> tmpp = (List<Object>)value;
if (propMethode.getType().isArray()) { if (propMethode.getType().isArray()) {
if (propMethode.getType().componentType() == byte.class) { if (propMethode.getType().componentType().isPrimitive()) {
byte[] datas = ArraysTools.listByteToPrimitive(tmpp); Object newData = ArraysTools.listToPrimitiveAuto(propMethode.getType().componentType(), tmpp);
propMethode.setExistingValue(data, datas); propMethode.setExistingValue(data, newData);
} else if (propMethode.getType().componentType() == short.class) {
short[] datas = ArraysTools.listShortToPrimitive(tmpp);
propMethode.setExistingValue(data, datas);
} else if (propMethode.getType().componentType() == int.class) {
int[] datas = ArraysTools.listIntegerToPrimitive(tmpp);
propMethode.setExistingValue(data, datas);
} else if (propMethode.getType().componentType() == long.class) {
long[] datas = ArraysTools.listLongToPrimitive(tmpp);
propMethode.setExistingValue(data, datas);
} else if (propMethode.getType().componentType() == boolean.class) {
boolean[] datas = ArraysTools.listBooleanToPrimitive(tmpp);
propMethode.setExistingValue(data, datas);
} else if (propMethode.getType().componentType() == float.class) {
float[] datas = ArraysTools.listFloatToPrimitive(tmpp);
propMethode.setExistingValue(data, datas);
} else if (propMethode.getType().componentType() == double.class) {
double[] datas = ArraysTools.listDoubleToPrimitive(tmpp);
propMethode.setExistingValue(data, datas);
} else { } else {
Log.verbose(" datas type: " + autoCast(propMethode.getType().componentType(), tmpp).getClass().getCanonicalName()); Log.verbose(" datas type: " + autoCast(propMethode.getType().componentType(), tmpp).getClass().getCanonicalName());
Log.verbose(" methode type: " + propMethode.getType().getCanonicalName()); Log.verbose(" methode type: " + propMethode.getType().getCanonicalName());
@ -672,12 +674,20 @@ public class IntrospectionModelComplex extends IntrospectionModel {
} else if (propMethode.getType() == boolean.class) { } else if (propMethode.getType() == boolean.class) {
boolean dataPrimitive = (Boolean)value; boolean dataPrimitive = (Boolean)value;
propMethode.setExistingValue(data, dataPrimitive); propMethode.setExistingValue(data, dataPrimitive);
} else if (propMethode.getType() == float.class) {
float dataPrimitive = (Float)value;
propMethode.setExistingValue(data, dataPrimitive);
} else if (propMethode.getType() == double.class) {
double dataPrimitive = (Double)value;
propMethode.setExistingValue(data, dataPrimitive);
} else { } else {
} }
return; return;
} }
}
// try with direct field // try with direct field
{
final IntrospectionProperty propField = findPropertyDescription(name); final IntrospectionProperty propField = findPropertyDescription(name);
if (propField != null && propField.canSetValue()) { if (propField != null && propField.canSetValue()) {
Log.verbose(" ==> find '" + Arrays.toString(propField.getNames()) + " type=" + propField.getType() + " sub-type=" + propField.getSubType() ); Log.verbose(" ==> find '" + Arrays.toString(propField.getNames()) + " type=" + propField.getType() + " sub-type=" + propField.getSubType() );
@ -724,10 +734,16 @@ public class IntrospectionModelComplex extends IntrospectionModel {
} else if (propField.getType().componentType() == boolean.class) { } else if (propField.getType().componentType() == boolean.class) {
boolean[] datas = ArraysTools.listBooleanToPrimitive(tmpp); boolean[] datas = ArraysTools.listBooleanToPrimitive(tmpp);
propField.setExistingValue(data, datas); propField.setExistingValue(data, datas);
} else if (propField.getType().componentType() == float.class) {
float[] datas = ArraysTools.listFloatToPrimitive(tmpp);
propField.setExistingValue(data, datas);
} else if (propField.getType().componentType() == double.class) {
double[] datas = ArraysTools.listDoubleToPrimitive(tmpp);
propField.setExistingValue(data, datas);
} else { } else {
Log.verbose(" datas type: " + autoCast(propMethode.getType().componentType(), tmpp).getClass().getCanonicalName()); Log.verbose(" datas type: " + autoCast(propField.getType().componentType(), tmpp).getClass().getCanonicalName());
Log.verbose(" methode type: " + propMethode.getType().getCanonicalName()); Log.verbose(" methode type: " + propField.getType().getCanonicalName());
propField.setExistingValue(data, autoCast(propMethode.getType().componentType(), tmpp)); propField.setExistingValue(data, autoCast(propField.getType().componentType(), tmpp));
} }
} else if (tmpp.size() == 1) { } else if (tmpp.size() == 1) {
propField.setExistingValue(data, tmpp.get(0)); propField.setExistingValue(data, tmpp.get(0));
@ -737,8 +753,8 @@ public class IntrospectionModelComplex extends IntrospectionModel {
} }
return; return;
} }
}
throw new ExmlBuilderException("can not find the field '" + name + "'"); throw new ExmlBuilderException("can not find the field '" + name + "'");
} }
/** /**
@ -747,57 +763,58 @@ public class IntrospectionModelComplex extends IntrospectionModel {
* @return Class of the node to create * @return Class of the node to create
*/ */
@Override @Override
public Class<?> getTypeOfSubNode(final Object data, final String nodeName) throws ExmlBuilderException { public Class<?> getTypeOfSubNode(final String nodeName) throws ExmlBuilderException {
Log.error(" nodeType='" + nodeName + "'"); Log.error(" nodeType='" + nodeName + "'");
// by default use setter to set the property
final IntrospectionProperty propMethode = findNodeDescription(nodeName); final IntrospectionProperty propMethode = findNodeDescription(nodeName);
if (propMethode != null && propMethode.canSetValue()) { if (propMethode != null && propMethode.canSetValue()) {
Log.error(" ==> find '" + propMethode.getNames()); Log.error(" ==> find '" + propMethode.getNames());
return propMethode.getType(); return propMethode.getType();
} }
// try with direct field throw new ExmlBuilderException("can not find the field '" + nodeName + "' availlable: " + getNodeAvaillable());
}
@Override
public Class<?> getTypeOfSubNodeList(final String nodeName) throws ExmlBuilderException {
Log.error(" nodeType='" + nodeName + "'");
final IntrospectionProperty propMethode = findNodeDescription(nodeName);
if (propMethode != null && propMethode.canSetValue()) {
Log.error(" ==> find '" + propMethode.getNames());
return propMethode.getSubType();
}
throw new ExmlBuilderException("can not find the field '" + nodeName + "' availlable: " + getNodeAvaillable());
}
@Override
public String getTreeNameOfSubNode(final String nodeName) throws ExmlBuilderException {
Log.error(" nodeType='" + nodeName + "'");
final IntrospectionProperty propMethode = findNodeDescription(nodeName);
if (propMethode != null && propMethode.canSetValue()) {
Log.error(" ==> find '" + propMethode.getNames());
return propMethode.getListName();
}
throw new ExmlBuilderException("can not find the field '" + nodeName + "'");
}
@Override
public Class<?> getTypeOfProperty(final String nodeName) throws ExmlBuilderException {
Log.error(" nodeType='" + nodeName + "'");
final IntrospectionProperty propField = findPropertyDescription(nodeName); final IntrospectionProperty propField = findPropertyDescription(nodeName);
if (propField != null && propField.canSetValue()) { if (propField != null && propField.canSetValue()) {
Log.error(" ==> find '" + propField.getNames()); Log.error(" ==> find '" + propField.getNames());
return propMethode.getType(); return propField.getType();
} }
throw new ExmlBuilderException("can not find the field '" + nodeName + "' availlable: " + getNodeAvaillable()); throw new ExmlBuilderException("can not find the field '" + nodeName + "' availlable: " + getNodeAvaillable());
} }
@Override @Override
public Class<?> getTypeOfSubNodeList(final Object data, final String nodeName) throws ExmlBuilderException { public Class<?> getTypeOfSubProperty(final String nodeName) throws ExmlBuilderException {
Log.error(" nodeType='" + nodeName + "'"); Log.error(" nodeType='" + nodeName + "'");
// by default use setter to set the property
final IntrospectionProperty propMethode = findNodeDescription(nodeName);
if (propMethode != null && propMethode.canSetValue()) {
Log.error(" ==> find '" + propMethode.getNames());
return propMethode.getSubType();
}
// try with direct field
final IntrospectionProperty propField = findPropertyDescription(nodeName); final IntrospectionProperty propField = findPropertyDescription(nodeName);
if (propField != null && propField.canSetValue()) { if (propField != null && propField.canSetValue()) {
Log.error(" ==> find '" + propField.getNames()); Log.error(" ==> find '" + propField.getNames());
return propMethode.getSubType(); return propField.getSubType();
} }
throw new ExmlBuilderException("can not find the field '" + nodeName + "' availlable: " + getNodeAvaillable()); throw new ExmlBuilderException("can not find the field '" + nodeName + "' availlable: " + getNodeAvaillable());
} }
@Override
public String getTreeNameOfSubNode(final Object data, final String nodeName) throws ExmlBuilderException {
Log.error(" nodeType='" + nodeName + "'");
// by default use setter to set the property
final IntrospectionProperty propMethode = findNodeDescription(nodeName);
if (propMethode != null && propMethode.canSetValue()) {
Log.error(" ==> find '" + propMethode.getNames());
return propMethode.getListName();
}
// try with direct field
final IntrospectionProperty propField = findPropertyDescription(nodeName);
if (propField != null && propField.canSetValue()) {
Log.error(" ==> find '" + propField.getNames());
return propMethode.getListName();
}
throw new ExmlBuilderException("can not find the field '" + nodeName + "'");
}
@Override @Override
@ -868,12 +885,26 @@ public class IntrospectionModelComplex extends IntrospectionModel {
throw new ExmlBuilderException("can not find the field '" + propertyName + "'"); throw new ExmlBuilderException("can not find the field '" + propertyName + "'");
} }
@Override @Override
public boolean isEndPoint() { public boolean isNative() {
return false; return false;
} }
@Override @Override
public String toString(final Object data) { public String toString(final Object data) throws ExmlBuilderException {
return null; if (this.tostring == null) {
if (StringSerializer.contains(this.classType)) {
throw new ExmlBuilderException("function 'toString' for '" + this.classType.getCanonicalName() + "' is not defined and not registered for specific type");
}
return StringSerializer.toString(data);
}
try {
return (String) this.tostring.invoke(data);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
if (Enum.class.isAssignableFrom(this.classType)) {
throw new ExmlBuilderException("Error in call 'toString()' for '" + this.classType.getCanonicalName() + "' ==> '????' ... availlable list: " + Arrays.asList(this.classType.getEnumConstants()));
}
e.printStackTrace();
throw new ExmlBuilderException("Error in call 'toString()' for '" + this.classType.getCanonicalName() + "' " + e.getMessage());
}
} }
@Override @Override
public String[] toStringList(final Object data) { public String[] toStringList(final Object data) {

View File

@ -29,6 +29,9 @@ public class IntrospectionModelFactory {
public static IntrospectionModel createModelList(final String nodeName, final MapKey modelType) throws ExmlBuilderException { public static IntrospectionModel createModelList(final String nodeName, final MapKey modelType) throws ExmlBuilderException {
return new IntrospectionModelList(nodeName, modelType.type()); return new IntrospectionModelList(nodeName, modelType.type());
} }
public static IntrospectionModel createModelEnum(final MapKey modelType) throws ExmlBuilderException {
return new IntrospectionModelComplex(modelType.type());
}
public static IntrospectionModel createModelPlop(final MapKey modelType) throws ExmlBuilderException { public static IntrospectionModel createModelPlop(final MapKey modelType) throws ExmlBuilderException {
if (StringSerializer.contains(modelType.type())) { if (StringSerializer.contains(modelType.type())) {

View File

@ -35,13 +35,16 @@ public class IntrospectionObject {
return this.modelInterface; return this.modelInterface;
} }
public void setProperty(final String propertyName, final String propertyValue) throws Exception { public void putProperty(final String propertyName, final Object propertyValue) throws Exception {
// Old way ... this.dataInterface.setProperty(this.data, propertyName, propertyValue);
Object value = this.modelInterface.getValue(propertyName, propertyValue);
if (this.properties.containsKey(propertyName)) { if (this.properties.containsKey(propertyName)) {
throw new ExmlBuilderException("Property have multiple values ==> impossible case; A Node must contain only 1 attibutes"); throw new ExmlBuilderException("Property have multiple values ==> impossible case; A Node must contain only 1 attibutes");
} }
this.properties.put(propertyName, value); this.properties.put(propertyName, propertyValue);
}
@Deprecated
public void setProperty(final String propertyName, final String propertyValue, final CacheIntrospectionModel cacheModel) throws Exception {
Object value = this.modelInterface.getValue(propertyName, propertyValue);
putProperty(propertyName, value);
} }
/** /**
@ -50,13 +53,19 @@ public class IntrospectionObject {
* @return Class of the node to create * @return Class of the node to create
*/ */
public Class<?> getTypeOfSubNode(final String nodeName) throws ExmlBuilderException { public Class<?> getTypeOfSubNode(final String nodeName) throws ExmlBuilderException {
return this.modelInterface.getTypeOfSubNode(this.data, nodeName); return this.modelInterface.getTypeOfSubNode(nodeName);
} }
public Class<?> getTypeOfSubNodeSubType(final String nodeName) throws ExmlBuilderException { public Class<?> getTypeOfSubNodeSubType(final String nodeName) throws ExmlBuilderException {
return this.modelInterface.getTypeOfSubNodeList(this.data, nodeName); return this.modelInterface.getTypeOfSubNodeList(nodeName);
} }
public String getTreeNameOfSubNode(final String nodeName) throws ExmlBuilderException { public String getTreeNameOfSubNode(final String nodeName) throws ExmlBuilderException {
return this.modelInterface.getTreeNameOfSubNode(this.data, nodeName); return this.modelInterface.getTreeNameOfSubNode(nodeName);
}
public Class<?> getTypeOfProperty(final String nodeName) throws ExmlBuilderException {
return this.modelInterface.getTypeOfProperty(nodeName);
}
public Class<?> getTypeOfSubProperty(final String nodeName) throws ExmlBuilderException {
return this.modelInterface.getTypeOfSubProperty(nodeName);
} }
public void setText(final String text) throws ExmlBuilderException { public void setText(final String text) throws ExmlBuilderException {
@ -70,14 +79,36 @@ public class IntrospectionObject {
public void addObject(final String nodeName, final Object value) { public void addObject(final String nodeName, final Object value) {
List<Object> node = this.nodes.get(nodeName); List<Object> node = this.nodes.get(nodeName);
if (node == null) { if (node == null) {
if (value instanceof List) { if (List.class.isAssignableFrom(value.getClass())) {
node = (List<Object>) value; node = (List<Object>) value;
} else if (value.getClass().isArray()) {
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
} else { } else {
node = new ArrayList<>(); node = new ArrayList<>();
node.add(value); node.add(value);
} }
this.nodes.put(nodeName, node); this.nodes.put(nodeName, node);
} else if (value instanceof List) { } else if (value.getClass().isArray()) {
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
} else if (List.class.isAssignableFrom(value.getClass())) {
List<Object> nodeIn = (List<Object>) value; List<Object> nodeIn = (List<Object>) value;
node.addAll(nodeIn); node.addAll(nodeIn);
} else { } else {

View File

@ -109,9 +109,12 @@ public abstract class IntrospectionProperty {
protected Object createValue(final String value) throws ExmlBuilderException { protected Object createValue(final String value) throws ExmlBuilderException {
try { try {
if (StringSerializer.contains(this.type)) { if (StringSerializer.contains(this.type)) {
// TODO This might be a deprecated code ....
return StringSerializer.valueOf(this.type, value); return StringSerializer.valueOf(this.type, value);
} }
if ((this.type != List.class) || !StringSerializer.contains(this.subType)) { if (this.type.isEnum()) {
} else if ((this.type != List.class) || !StringSerializer.contains(this.subType)) {
throw new ExmlBuilderException("Can not parse the specific element ... need to introspect and find the 'xxx valueOf(String data);'"); throw new ExmlBuilderException("Can not parse the specific element ... need to introspect and find the 'xxx valueOf(String data);'");
} }
ArrayList<Object> out = new ArrayList<>(); ArrayList<Object> out = new ArrayList<>();

View File

@ -46,6 +46,32 @@ public class GeneratorIntrospection implements Generator {
return out; return out;
} }
private <T> String autoArrayToString(final Class<T> clazz, final Object inData, final IntrospectionModel model) throws ExmlBuilderException {
@SuppressWarnings("unchecked")
T[] datas = (T[])inData;
StringBuilder out = new StringBuilder();
for(int iii=0; iii<datas.length; iii++) {
if (!out.isEmpty()) {
out.append(";");
}
out.append(model.toString(datas[iii]));
}
return out.toString();
}
private <T> String autoListToString(final Class<T> clazz, final Object inData, final IntrospectionModel model) throws ExmlBuilderException {
@SuppressWarnings("unchecked")
List<T> elements1 = (List<T>)inData;
StringBuilder out = new StringBuilder();
for (Object elem1: elements1) {
if (!out.isEmpty()) {
out.append(";");
}
out.append(model.toString(elem1));
}
return out.toString();
}
public void generateProperties(final Object data, final IntrospectionModel introspection, final StringBuilder tmpp) throws ExmlBuilderException { public void generateProperties(final Object data, final IntrospectionModel introspection, final StringBuilder tmpp) throws ExmlBuilderException {
List<IntrospectionProperty> elements = introspection.getAttributes(); List<IntrospectionProperty> elements = introspection.getAttributes();
if (elements == null) { if (elements == null) {
@ -55,9 +81,30 @@ public class GeneratorIntrospection implements Generator {
if (!elem.canGetValue()) { if (!elem.canGetValue()) {
continue; continue;
} }
String dataString=elem.getValueString(data); Object dataObj = elem.getValue(data);
if (dataString != null) { if (dataObj == null) {
continue;
}
String name = elem.getNames()[0]; String name = elem.getNames()[0];
Class<?> type = elem.getType();
String dataString = null;
if (type.isArray()) {
Class<?> typeClass = elem.getType().componentType();
if (typeClass.isPrimitive()) {
dataString = StringSerializer.toString(dataObj);
} else {
IntrospectionModel introspectionSub = findOrCreate(ModelType.NORMAL, null, typeClass);
dataString = autoArrayToString(typeClass, dataObj, introspectionSub);
}
} else if (List.class.isAssignableFrom(type)) {
Class<?> typeClass = elem.getSubType();
IntrospectionModel introspectionSub = findOrCreate(ModelType.NORMAL, null, typeClass);
dataString = autoListToString(typeClass, dataObj, introspectionSub);
} else {
IntrospectionModel introspectionSub = findOrCreate(ModelType.NORMAL, null, dataObj.getClass());
dataString = introspectionSub.toString(dataObj);
}
if (dataString != null) {
tmpp.append(" "); tmpp.append(" ");
tmpp.append(name); tmpp.append(name);
tmpp.append("=\""); tmpp.append("=\"");
@ -144,7 +191,7 @@ public class GeneratorIntrospection implements Generator {
public void generateNode(final Object data, final IntrospectionModel model, final String nodeName, final StringBuilder tmpp, final int indent) throws ExmlBuilderException { public void generateNode(final Object data, final IntrospectionModel model, final String nodeName, final StringBuilder tmpp, final int indent) throws ExmlBuilderException {
if (model.isEndPoint()) { if (model.isNative()) {
if (model.isList()) { if (model.isList()) {
String[] listDatas = model.toStringList(data); String[] listDatas = model.toStringList(data);
for (int iii=0; iii<listDatas.length; iii++) { for (int iii=0; iii<listDatas.length; iii++) {
@ -197,6 +244,15 @@ public class GeneratorIntrospection implements Generator {
tmpp.append(baseName.get(0)); tmpp.append(baseName.get(0));
tmpp.append(">"); tmpp.append(">");
} }
} else if (model.isEnum()) {
Tools.addIndent(tmpp, indent);
tmpp.append("<");
tmpp.append(nodeName);
tmpp.append(">");
tmpp.append(model.toString(data));
tmpp.append("</");
tmpp.append(nodeName);
tmpp.append(">");
} else { } else {
Tools.addIndent(tmpp, indent); Tools.addIndent(tmpp, indent);
tmpp.append("<"); tmpp.append("<");

View File

@ -9,7 +9,7 @@ import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger; import io.scenarium.logger.Logger;
public class Log { public class Log {
private static final boolean FORCE = false; private static final boolean FORCE = true;
private static final String LIB_NAME = "exml"; private static final String LIB_NAME = "exml";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME); private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL); private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);

View File

@ -44,16 +44,16 @@ public class ExmlTestIntrospection {
+ " memberLongClass = \"545645645454\"\n" + " memberLongClass = \"545645645454\"\n"
+ " memberBooleanClass = \"true\" \n" + " memberBooleanClass = \"true\" \n"
+ " memberStringClass = \"sdfgsdkjfglksqjéé\"\n" + " memberStringClass = \"sdfgsdkjfglksqjéé\"\n"
+ " memberArrayByte=\"12, 15,123, 100, 2\"\n" + " memberArrayByte=\"12; 15;123; 100; 2\"\n"
+ " memberArrayByteClass=\"\t\t\r\n 12,1, 100,122\"\n" + " memberArrayByteClass=\"\t\t\r\n 12;1; 100;122\"\n"
+ " memberArrayShort=\"1245,1894, -100,-12542\"\n" + " memberArrayShort=\"1245;1894; -100;-12542\"\n"
+ " memberArrayShortClass=\"-1245,-1894, 0,2542,15615\"\n" + " memberArrayShortClass=\"-1245;-1894; 0;2542;15615\"\n"
+ " memberArrayInteger=\"123456,-654987\"\n" + " memberArrayInteger=\"123456;-654987\"\n"
+ " memberArrayIntegerClass=\"1567845,45621354,-5646544\"\n" + " memberArrayIntegerClass=\"1567845;45621354;-5646544\"\n"
+ " memberArrayLong=\"1651324654,65421351685,-5\"\n" + " memberArrayLong=\"1651324654;65421351685;-5\"\n"
+ " memberArrayLongClass=\"6746541351,546546546,564654654,654654654654,-45546\"\n" + " memberArrayLongClass=\"6746541351;546546546;564654654;654654654654;-45546\"\n"
+ " memberArrayBoolean=\"true, true, false\"\n" + " memberArrayBoolean=\"true; true; false\"\n"
+ " memberArrayBooleanClass=\"false, false, true, true\"\n" + " memberArrayBooleanClass=\"false; false; true; true\"\n"
+ "/>\n"; + "/>\n";
//@formatter:on //@formatter:on
@ -128,16 +128,16 @@ public class ExmlTestIntrospection {
+ " memberLongClass = \"545645645454\"\n" + " memberLongClass = \"545645645454\"\n"
+ " memberBooleanClass = \"true\" \n" + " memberBooleanClass = \"true\" \n"
+ " memberStringClass = \"sdfgsdkjfglksqjéé\"\n" + " memberStringClass = \"sdfgsdkjfglksqjéé\"\n"
+ " memberArrayByte=\"12, 15,123, 100, 2\"\n" + " memberArrayByte=\"12; 15;123; 100; 2\"\n"
+ " memberArrayByteClass=\"\t\t\r\n 12,1, 100,122\"\n" + " memberArrayByteClass=\"\t\t\r\n 12;1; 100;122\"\n"
+ " memberArrayShort=\"1245,1894, -100,-12542\"\n" + " memberArrayShort=\"1245;1894; -100;-12542\"\n"
+ " memberArrayShortClass=\"-1245,-1894, 0,2542,15615\"\n" + " memberArrayShortClass=\"-1245;-1894; 0;2542;15615\"\n"
+ " memberArrayInteger=\"123456,-654987\"\n" + " memberArrayInteger=\"123456;-654987\"\n"
+ " memberArrayIntegerClass=\"1567845,45621354,-5646544\"\n" + " memberArrayIntegerClass=\"1567845;45621354;-5646544\"\n"
+ " memberArrayLong=\"1651324654,65421351685,-5\"\n" + " memberArrayLong=\"1651324654;65421351685;-5\"\n"
+ " memberArrayLongClass=\"6746541351,546546546,564654654,654654654654,-45546\"\n" + " memberArrayLongClass=\"6746541351;546546546;564654654;654654654654;-45546\"\n"
+ " memberArrayBoolean=\"true, true, false\"\n" + " memberArrayBoolean=\"true; true; false\"\n"
+ " memberArrayBooleanClass=\"false, false, true, true\"\n" + " memberArrayBooleanClass=\"false; false; true; true\"\n"
+ "/>\n"; + "/>\n";
//@formatter:on //@formatter:on
final ClassPublicMethodOnly[] root = Assertions.assertDoesNotThrow(() -> Exml.parse(dataToParse, ClassPublicMethodOnly.class, "elem")); final ClassPublicMethodOnly[] root = Assertions.assertDoesNotThrow(() -> Exml.parse(dataToParse, ClassPublicMethodOnly.class, "elem"));

View File

@ -5,8 +5,6 @@
*/ */
package test.atriasoft.exml; package test.atriasoft.exml;
import java.util.List;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlDefaultAttibute;

View File

@ -100,19 +100,19 @@ public class ExmlTestIntrospectionByte {
private Byte valueA; private Byte valueA;
private Byte valueB; private Byte valueB;
private Byte valueNull; private Byte valueNull;
public Byte isValueA() { public Byte getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Byte valueA) { public void setValueA(final Byte valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Byte isValueB() { public Byte getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Byte valueB) { public void setValueB(final Byte valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Byte isValueNull() { public Byte getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Byte valueNull) { public void setValueNull(final Byte valueNull) {
@ -134,9 +134,9 @@ public class ExmlTestIntrospectionByte {
Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
final TestByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME)); final TestByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
Assertions.assertEquals((byte)-55, root.isValueA()); Assertions.assertEquals((byte)-55, root.getValueA());
Assertions.assertEquals((byte)57, root.isValueB()); Assertions.assertEquals((byte)57, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -237,7 +237,7 @@ public class ExmlTestIntrospectionByte {
@Test @Test
public void testModelArrayNodeByte() { public void testModelArrayNodeByte() {
TestArrayNodeByte elem = new TestArrayNodeByte(); TestArrayNodeByte elem = new TestArrayNodeByte();
elem.values = new Byte[] {12, -13, 33, 78, -127};; elem.values = new Byte[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder));
@ -294,19 +294,19 @@ public class ExmlTestIntrospectionByte {
private Byte valueA; private Byte valueA;
private Byte valueB; private Byte valueB;
private Byte valueNull; private Byte valueNull;
public Byte isValueA() { public Byte getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Byte valueA) { public void setValueA(final Byte valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Byte isValueB() { public Byte getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Byte valueB) { public void setValueB(final Byte valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Byte isValueNull() { public Byte getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Byte valueNull) { public void setValueNull(final Byte valueNull) {
@ -331,9 +331,9 @@ public class ExmlTestIntrospectionByte {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME)); final TestNodeByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
Assertions.assertEquals((byte)54, root.isValueA()); Assertions.assertEquals((byte)54, root.getValueA());
Assertions.assertEquals((byte)-68, root.isValueB()); Assertions.assertEquals((byte)-68, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
public class TestArrayNodeByteFunc { public class TestArrayNodeByteFunc {

View File

@ -5,8 +5,6 @@
*/ */
package test.atriasoft.exml; package test.atriasoft.exml;
import java.util.List;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlDefaultAttibute;
@ -71,13 +69,13 @@ public class ExmlTestIntrospectionByteNative {
public class TestbyteFunc { public class TestbyteFunc {
private byte valueA; private byte valueA;
private byte valueB; private byte valueB;
public byte isValueA() { public byte getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final byte valueA) { public void setValueA(final byte valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public byte isValueB() { public byte getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final byte valueB) { public void setValueB(final byte valueB) {
@ -98,8 +96,8 @@ public class ExmlTestIntrospectionByteNative {
Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
final TestbyteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestbyteFunc.class, ExmlTestIntrospectionByte.NODE_NAME)); final TestbyteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestbyteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
Assertions.assertEquals((byte)-55, root.isValueA()); Assertions.assertEquals((byte)-55, root.getValueA());
Assertions.assertEquals((byte)57, root.isValueB()); Assertions.assertEquals((byte)57, root.getValueB());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -165,7 +163,7 @@ public class ExmlTestIntrospectionByteNative {
@Test @Test
public void testModelArrayNodebyteNative() { public void testModelArrayNodebyteNative() {
TestArrayNodeByteNative elem = new TestArrayNodeByteNative(); TestArrayNodeByteNative elem = new TestArrayNodeByteNative();
elem.values = new byte[] {12, -13, 33, 78, -127};; elem.values = new byte[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder));
@ -191,13 +189,13 @@ public class ExmlTestIntrospectionByteNative {
public class TestNodebyteFunc { public class TestNodebyteFunc {
private byte valueA; private byte valueA;
private byte valueB; private byte valueB;
public byte isValueA() { public byte getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final byte valueA) { public void setValueA(final byte valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public byte isValueB() { public byte getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final byte valueB) { public void setValueB(final byte valueB) {
@ -221,8 +219,8 @@ public class ExmlTestIntrospectionByteNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodebyteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodebyteFunc.class, ExmlTestIntrospectionByte.NODE_NAME)); final TestNodebyteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodebyteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
Assertions.assertEquals((byte)54, root.isValueA()); Assertions.assertEquals((byte)54, root.getValueA());
Assertions.assertEquals((byte)-68, root.isValueB()); Assertions.assertEquals((byte)-68, root.getValueB());
} }
public class TestArrayNodeByteFunc { public class TestArrayNodeByteFunc {

View File

@ -41,8 +41,8 @@ public class ExmlTestIntrospectionDouble {
Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
final TestDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDouble.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)12, root.valueA); Assertions.assertEquals(12, root.valueA);
Assertions.assertEquals((double)-13, root.valueB); Assertions.assertEquals(-13, root.valueB);
Assertions.assertEquals(null, root.valueNull); Assertions.assertEquals(null, root.valueNull);
} }
@ -63,11 +63,11 @@ public class ExmlTestIntrospectionDouble {
final TestArrayDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDouble.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((double)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((double)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((double)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((double)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((double)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -87,11 +87,11 @@ public class ExmlTestIntrospectionDouble {
final TestListDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListDouble.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestListDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.values.size()); Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals((double)12, root.values.get(0)); Assertions.assertEquals(12, root.values.get(0));
Assertions.assertEquals((double)-13, root.values.get(1)); Assertions.assertEquals(-13, root.values.get(1));
Assertions.assertEquals((double)33, root.values.get(2)); Assertions.assertEquals(33, root.values.get(2));
Assertions.assertEquals((double)78, root.values.get(3)); Assertions.assertEquals(78, root.values.get(3));
Assertions.assertEquals((double)-127, root.values.get(4)); Assertions.assertEquals(-127, root.values.get(4));
} }
@ -100,19 +100,19 @@ public class ExmlTestIntrospectionDouble {
private Double valueA; private Double valueA;
private Double valueB; private Double valueB;
private Double valueNull; private Double valueNull;
public Double isValueA() { public Double getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Double valueA) { public void setValueA(final Double valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Double isValueB() { public Double getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Double valueB) { public void setValueB(final Double valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Double isValueNull() { public Double getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Double valueNull) { public void setValueNull(final Double valueNull) {
@ -134,9 +134,9 @@ public class ExmlTestIntrospectionDouble {
Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
final TestDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)-55, root.isValueA()); Assertions.assertEquals(-55, root.getValueA());
Assertions.assertEquals((double)57, root.isValueB()); Assertions.assertEquals(57, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -165,11 +165,11 @@ public class ExmlTestIntrospectionDouble {
final TestArrayDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((double)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((double)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((double)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((double)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((double)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -197,11 +197,11 @@ public class ExmlTestIntrospectionDouble {
final TestListDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestListDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size()); Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals((double)12, root.getValues().get(0)); Assertions.assertEquals(12, root.getValues().get(0));
Assertions.assertEquals((double)-13, root.getValues().get(1)); Assertions.assertEquals(-13, root.getValues().get(1));
Assertions.assertEquals((double)33, root.getValues().get(2)); Assertions.assertEquals(33, root.getValues().get(2));
Assertions.assertEquals((double)78, root.getValues().get(3)); Assertions.assertEquals(78, root.getValues().get(3));
Assertions.assertEquals((double)-127, root.getValues().get(4)); Assertions.assertEquals(-127, root.getValues().get(4));
} }
public class TestNodeDouble { public class TestNodeDouble {
@ -226,8 +226,8 @@ public class ExmlTestIntrospectionDouble {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)11, root.valueA); Assertions.assertEquals(11, root.valueA);
Assertions.assertEquals((double)-120, root.valueB); Assertions.assertEquals(-120, root.valueB);
Assertions.assertEquals(null, root.valueNull); Assertions.assertEquals(null, root.valueNull);
} }
@ -237,7 +237,7 @@ public class ExmlTestIntrospectionDouble {
@Test @Test
public void testModelArrayNodeDouble() { public void testModelArrayNodeDouble() {
TestArrayNodeDouble elem = new TestArrayNodeDouble(); TestArrayNodeDouble elem = new TestArrayNodeDouble();
elem.values = new Double[] {(double)12, (double)-13, (double)33, (double)78, (double)-127};; elem.values = new Double[] {(double)12, (double)-13, (double)33, (double)78, (double)-127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder));
@ -253,11 +253,11 @@ public class ExmlTestIntrospectionDouble {
final TestArrayNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((double)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((double)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((double)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((double)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((double)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
public class TestListNodeDouble { public class TestListNodeDouble {
@ -282,11 +282,11 @@ public class ExmlTestIntrospectionDouble {
final TestListNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestListNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.values.size()); Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals((double)12, root.values.get(0)); Assertions.assertEquals(12, root.values.get(0));
Assertions.assertEquals((double)-13, root.values.get(1)); Assertions.assertEquals(-13, root.values.get(1));
Assertions.assertEquals((double)33, root.values.get(2)); Assertions.assertEquals(33, root.values.get(2));
Assertions.assertEquals((double)78, root.values.get(3)); Assertions.assertEquals(78, root.values.get(3));
Assertions.assertEquals((double)-127, root.values.get(4)); Assertions.assertEquals(-127, root.values.get(4));
} }
@ -294,19 +294,19 @@ public class ExmlTestIntrospectionDouble {
private Double valueA; private Double valueA;
private Double valueB; private Double valueB;
private Double valueNull; private Double valueNull;
public Double isValueA() { public Double getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Double valueA) { public void setValueA(final Double valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Double isValueB() { public Double getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Double valueB) { public void setValueB(final Double valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Double isValueNull() { public Double getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Double valueNull) { public void setValueNull(final Double valueNull) {
@ -331,9 +331,9 @@ public class ExmlTestIntrospectionDouble {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)54, root.isValueA()); Assertions.assertEquals(54, root.getValueA());
Assertions.assertEquals((double)-68, root.isValueB()); Assertions.assertEquals(-68, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
public class TestArrayNodeDoubleFunc { public class TestArrayNodeDoubleFunc {
@ -367,11 +367,11 @@ public class ExmlTestIntrospectionDouble {
final TestArrayNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((double)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((double)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((double)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((double)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((double)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
// Note this is set in static to test an other part of code... // Note this is set in static to test an other part of code...
@ -405,11 +405,11 @@ public class ExmlTestIntrospectionDouble {
final TestListNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestListNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size()); Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals((double)12, root.getValues().get(0)); Assertions.assertEquals(12, root.getValues().get(0));
Assertions.assertEquals((double)-13, root.getValues().get(1)); Assertions.assertEquals(-13, root.getValues().get(1));
Assertions.assertEquals((double)33, root.getValues().get(2)); Assertions.assertEquals(33, root.getValues().get(2));
Assertions.assertEquals((double)78, root.getValues().get(3)); Assertions.assertEquals(78, root.getValues().get(3));
Assertions.assertEquals((double)-127, root.getValues().get(4)); Assertions.assertEquals(-127, root.getValues().get(4));
} }
} }

View File

@ -5,8 +5,6 @@
*/ */
package test.atriasoft.exml; package test.atriasoft.exml;
import java.util.List;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlDefaultAttibute;
@ -29,8 +27,8 @@ public class ExmlTestIntrospectionDoubleNative {
@Test @Test
public void testModelDoubleNative() { public void testModelDoubleNative() {
TestDoubleNative elem = new TestDoubleNative(); TestDoubleNative elem = new TestDoubleNative();
elem.valueA = (double)12; elem.valueA = 12;
elem.valueB = (double)-13; elem.valueB = -13;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder));
@ -39,8 +37,8 @@ public class ExmlTestIntrospectionDoubleNative {
Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
final TestDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)12, root.valueA); Assertions.assertEquals(12, root.valueA);
Assertions.assertEquals((double)-13, root.valueB); Assertions.assertEquals(-13, root.valueB);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -60,24 +58,24 @@ public class ExmlTestIntrospectionDoubleNative {
final TestArrayDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((double)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((double)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((double)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((double)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((double)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
public class TestdoubleFunc { public class TestdoubleFunc {
private double valueA; private double valueA;
private double valueB; private double valueB;
public double isValueA() { public double getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final double valueA) { public void setValueA(final double valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public double isValueB() { public double getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final double valueB) { public void setValueB(final double valueB) {
@ -88,8 +86,8 @@ public class ExmlTestIntrospectionDoubleNative {
@Test @Test
public void testModelDoubleFunc() { public void testModelDoubleFunc() {
TestdoubleFunc elem = new TestdoubleFunc(); TestdoubleFunc elem = new TestdoubleFunc();
elem.setValueA((double)-55); elem.setValueA(-55);
elem.setValueB((double)57); elem.setValueB(57);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder));
@ -98,8 +96,8 @@ public class ExmlTestIntrospectionDoubleNative {
Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
final TestdoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestdoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestdoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestdoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)-55, root.isValueA()); Assertions.assertEquals(-55, root.getValueA());
Assertions.assertEquals((double)57, root.isValueB()); Assertions.assertEquals(57, root.getValueB());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -128,11 +126,11 @@ public class ExmlTestIntrospectionDoubleNative {
final TestArrayDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((double)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((double)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((double)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((double)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((double)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
public class TestNodeDoubleNative { public class TestNodeDoubleNative {
@ -142,8 +140,8 @@ public class ExmlTestIntrospectionDoubleNative {
@Test @Test
public void testModelNodeDoubleNative() { public void testModelNodeDoubleNative() {
TestNodeDoubleNative elem = new TestNodeDoubleNative(); TestNodeDoubleNative elem = new TestNodeDoubleNative();
elem.valueA = (double)11; elem.valueA = 11;
elem.valueB = (double)-120; elem.valueB = -120;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder));
@ -155,8 +153,8 @@ public class ExmlTestIntrospectionDoubleNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestNodeDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)11, root.valueA); Assertions.assertEquals(11, root.valueA);
Assertions.assertEquals((double)-120, root.valueB); Assertions.assertEquals(-120, root.valueB);
} }
public class TestArrayNodeDoubleNative { public class TestArrayNodeDoubleNative {
@ -165,7 +163,7 @@ public class ExmlTestIntrospectionDoubleNative {
@Test @Test
public void testModelArrayNodeDoubleNative() { public void testModelArrayNodeDoubleNative() {
TestArrayNodeDoubleNative elem = new TestArrayNodeDoubleNative(); TestArrayNodeDoubleNative elem = new TestArrayNodeDoubleNative();
elem.values = new double[] {12, -13, 33, 78, -127};; elem.values = new double[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder));
@ -181,23 +179,23 @@ public class ExmlTestIntrospectionDoubleNative {
final TestArrayNodeDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayNodeDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((double)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((double)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((double)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((double)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((double)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
public class TestNodedoubleFunc { public class TestNodedoubleFunc {
private double valueA; private double valueA;
private double valueB; private double valueB;
public double isValueA() { public double getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final double valueA) { public void setValueA(final double valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public double isValueB() { public double getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final double valueB) { public void setValueB(final double valueB) {
@ -208,8 +206,8 @@ public class ExmlTestIntrospectionDoubleNative {
@Test @Test
public void testModelNodeDoubleFunc() { public void testModelNodeDoubleFunc() {
TestNodedoubleFunc elem = new TestNodedoubleFunc(); TestNodedoubleFunc elem = new TestNodedoubleFunc();
elem.setValueA((double)54); elem.setValueA(54);
elem.setValueB((double)-68); elem.setValueB(-68);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder));
@ -221,8 +219,8 @@ public class ExmlTestIntrospectionDoubleNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodedoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodedoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestNodedoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodedoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals((double)54, root.isValueA()); Assertions.assertEquals(54, root.getValueA());
Assertions.assertEquals((double)-68, root.isValueB()); Assertions.assertEquals(-68, root.getValueB());
} }
public class TestArrayNodeDoubleFunc { public class TestArrayNodeDoubleFunc {
@ -256,11 +254,11 @@ public class ExmlTestIntrospectionDoubleNative {
final TestArrayNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME)); final TestArrayNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((double)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((double)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((double)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((double)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((double)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
} }

View File

@ -0,0 +1,397 @@
/** @file
* @author Edouard DUPIN
* @copyright 2021, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package test.atriasoft.exml;
import java.util.List;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class ExmlTestIntrospectionEnum {
static final String NODE_NAME = "elem";
@BeforeAll
public static void beforeClass() {
Log.warning("================================================================");
}
public enum TestEnumVal {
VALUE_1,
VALUE_2,
VALUE_3;
}
@XmlDefaultAttibute
public class TestEnum {
public TestEnumVal valueA;
public TestEnumVal valueB;
}
@Test
public void testModelEnum() {
TestEnum elem = new TestEnum();
elem.valueA = TestEnumVal.VALUE_1;
elem.valueB = TestEnumVal.VALUE_3;
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem valueA=\"VALUE_1\" valueB=\"VALUE_3\"/>", dataTest);
final TestEnum root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestEnum.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(TestEnumVal.VALUE_1, root.valueA);
Assertions.assertEquals(TestEnumVal.VALUE_3, root.valueB);
}
@XmlDefaultAttibute
public class TestArrayEnum {
public TestEnumVal[] values;
}
@Test
public void testModelArrayEnum() {
TestArrayEnum elem = new TestArrayEnum();
elem.values = new TestEnumVal[] {TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2};
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem values=\"VALUE_1;VALUE_2;VALUE_3;VALUE_1;VALUE_2\"/>", dataTest);
final TestArrayEnum root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayEnum.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values[0]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values[1]);
Assertions.assertEquals(TestEnumVal.VALUE_3, root.values[2]);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values[3]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values[4]);
}
@XmlDefaultAttibute
public class TestListEnum {
public List<TestEnumVal> values;
}
@Test
public void testModelListEnum() {
TestListEnum elem = new TestListEnum();
elem.values = List.of(TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2);
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem values=\"VALUE_1;VALUE_2;VALUE_3;VALUE_1;VALUE_2\"/>", dataTest);
final TestListEnum root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListEnum.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values.get(0));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values.get(1));
Assertions.assertEquals(TestEnumVal.VALUE_3, root.values.get(2));
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values.get(3));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values.get(4));
}
@XmlDefaultAttibute
public class TestEnumFunc {
private TestEnumVal valueA;
private TestEnumVal valueB;
public TestEnumVal getValueA() {
return this.valueA;
}
public void setValueA(final TestEnumVal valueA) {
this.valueA = valueA;
}
public TestEnumVal getValueB() {
return this.valueB;
}
public void setValueB(final TestEnumVal valueB) {
this.valueB = valueB;
}
}
@Test
public void testModelEnumFunc() {
TestEnumFunc elem = new TestEnumFunc();
elem.setValueA(TestEnumVal.VALUE_1);
elem.setValueB(TestEnumVal.VALUE_2);
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem valueA=\"VALUE_1\" valueB=\"VALUE_2\"/>", dataTest);
final TestEnumFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestEnumFunc.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValueA());
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValueB());
}
@XmlDefaultAttibute
public class TestArrayEnumFunc {
private TestEnumVal[] values;
public TestEnumVal[] getValues() {
return this.values;
}
public void setValues(final TestEnumVal[] values) {
this.values = values;
}
}
@Test
public void testModelArrayEnumFunc() {
TestArrayEnumFunc elem = new TestArrayEnumFunc();
elem.setValues(new TestEnumVal[] {TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2});
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem values=\"VALUE_1;VALUE_2;VALUE_3;VALUE_1;VALUE_2\"/>", dataTest);
final TestArrayEnumFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayEnumFunc.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues()[0]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues()[1]);
Assertions.assertEquals(TestEnumVal.VALUE_3, root.getValues()[2]);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues()[3]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues()[4]);
}
@XmlDefaultAttibute
public class TestListEnumFunc {
private List<TestEnumVal> values;
public List<TestEnumVal> getValues() {
return this.values;
}
public void setValues(final List<TestEnumVal> values) {
this.values = values;
}
}
@Test
public void testModelListEnumFunc() {
TestListEnumFunc elem = new TestListEnumFunc();
elem.setValues(List.of(TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2));
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem values=\"VALUE_1;VALUE_2;VALUE_3;VALUE_1;VALUE_2\"/>", dataTest);
final TestListEnumFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListEnumFunc.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues().get(0));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues().get(1));
Assertions.assertEquals(TestEnumVal.VALUE_3, root.getValues().get(2));
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues().get(3));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues().get(4));
}
public class TestNodeEnum {
public TestEnumVal valueA;
public TestEnumVal valueB;
}
@Test
public void testModelNodeEnum() {
TestNodeEnum elem = new TestNodeEnum();
elem.valueA = TestEnumVal.VALUE_3;
elem.valueB = TestEnumVal.VALUE_1;
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem>\n"
+ " <valueA>VALUE_3</valueA>\n"
+ " <valueB>VALUE_1</valueB>\n"
+ "</elem>", dataTest);
final TestNodeEnum root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeEnum.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(TestEnumVal.VALUE_3, root.valueA);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.valueB);
}
public class TestArrayNodeEnum {
public TestEnumVal[] values;
}
@Test
public void testModelArrayNodeEnum() {
TestArrayNodeEnum elem = new TestArrayNodeEnum();
elem.values = new TestEnumVal[] {TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2};
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ " <values>VALUE_3</values>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ "</elem>", dataTest);
final TestArrayNodeEnum root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeEnum.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values[0]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values[1]);
Assertions.assertEquals(TestEnumVal.VALUE_3, root.values[2]);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values[3]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values[4]);
}
public class TestListNodeEnum {
public List<TestEnumVal> values;
}
@Test
public void testModelListNodeEnum() {
TestListNodeEnum elem = new TestListNodeEnum();
elem.values = List.of(TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2);
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ " <values>VALUE_3</values>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ "</elem>", dataTest);
final TestListNodeEnum root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeEnum.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values.get(0));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values.get(1));
Assertions.assertEquals(TestEnumVal.VALUE_3, root.values.get(2));
Assertions.assertEquals(TestEnumVal.VALUE_1, root.values.get(3));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.values.get(4));
}
public class TestNodeEnumFunc {
private TestEnumVal valueA;
private TestEnumVal valueB;
public TestEnumVal getValueA() {
return this.valueA;
}
public void setValueA(final TestEnumVal valueA) {
this.valueA = valueA;
}
public TestEnumVal getValueB() {
return this.valueB;
}
public void setValueB(final TestEnumVal valueB) {
this.valueB = valueB;
}
}
@Test
public void testModelNodeEnumFunc() {
TestNodeEnumFunc elem = new TestNodeEnumFunc();
elem.setValueA(TestEnumVal.VALUE_2);
elem.setValueB(TestEnumVal.VALUE_3);
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem>\n"
+ " <valueA>VALUE_2</valueA>\n"
+ " <valueB>VALUE_3</valueB>\n"
+ "</elem>", dataTest);
final TestNodeEnumFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeEnumFunc.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValueA());
Assertions.assertEquals(TestEnumVal.VALUE_3, root.getValueB());
}
public class TestArrayNodeEnumFunc {
private TestEnumVal[] values;
public TestEnumVal[] getValues() {
return this.values;
}
public void setValues(final TestEnumVal[] values) {
this.values = values;
}
}
@Test
public void testModelArrayNodeEnumFunc() {
TestArrayNodeEnumFunc elem = new TestArrayNodeEnumFunc();
elem.setValues(new TestEnumVal[] {TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2});
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ " <values>VALUE_3</values>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ "</elem>", dataTest);
final TestArrayNodeEnumFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeEnumFunc.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues()[0]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues()[1]);
Assertions.assertEquals(TestEnumVal.VALUE_3, root.getValues()[2]);
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues()[3]);
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues()[4]);
}
// Note this is set in static to test an other part of code...
public static class TestListNodeEnumFunc {
private List<TestEnumVal> values;
public List<TestEnumVal> getValues() {
return this.values;
}
public void setValues(final List<TestEnumVal> values) {
this.values = values;
}
}
@Test
public void testModelListNodeEnumFunc() {
TestListNodeEnumFunc elem = new TestListNodeEnumFunc();
elem.setValues(List.of(TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2));
StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder));
String dataTest = builder.toString();
Log.warning("data generated: " + builder.toString());
Assertions.assertEquals("<elem>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ " <values>VALUE_3</values>\n"
+ " <values>VALUE_1</values>\n"
+ " <values>VALUE_2</values>\n"
+ "</elem>", dataTest);
final TestListNodeEnumFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeEnumFunc.class, ExmlTestIntrospectionEnum.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues().get(0));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues().get(1));
Assertions.assertEquals(TestEnumVal.VALUE_3, root.getValues().get(2));
Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues().get(3));
Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues().get(4));
}
}

View File

@ -41,8 +41,8 @@ public class ExmlTestIntrospectionFloat {
Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
final TestFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloat.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)12, root.valueA); Assertions.assertEquals(12, root.valueA);
Assertions.assertEquals((float)-13, root.valueB); Assertions.assertEquals(-13, root.valueB);
Assertions.assertEquals(null, root.valueNull); Assertions.assertEquals(null, root.valueNull);
} }
@ -63,11 +63,11 @@ public class ExmlTestIntrospectionFloat {
final TestArrayFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloat.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((float)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((float)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((float)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((float)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((float)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -87,11 +87,11 @@ public class ExmlTestIntrospectionFloat {
final TestListFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListFloat.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestListFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.values.size()); Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals((float)12, root.values.get(0)); Assertions.assertEquals(12, root.values.get(0));
Assertions.assertEquals((float)-13, root.values.get(1)); Assertions.assertEquals(-13, root.values.get(1));
Assertions.assertEquals((float)33, root.values.get(2)); Assertions.assertEquals(33, root.values.get(2));
Assertions.assertEquals((float)78, root.values.get(3)); Assertions.assertEquals(78, root.values.get(3));
Assertions.assertEquals((float)-127, root.values.get(4)); Assertions.assertEquals(-127, root.values.get(4));
} }
@ -100,19 +100,19 @@ public class ExmlTestIntrospectionFloat {
private Float valueA; private Float valueA;
private Float valueB; private Float valueB;
private Float valueNull; private Float valueNull;
public Float isValueA() { public Float getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Float valueA) { public void setValueA(final Float valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Float isValueB() { public Float getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Float valueB) { public void setValueB(final Float valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Float isValueNull() { public Float getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Float valueNull) { public void setValueNull(final Float valueNull) {
@ -134,9 +134,9 @@ public class ExmlTestIntrospectionFloat {
Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
final TestFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)-55, root.isValueA()); Assertions.assertEquals(-55, root.getValueA());
Assertions.assertEquals((float)57, root.isValueB()); Assertions.assertEquals(57, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -165,11 +165,11 @@ public class ExmlTestIntrospectionFloat {
final TestArrayFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((float)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((float)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((float)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((float)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((float)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -197,11 +197,11 @@ public class ExmlTestIntrospectionFloat {
final TestListFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestListFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size()); Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals((float)12, root.getValues().get(0)); Assertions.assertEquals(12, root.getValues().get(0));
Assertions.assertEquals((float)-13, root.getValues().get(1)); Assertions.assertEquals(-13, root.getValues().get(1));
Assertions.assertEquals((float)33, root.getValues().get(2)); Assertions.assertEquals(33, root.getValues().get(2));
Assertions.assertEquals((float)78, root.getValues().get(3)); Assertions.assertEquals(78, root.getValues().get(3));
Assertions.assertEquals((float)-127, root.getValues().get(4)); Assertions.assertEquals(-127, root.getValues().get(4));
} }
public class TestNodeFloat { public class TestNodeFloat {
@ -226,8 +226,8 @@ public class ExmlTestIntrospectionFloat {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)11, root.valueA); Assertions.assertEquals(11, root.valueA);
Assertions.assertEquals((float)-120, root.valueB); Assertions.assertEquals(-120, root.valueB);
Assertions.assertEquals(null, root.valueNull); Assertions.assertEquals(null, root.valueNull);
} }
@ -237,7 +237,7 @@ public class ExmlTestIntrospectionFloat {
@Test @Test
public void testModelArrayNodeFloat() { public void testModelArrayNodeFloat() {
TestArrayNodeFloat elem = new TestArrayNodeFloat(); TestArrayNodeFloat elem = new TestArrayNodeFloat();
elem.values = new Float[] {(float)12, (float)-13, (float)33, (float)78, (float)-127};; elem.values = new Float[] {(float)12, (float)-13, (float)33, (float)78, (float)-127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder));
@ -253,11 +253,11 @@ public class ExmlTestIntrospectionFloat {
final TestArrayNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((float)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((float)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((float)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((float)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((float)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
public class TestListNodeFloat { public class TestListNodeFloat {
@ -282,11 +282,11 @@ public class ExmlTestIntrospectionFloat {
final TestListNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestListNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.values.size()); Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals((float)12, root.values.get(0)); Assertions.assertEquals(12, root.values.get(0));
Assertions.assertEquals((float)-13, root.values.get(1)); Assertions.assertEquals(-13, root.values.get(1));
Assertions.assertEquals((float)33, root.values.get(2)); Assertions.assertEquals(33, root.values.get(2));
Assertions.assertEquals((float)78, root.values.get(3)); Assertions.assertEquals(78, root.values.get(3));
Assertions.assertEquals((float)-127, root.values.get(4)); Assertions.assertEquals(-127, root.values.get(4));
} }
@ -294,19 +294,19 @@ public class ExmlTestIntrospectionFloat {
private Float valueA; private Float valueA;
private Float valueB; private Float valueB;
private Float valueNull; private Float valueNull;
public Float isValueA() { public Float getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Float valueA) { public void setValueA(final Float valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Float isValueB() { public Float getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Float valueB) { public void setValueB(final Float valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Float isValueNull() { public Float getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Float valueNull) { public void setValueNull(final Float valueNull) {
@ -331,9 +331,9 @@ public class ExmlTestIntrospectionFloat {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)54, root.isValueA()); Assertions.assertEquals(54, root.getValueA());
Assertions.assertEquals((float)-68, root.isValueB()); Assertions.assertEquals(-68, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
public class TestArrayNodeFloatFunc { public class TestArrayNodeFloatFunc {
@ -367,11 +367,11 @@ public class ExmlTestIntrospectionFloat {
final TestArrayNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((float)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((float)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((float)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((float)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((float)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
// Note this is set in static to test an other part of code... // Note this is set in static to test an other part of code...
@ -405,11 +405,11 @@ public class ExmlTestIntrospectionFloat {
final TestListNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestListNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size()); Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals((float)12, root.getValues().get(0)); Assertions.assertEquals(12, root.getValues().get(0));
Assertions.assertEquals((float)-13, root.getValues().get(1)); Assertions.assertEquals(-13, root.getValues().get(1));
Assertions.assertEquals((float)33, root.getValues().get(2)); Assertions.assertEquals(33, root.getValues().get(2));
Assertions.assertEquals((float)78, root.getValues().get(3)); Assertions.assertEquals(78, root.getValues().get(3));
Assertions.assertEquals((float)-127, root.getValues().get(4)); Assertions.assertEquals(-127, root.getValues().get(4));
} }
} }

View File

@ -5,8 +5,6 @@
*/ */
package test.atriasoft.exml; package test.atriasoft.exml;
import java.util.List;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlDefaultAttibute;
@ -29,8 +27,8 @@ public class ExmlTestIntrospectionFloatNative {
@Test @Test
public void testModelFloatNative() { public void testModelFloatNative() {
TestFloatNative elem = new TestFloatNative(); TestFloatNative elem = new TestFloatNative();
elem.valueA = (float)12; elem.valueA = 12;
elem.valueB = (float)-13; elem.valueB = -13;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder));
@ -39,8 +37,8 @@ public class ExmlTestIntrospectionFloatNative {
Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
final TestFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)12, root.valueA); Assertions.assertEquals(12, root.valueA);
Assertions.assertEquals((float)-13, root.valueB); Assertions.assertEquals(-13, root.valueB);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -60,24 +58,24 @@ public class ExmlTestIntrospectionFloatNative {
final TestArrayFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((float)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((float)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((float)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((float)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((float)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
public class TestfloatFunc { public class TestfloatFunc {
private float valueA; private float valueA;
private float valueB; private float valueB;
public float isValueA() { public float getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final float valueA) { public void setValueA(final float valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public float isValueB() { public float getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final float valueB) { public void setValueB(final float valueB) {
@ -88,8 +86,8 @@ public class ExmlTestIntrospectionFloatNative {
@Test @Test
public void testModelFloatFunc() { public void testModelFloatFunc() {
TestfloatFunc elem = new TestfloatFunc(); TestfloatFunc elem = new TestfloatFunc();
elem.setValueA((float)-55); elem.setValueA(-55);
elem.setValueB((float)57); elem.setValueB(57);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder));
@ -98,8 +96,8 @@ public class ExmlTestIntrospectionFloatNative {
Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
final TestfloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestfloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestfloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestfloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)-55, root.isValueA()); Assertions.assertEquals(-55, root.getValueA());
Assertions.assertEquals((float)57, root.isValueB()); Assertions.assertEquals(57, root.getValueB());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -128,11 +126,11 @@ public class ExmlTestIntrospectionFloatNative {
final TestArrayFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((float)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((float)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((float)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((float)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((float)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
public class TestNodeFloatNative { public class TestNodeFloatNative {
@ -142,8 +140,8 @@ public class ExmlTestIntrospectionFloatNative {
@Test @Test
public void testModelNodeFloatNative() { public void testModelNodeFloatNative() {
TestNodeFloatNative elem = new TestNodeFloatNative(); TestNodeFloatNative elem = new TestNodeFloatNative();
elem.valueA = (float)11; elem.valueA = 11;
elem.valueB = (float)-120; elem.valueB = -120;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder));
@ -155,8 +153,8 @@ public class ExmlTestIntrospectionFloatNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestNodeFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)11, root.valueA); Assertions.assertEquals(11, root.valueA);
Assertions.assertEquals((float)-120, root.valueB); Assertions.assertEquals(-120, root.valueB);
} }
public class TestArrayNodeFloatNative { public class TestArrayNodeFloatNative {
@ -165,7 +163,7 @@ public class ExmlTestIntrospectionFloatNative {
@Test @Test
public void testModelArrayNodeFloatNative() { public void testModelArrayNodeFloatNative() {
TestArrayNodeFloatNative elem = new TestArrayNodeFloatNative(); TestArrayNodeFloatNative elem = new TestArrayNodeFloatNative();
elem.values = new float[] {12, -13, 33, 78, -127};; elem.values = new float[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder));
@ -181,23 +179,23 @@ public class ExmlTestIntrospectionFloatNative {
final TestArrayNodeFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayNodeFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((float)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((float)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((float)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((float)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((float)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
public class TestNodefloatFunc { public class TestNodefloatFunc {
private float valueA; private float valueA;
private float valueB; private float valueB;
public float isValueA() { public float getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final float valueA) { public void setValueA(final float valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public float isValueB() { public float getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final float valueB) { public void setValueB(final float valueB) {
@ -208,8 +206,8 @@ public class ExmlTestIntrospectionFloatNative {
@Test @Test
public void testModelNodeFloatFunc() { public void testModelNodeFloatFunc() {
TestNodefloatFunc elem = new TestNodefloatFunc(); TestNodefloatFunc elem = new TestNodefloatFunc();
elem.setValueA((float)54); elem.setValueA(54);
elem.setValueB((float)-68); elem.setValueB(-68);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder));
@ -221,8 +219,8 @@ public class ExmlTestIntrospectionFloatNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodefloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodefloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestNodefloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodefloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals((float)54, root.isValueA()); Assertions.assertEquals(54, root.getValueA());
Assertions.assertEquals((float)-68, root.isValueB()); Assertions.assertEquals(-68, root.getValueB());
} }
public class TestArrayNodeFloatFunc { public class TestArrayNodeFloatFunc {
@ -256,11 +254,11 @@ public class ExmlTestIntrospectionFloatNative {
final TestArrayNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME)); final TestArrayNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((float)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((float)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((float)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((float)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((float)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
} }

View File

@ -41,8 +41,8 @@ public class ExmlTestIntrospectionInteger {
Assertions.assertEquals("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
final TestInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestInteger.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)12, root.valueA); Assertions.assertEquals(12, root.valueA);
Assertions.assertEquals((int)-13, root.valueB); Assertions.assertEquals(-13, root.valueB);
Assertions.assertEquals(null, root.valueNull); Assertions.assertEquals(null, root.valueNull);
} }
@ -63,11 +63,11 @@ public class ExmlTestIntrospectionInteger {
final TestArrayInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayInteger.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((int)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((int)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((int)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((int)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((int)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -77,7 +77,7 @@ public class ExmlTestIntrospectionInteger {
@Test @Test
public void testModelListInteger() { public void testModelListInteger() {
TestListInteger elem = new TestListInteger(); TestListInteger elem = new TestListInteger();
elem.values = List.of((int)12, (int)-13, (int)33, (int)78, (int)-127); elem.values = List.of(12, -13, 33, 78, -127);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -87,11 +87,11 @@ public class ExmlTestIntrospectionInteger {
final TestListInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListInteger.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestListInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.values.size()); Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals((int)12, root.values.get(0)); Assertions.assertEquals(12, root.values.get(0));
Assertions.assertEquals((int)-13, root.values.get(1)); Assertions.assertEquals(-13, root.values.get(1));
Assertions.assertEquals((int)33, root.values.get(2)); Assertions.assertEquals(33, root.values.get(2));
Assertions.assertEquals((int)78, root.values.get(3)); Assertions.assertEquals(78, root.values.get(3));
Assertions.assertEquals((int)-127, root.values.get(4)); Assertions.assertEquals(-127, root.values.get(4));
} }
@ -100,19 +100,19 @@ public class ExmlTestIntrospectionInteger {
private Integer valueA; private Integer valueA;
private Integer valueB; private Integer valueB;
private Integer valueNull; private Integer valueNull;
public Integer isValueA() { public Integer getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Integer valueA) { public void setValueA(final Integer valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Integer isValueB() { public Integer getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Integer valueB) { public void setValueB(final Integer valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Integer isValueNull() { public Integer getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Integer valueNull) { public void setValueNull(final Integer valueNull) {
@ -123,8 +123,8 @@ public class ExmlTestIntrospectionInteger {
@Test @Test
public void testModelIntegerFunc() { public void testModelIntegerFunc() {
TestIntegerFunc elem = new TestIntegerFunc(); TestIntegerFunc elem = new TestIntegerFunc();
elem.setValueA((int)-55); elem.setValueA(-55);
elem.setValueB((int)57); elem.setValueB(57);
elem.setValueNull(null); elem.setValueNull(null);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -134,9 +134,9 @@ public class ExmlTestIntrospectionInteger {
Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
final TestIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)-55, root.isValueA()); Assertions.assertEquals(-55, root.getValueA());
Assertions.assertEquals((int)57, root.isValueB()); Assertions.assertEquals(57, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -165,11 +165,11 @@ public class ExmlTestIntrospectionInteger {
final TestArrayIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((int)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((int)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((int)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((int)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((int)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -187,7 +187,7 @@ public class ExmlTestIntrospectionInteger {
@Test @Test
public void testModelListIntegerFunc() { public void testModelListIntegerFunc() {
TestListIntegerFunc elem = new TestListIntegerFunc(); TestListIntegerFunc elem = new TestListIntegerFunc();
elem.setValues(List.of((int)12, (int)-13, (int)33, (int)78, (int)-127)); elem.setValues(List.of(12, -13, 33, 78, -127));
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -197,11 +197,11 @@ public class ExmlTestIntrospectionInteger {
final TestListIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestListIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size()); Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals((int)12, root.getValues().get(0)); Assertions.assertEquals(12, root.getValues().get(0));
Assertions.assertEquals((int)-13, root.getValues().get(1)); Assertions.assertEquals(-13, root.getValues().get(1));
Assertions.assertEquals((int)33, root.getValues().get(2)); Assertions.assertEquals(33, root.getValues().get(2));
Assertions.assertEquals((int)78, root.getValues().get(3)); Assertions.assertEquals(78, root.getValues().get(3));
Assertions.assertEquals((int)-127, root.getValues().get(4)); Assertions.assertEquals(-127, root.getValues().get(4));
} }
public class TestNodeInteger { public class TestNodeInteger {
@ -226,8 +226,8 @@ public class ExmlTestIntrospectionInteger {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)11, root.valueA); Assertions.assertEquals(11, root.valueA);
Assertions.assertEquals((int)-120, root.valueB); Assertions.assertEquals(-120, root.valueB);
Assertions.assertEquals(null, root.valueNull); Assertions.assertEquals(null, root.valueNull);
} }
@ -237,7 +237,7 @@ public class ExmlTestIntrospectionInteger {
@Test @Test
public void testModelArrayNodeInteger() { public void testModelArrayNodeInteger() {
TestArrayNodeInteger elem = new TestArrayNodeInteger(); TestArrayNodeInteger elem = new TestArrayNodeInteger();
elem.values = new Integer[] {12, -13, 33, 78, -127};; elem.values = new Integer[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -253,11 +253,11 @@ public class ExmlTestIntrospectionInteger {
final TestArrayNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((int)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((int)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((int)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((int)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((int)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
public class TestListNodeInteger { public class TestListNodeInteger {
@ -266,7 +266,7 @@ public class ExmlTestIntrospectionInteger {
@Test @Test
public void testModelListNodeInteger() { public void testModelListNodeInteger() {
TestListNodeInteger elem = new TestListNodeInteger(); TestListNodeInteger elem = new TestListNodeInteger();
elem.values = List.of((int)12, (int)-13, (int)33, (int)78, (int)-127); elem.values = List.of(12, -13, 33, 78, -127);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -282,11 +282,11 @@ public class ExmlTestIntrospectionInteger {
final TestListNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestListNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.values.size()); Assertions.assertEquals(5, root.values.size());
Assertions.assertEquals((int)12, root.values.get(0)); Assertions.assertEquals(12, root.values.get(0));
Assertions.assertEquals((int)-13, root.values.get(1)); Assertions.assertEquals(-13, root.values.get(1));
Assertions.assertEquals((int)33, root.values.get(2)); Assertions.assertEquals(33, root.values.get(2));
Assertions.assertEquals((int)78, root.values.get(3)); Assertions.assertEquals(78, root.values.get(3));
Assertions.assertEquals((int)-127, root.values.get(4)); Assertions.assertEquals(-127, root.values.get(4));
} }
@ -294,19 +294,19 @@ public class ExmlTestIntrospectionInteger {
private Integer valueA; private Integer valueA;
private Integer valueB; private Integer valueB;
private Integer valueNull; private Integer valueNull;
public Integer isValueA() { public Integer getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Integer valueA) { public void setValueA(final Integer valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Integer isValueB() { public Integer getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Integer valueB) { public void setValueB(final Integer valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Integer isValueNull() { public Integer getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Integer valueNull) { public void setValueNull(final Integer valueNull) {
@ -317,8 +317,8 @@ public class ExmlTestIntrospectionInteger {
@Test @Test
public void testModelNodeIntegerFunc() { public void testModelNodeIntegerFunc() {
TestNodeIntegerFunc elem = new TestNodeIntegerFunc(); TestNodeIntegerFunc elem = new TestNodeIntegerFunc();
elem.setValueA((int)54); elem.setValueA(54);
elem.setValueB((int)-68); elem.setValueB(-68);
elem.setValueNull(null); elem.setValueNull(null);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -331,9 +331,9 @@ public class ExmlTestIntrospectionInteger {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)54, root.isValueA()); Assertions.assertEquals(54, root.getValueA());
Assertions.assertEquals((int)-68, root.isValueB()); Assertions.assertEquals(-68, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
public class TestArrayNodeIntegerFunc { public class TestArrayNodeIntegerFunc {
@ -367,11 +367,11 @@ public class ExmlTestIntrospectionInteger {
final TestArrayNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((int)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((int)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((int)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((int)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((int)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
// Note this is set in static to test an other part of code... // Note this is set in static to test an other part of code...
@ -389,7 +389,7 @@ public class ExmlTestIntrospectionInteger {
@Test @Test
public void testModelListNodeIntegerFunc() { public void testModelListNodeIntegerFunc() {
TestListNodeIntegerFunc elem = new TestListNodeIntegerFunc(); TestListNodeIntegerFunc elem = new TestListNodeIntegerFunc();
elem.setValues(List.of((int)12, (int)-13, (int)33, (int)78, (int)-127)); elem.setValues(List.of(12, -13, 33, 78, -127));
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -405,11 +405,11 @@ public class ExmlTestIntrospectionInteger {
final TestListNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestListNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.getValues().size()); Assertions.assertEquals(5, root.getValues().size());
Assertions.assertEquals((int)12, root.getValues().get(0)); Assertions.assertEquals(12, root.getValues().get(0));
Assertions.assertEquals((int)-13, root.getValues().get(1)); Assertions.assertEquals(-13, root.getValues().get(1));
Assertions.assertEquals((int)33, root.getValues().get(2)); Assertions.assertEquals(33, root.getValues().get(2));
Assertions.assertEquals((int)78, root.getValues().get(3)); Assertions.assertEquals(78, root.getValues().get(3));
Assertions.assertEquals((int)-127, root.getValues().get(4)); Assertions.assertEquals(-127, root.getValues().get(4));
} }
} }

View File

@ -5,8 +5,6 @@
*/ */
package test.atriasoft.exml; package test.atriasoft.exml;
import java.util.List;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlDefaultAttibute;
@ -29,8 +27,8 @@ public class ExmlTestIntrospectionIntegerNative {
@Test @Test
public void testModelIntegerNative() { public void testModelIntegerNative() {
TestIntegerNative elem = new TestIntegerNative(); TestIntegerNative elem = new TestIntegerNative();
elem.valueA = (int)12; elem.valueA = 12;
elem.valueB = (int)-13; elem.valueB = -13;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -39,8 +37,8 @@ public class ExmlTestIntrospectionIntegerNative {
Assertions.assertEquals("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
final TestIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)12, root.valueA); Assertions.assertEquals(12, root.valueA);
Assertions.assertEquals((int)-13, root.valueB); Assertions.assertEquals(-13, root.valueB);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -60,24 +58,24 @@ public class ExmlTestIntrospectionIntegerNative {
final TestArrayIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((int)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((int)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((int)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((int)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((int)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
@XmlDefaultAttibute @XmlDefaultAttibute
public class TestintFunc { public class TestintFunc {
private int valueA; private int valueA;
private int valueB; private int valueB;
public int isValueA() { public int getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final int valueA) { public void setValueA(final int valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public int isValueB() { public int getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final int valueB) { public void setValueB(final int valueB) {
@ -88,8 +86,8 @@ public class ExmlTestIntrospectionIntegerNative {
@Test @Test
public void testModelIntegerFunc() { public void testModelIntegerFunc() {
TestintFunc elem = new TestintFunc(); TestintFunc elem = new TestintFunc();
elem.setValueA((int)-55); elem.setValueA(-55);
elem.setValueB((int)57); elem.setValueB(57);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -98,8 +96,8 @@ public class ExmlTestIntrospectionIntegerNative {
Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
final TestintFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestintFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestintFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestintFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)-55, root.isValueA()); Assertions.assertEquals(-55, root.getValueA());
Assertions.assertEquals((int)57, root.isValueB()); Assertions.assertEquals(57, root.getValueB());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -128,11 +126,11 @@ public class ExmlTestIntrospectionIntegerNative {
final TestArrayIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((int)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((int)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((int)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((int)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((int)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
public class TestNodeIntegerNative { public class TestNodeIntegerNative {
@ -142,8 +140,8 @@ public class ExmlTestIntrospectionIntegerNative {
@Test @Test
public void testModelNodeIntegerNative() { public void testModelNodeIntegerNative() {
TestNodeIntegerNative elem = new TestNodeIntegerNative(); TestNodeIntegerNative elem = new TestNodeIntegerNative();
elem.valueA = (int)11; elem.valueA = 11;
elem.valueB = (int)-120; elem.valueB = -120;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -155,8 +153,8 @@ public class ExmlTestIntrospectionIntegerNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestNodeIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)11, root.valueA); Assertions.assertEquals(11, root.valueA);
Assertions.assertEquals((int)-120, root.valueB); Assertions.assertEquals(-120, root.valueB);
} }
public class TestArrayNodeIntegerNative { public class TestArrayNodeIntegerNative {
@ -165,7 +163,7 @@ public class ExmlTestIntrospectionIntegerNative {
@Test @Test
public void testModelArrayNodeintNative() { public void testModelArrayNodeintNative() {
TestArrayNodeIntegerNative elem = new TestArrayNodeIntegerNative(); TestArrayNodeIntegerNative elem = new TestArrayNodeIntegerNative();
elem.values = new int[] {12, -13, 33, 78, -127};; elem.values = new int[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -181,23 +179,23 @@ public class ExmlTestIntrospectionIntegerNative {
final TestArrayNodeIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayNodeIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.values.length); Assertions.assertEquals(5, root.values.length);
Assertions.assertEquals((int)12, root.values[0]); Assertions.assertEquals(12, root.values[0]);
Assertions.assertEquals((int)-13, root.values[1]); Assertions.assertEquals(-13, root.values[1]);
Assertions.assertEquals((int)33, root.values[2]); Assertions.assertEquals(33, root.values[2]);
Assertions.assertEquals((int)78, root.values[3]); Assertions.assertEquals(78, root.values[3]);
Assertions.assertEquals((int)-127, root.values[4]); Assertions.assertEquals(-127, root.values[4]);
} }
public class TestNodeintFunc { public class TestNodeintFunc {
private int valueA; private int valueA;
private int valueB; private int valueB;
public int isValueA() { public int getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final int valueA) { public void setValueA(final int valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public int isValueB() { public int getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final int valueB) { public void setValueB(final int valueB) {
@ -208,8 +206,8 @@ public class ExmlTestIntrospectionIntegerNative {
@Test @Test
public void testModelNodeIntegerFunc() { public void testModelNodeIntegerFunc() {
TestNodeintFunc elem = new TestNodeintFunc(); TestNodeintFunc elem = new TestNodeintFunc();
elem.setValueA((int)54); elem.setValueA(54);
elem.setValueB((int)-68); elem.setValueB(-68);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder));
@ -221,8 +219,8 @@ public class ExmlTestIntrospectionIntegerNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeintFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeintFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestNodeintFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeintFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals((int)54, root.isValueA()); Assertions.assertEquals(54, root.getValueA());
Assertions.assertEquals((int)-68, root.isValueB()); Assertions.assertEquals(-68, root.getValueB());
} }
public class TestArrayNodeIntegerFunc { public class TestArrayNodeIntegerFunc {
@ -256,11 +254,11 @@ public class ExmlTestIntrospectionIntegerNative {
final TestArrayNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME)); final TestArrayNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
Assertions.assertEquals(5, root.getValues().length); Assertions.assertEquals(5, root.getValues().length);
Assertions.assertEquals((int)12, root.getValues()[0]); Assertions.assertEquals(12, root.getValues()[0]);
Assertions.assertEquals((int)-13, root.getValues()[1]); Assertions.assertEquals(-13, root.getValues()[1]);
Assertions.assertEquals((int)33, root.getValues()[2]); Assertions.assertEquals(33, root.getValues()[2]);
Assertions.assertEquals((int)78, root.getValues()[3]); Assertions.assertEquals(78, root.getValues()[3]);
Assertions.assertEquals((int)-127, root.getValues()[4]); Assertions.assertEquals(-127, root.getValues()[4]);
} }
} }

View File

@ -100,19 +100,19 @@ public class ExmlTestIntrospectionShort {
private Short valueA; private Short valueA;
private Short valueB; private Short valueB;
private Short valueNull; private Short valueNull;
public Short isValueA() { public Short getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Short valueA) { public void setValueA(final Short valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Short isValueB() { public Short getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Short valueB) { public void setValueB(final Short valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Short isValueNull() { public Short getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Short valueNull) { public void setValueNull(final Short valueNull) {
@ -134,9 +134,9 @@ public class ExmlTestIntrospectionShort {
Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
final TestShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME)); final TestShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
Assertions.assertEquals((short)-55, root.isValueA()); Assertions.assertEquals((short)-55, root.getValueA());
Assertions.assertEquals((short)57, root.isValueB()); Assertions.assertEquals((short)57, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -237,7 +237,7 @@ public class ExmlTestIntrospectionShort {
@Test @Test
public void testModelArrayNodeShort() { public void testModelArrayNodeShort() {
TestArrayNodeShort elem = new TestArrayNodeShort(); TestArrayNodeShort elem = new TestArrayNodeShort();
elem.values = new Short[] {12, -13, 33, 78, -127};; elem.values = new Short[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionShort.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionShort.NODE_NAME, builder));
@ -294,19 +294,19 @@ public class ExmlTestIntrospectionShort {
private Short valueA; private Short valueA;
private Short valueB; private Short valueB;
private Short valueNull; private Short valueNull;
public Short isValueA() { public Short getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final Short valueA) { public void setValueA(final Short valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public Short isValueB() { public Short getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final Short valueB) { public void setValueB(final Short valueB) {
this.valueB = valueB; this.valueB = valueB;
} }
public Short isValueNull() { public Short getValueNull() {
return this.valueNull; return this.valueNull;
} }
public void setValueNull(final Short valueNull) { public void setValueNull(final Short valueNull) {
@ -331,9 +331,9 @@ public class ExmlTestIntrospectionShort {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME)); final TestNodeShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
Assertions.assertEquals((short)54, root.isValueA()); Assertions.assertEquals((short)54, root.getValueA());
Assertions.assertEquals((short)-68, root.isValueB()); Assertions.assertEquals((short)-68, root.getValueB());
Assertions.assertEquals(null, root.isValueNull()); Assertions.assertEquals(null, root.getValueNull());
} }
public class TestArrayNodeShortFunc { public class TestArrayNodeShortFunc {

View File

@ -5,8 +5,6 @@
*/ */
package test.atriasoft.exml; package test.atriasoft.exml;
import java.util.List;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlDefaultAttibute;
@ -71,13 +69,13 @@ public class ExmlTestIntrospectionShortNative {
public class TestshortFunc { public class TestshortFunc {
private short valueA; private short valueA;
private short valueB; private short valueB;
public short isValueA() { public short getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final short valueA) { public void setValueA(final short valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public short isValueB() { public short getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final short valueB) { public void setValueB(final short valueB) {
@ -98,8 +96,8 @@ public class ExmlTestIntrospectionShortNative {
Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest); Assertions.assertEquals("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
final TestshortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestshortFunc.class, ExmlTestIntrospectionShort.NODE_NAME)); final TestshortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestshortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
Assertions.assertEquals((short)-55, root.isValueA()); Assertions.assertEquals((short)-55, root.getValueA());
Assertions.assertEquals((short)57, root.isValueB()); Assertions.assertEquals((short)57, root.getValueB());
} }
@XmlDefaultAttibute @XmlDefaultAttibute
@ -165,7 +163,7 @@ public class ExmlTestIntrospectionShortNative {
@Test @Test
public void testModelArrayNodeshortNative() { public void testModelArrayNodeshortNative() {
TestArrayNodeShortNative elem = new TestArrayNodeShortNative(); TestArrayNodeShortNative elem = new TestArrayNodeShortNative();
elem.values = new short[] {12, -13, 33, 78, -127};; elem.values = new short[] {12, -13, 33, 78, -127};
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionShort.NODE_NAME, builder)); Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionShort.NODE_NAME, builder));
@ -191,13 +189,13 @@ public class ExmlTestIntrospectionShortNative {
public class TestNodeshortFunc { public class TestNodeshortFunc {
private short valueA; private short valueA;
private short valueB; private short valueB;
public short isValueA() { public short getValueA() {
return this.valueA; return this.valueA;
} }
public void setValueA(final short valueA) { public void setValueA(final short valueA) {
this.valueA = valueA; this.valueA = valueA;
} }
public short isValueB() { public short getValueB() {
return this.valueB; return this.valueB;
} }
public void setValueB(final short valueB) { public void setValueB(final short valueB) {
@ -221,8 +219,8 @@ public class ExmlTestIntrospectionShortNative {
+ "</elem>", dataTest); + "</elem>", dataTest);
final TestNodeshortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeshortFunc.class, ExmlTestIntrospectionShort.NODE_NAME)); final TestNodeshortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeshortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
Assertions.assertEquals((short)54, root.isValueA()); Assertions.assertEquals((short)54, root.getValueA());
Assertions.assertEquals((short)-68, root.isValueB()); Assertions.assertEquals((short)-68, root.getValueB());
} }
public class TestArrayNodeShortFunc { public class TestArrayNodeShortFunc {