use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateNestedElement.
// @Test
// public void testJsonArrayWithVariable() {
// BValue[] returns = BLangFunctions.invoke(bLangProgram, "testJsonArrayWithVariable");
// Assert.assertTrue(returns[0] instanceof BJSON);
// Assert.assertEquals(returns[0].stringValue(), "[\"a\",\"b\",\"c\",{\"name\":\"supun\"}]");
// }
@Test
public void testUpdateNestedElement() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateNestedElement");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"details\":{\"fname\":\"Supun\",\"lname\":\"Setunga\"}}");
}
use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateJsonArrayInArray.
@Test
public void testUpdateJsonArrayInArray() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateJsonArrayInArray");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "[\"a\",[1,2,3],\"c\"]");
}
use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.
the class BJSONValueTest method testAddString.
@Test
public void testAddString() {
BValue[] returns = BRunUtil.invoke(compileResult, "testAddString");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"fname\":\"Supun\",\"lname\":\"Setunga\"}");
}
use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.
the class BJSONValueTest method testIntAsJsonVal.
@Test(description = "Test initializing json with an integer")
public void testIntAsJsonVal() {
BValue[] returns = BRunUtil.invoke(compileResult, "testIntAsJsonVal");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON person = ((BJSON) returns[0]);
Assert.assertEquals(person.value().longValue(), 5);
}
use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateInt.
@Test
public void testUpdateInt() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateInt");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"fname\":\"Supun\",\"age\":25}");
}
Aggregations