/**
* Test Model Tree. Emulates retrieving model tree for aspect
*/
@Test
public void childWithSameIds() {
AspectSubTreeNode model = new AspectSubTreeNode(
AspectTreeType.MODEL_TREE);
model.setModified(true);
CompositeNode first = new CompositeNode("One");
first.setId("One_1");
CompositeNode second = new CompositeNode("One");
second.setId("One_2");
DynamicsSpecificationNode dynamics = new DynamicsSpecificationNode(
"Dynamics");
PhysicalQuantity value = new PhysicalQuantity();
value.setScalingFactor("10");
value.setUnit("ms");
value.setValue(new DoubleValue(10));
dynamics.setInitialConditions(value);
FunctionNode function = new FunctionNode("Function");
function.setExpression("y=x+2");
List<String> argumentsF = new ArrayList<String>();
argumentsF.add("1");
argumentsF.add("2");
function.setArgument(argumentsF);
dynamics.setDynamics(function);
ParameterSpecificationNode parameter = new ParameterSpecificationNode(
"Parameter");
ParameterSpecificationNode parameter2 = new ParameterSpecificationNode(
"Parameter");
PhysicalQuantity value1 = new PhysicalQuantity();
value1.setScalingFactor("10");
value1.setUnit("ms");
value1.setValue(new DoubleValue(10));
parameter.setValue(value1);
parameter2.setValue(value1);
FunctionNode functionNode = new FunctionNode("FunctionNode");
functionNode.setExpression("y=x^2");
List<String> arguments = new ArrayList<String>();
arguments.add("1");
functionNode.setArgument(arguments);
first.addChild(parameter);
first.addChild(dynamics);
first.addChild(functionNode);
second.addChild(parameter2);
model.addChild(first);
model.addChild(second);
SerializeTreeVisitor visitor = new SerializeTreeVisitor();
model.apply(visitor);
String serialized = "{" + visitor.getSerializedTree() + "}";
System.out.println(serialized);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonParser jp = new JsonParser();