Search in sources :

Example 31 with BJSON

use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.

the class BJSONValueTest method testUpdateJson.

@Test
public void testUpdateJson() {
    BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateJson");
    Assert.assertTrue(returns[0] instanceof BJSON);
    BJSON json = ((BJSON) returns[0]);
    Assert.assertEquals(json.toString(), "{\"fname\":\"Supun\",\"address\":{\"country\":\"SriLanka\"}}");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 32 with BJSON

use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.

the class BJSONValueTest method testStringAsJsonVal.

@Test(description = "Test initializing json with a string")
public void testStringAsJsonVal() {
    BValue[] returns = BRunUtil.invoke(compileResult, "testStringAsJsonVal");
    Assert.assertTrue(returns[0] instanceof BJSON);
    BJSON person = ((BJSON) returns[0]);
    Assert.assertEquals(person.value().asText(), "Supun");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 33 with BJSON

use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.

the class BJSONValueTest method testJsonStringToJson.

@Test
public void testJsonStringToJson() {
    BValue[] returns = BRunUtil.invoke(compileResult, "testJsonStringToJson");
    Assert.assertTrue(returns[0] instanceof BJSON);
    BJSON json = ((BJSON) returns[0]);
    Assert.assertEquals(json.toString(), "{\"name\", \"supun\"}");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 34 with BJSON

use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.

the class BJSONValueTest method testUpdateBooleanInArray.

@Test
public void testUpdateBooleanInArray() {
    BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateBooleanInArray");
    Assert.assertTrue(returns[0] instanceof BJSON);
    BJSON json = ((BJSON) returns[0]);
    Assert.assertEquals(json.toString(), "[\"a\",true,\"c\"]");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 35 with BJSON

use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.

the class BJSONValueTest method testUpdateFloatInArray.

@Test
public void testUpdateFloatInArray() {
    BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateFloatInArray");
    Assert.assertTrue(returns[0] instanceof BJSON);
    BJSON json = ((BJSON) returns[0]);
    Assert.assertEquals(json.toString(), "[\"a\",4.72,\"c\"]");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Aggregations

BJSON (org.ballerinalang.model.values.BJSON)255 Test (org.testng.annotations.Test)214 BValue (org.ballerinalang.model.values.BValue)113 HTTPTestRequest (org.ballerinalang.test.services.testutils.HTTPTestRequest)108 HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)108 HttpMessageDataStreamer (org.wso2.transport.http.netty.message.HttpMessageDataStreamer)104 BString (org.ballerinalang.model.values.BString)85 BXMLItem (org.ballerinalang.model.values.BXMLItem)37 BStruct (org.ballerinalang.model.values.BStruct)23 BXML (org.ballerinalang.model.values.BXML)17 OMNode (org.apache.axiom.om.OMNode)13 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)13 BMap (org.ballerinalang.model.values.BMap)11 JsonNode (org.ballerinalang.model.util.JsonNode)10 BNewArray (org.ballerinalang.model.values.BNewArray)9 BIntArray (org.ballerinalang.model.values.BIntArray)8 BRefType (org.ballerinalang.model.values.BRefType)8 ArrayList (java.util.ArrayList)7 BStringArray (org.ballerinalang.model.values.BStringArray)7 BStructType (org.ballerinalang.model.types.BStructType)6