use of org.ballerinalang.model.values.BXMLItem in project ballerina by ballerina-lang.
the class JSONTest method testToXMLKeyValue.
@Test(description = "Convert json object with key value")
public void testToXMLKeyValue() {
BValue[] args = { new BJSON(jsonToXML15) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXML", args);
Assert.assertTrue(returns[0] instanceof BXML);
OMNode returnElement = ((BXMLItem) returns[0]).value();
Assert.assertEquals(returnElement.toString(), "<key>value</key>");
}
use of org.ballerinalang.model.values.BXMLItem in project ballerina by ballerina-lang.
the class JSONTest method testToXMLSimpleArrayObject.
@Test(description = "Convert json object with simple array")
public void testToXMLSimpleArrayObject() {
BValue[] args = { new BJSON(jsonToXML4) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXML", args);
Assert.assertTrue(returns[0] instanceof BXML);
OMNode returnElement = ((BXMLItem) returns[0]).value();
Assert.assertEquals(returnElement.toString(), "<books><item>book1</item><item>book2</item><item>book3" + "</item></books>");
}
use of org.ballerinalang.model.values.BXMLItem in project ballerina by ballerina-lang.
the class JSONTest method testToXMLAttributes.
@Test(description = "Convert a simple json object with attributes")
public void testToXMLAttributes() {
BValue[] args = { new BJSON(jsonToXML12) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXML", args);
Assert.assertTrue(returns[0] instanceof BXML);
OMNode returnElement = ((BXMLItem) returns[0]).value();
Assert.assertEquals(returnElement.toString(), "<info id=\"100\"><name>John</name><age>30</age><car>honda</car>" + "</info>");
}
use of org.ballerinalang.model.values.BXMLItem in project ballerina by ballerina-lang.
the class JSONTest method testToXMLComplexObject.
@Test(description = "Convert complex json object in to xml")
public void testToXMLComplexObject() {
BValue[] args = { new BJSON(jsonToXML1) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXML", args);
Assert.assertTrue(returns[0] instanceof BXML);
OMNode returnElement = ((BXMLItem) returns[0]).value();
Assert.assertEquals(returnElement.toString(), "<bookStore><storeName>foo" + "</storeName><postalCode>94</postalCode><isOpen>true</isOpen><address><street>PalmGrove</street>" + "<city>Colombo</city><country>SriLanka</country></address><codes><item>4</item><item>8</item>" + "<item>9</item></codes></bookStore>");
}
use of org.ballerinalang.model.values.BXMLItem in project ballerina by ballerina-lang.
the class JSONTest method testToXMLKeyWithAttributeAndValue.
@Test(description = "Convert json object with attribute and value")
public void testToXMLKeyWithAttributeAndValue() {
BValue[] args = { new BJSON(jsonToXML19) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXML", args);
Assert.assertTrue(returns[0] instanceof BXML);
OMNode returnElement = ((BXMLItem) returns[0]).value();
Assert.assertEquals(returnElement.toString(), "<foo key=\"value\"><test>hello</test></foo>");
}
Aggregations