Search in sources :

Example 96 with BValue

use of org.ballerinalang.model.values.BValue 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 97 with BValue

use of org.ballerinalang.model.values.BValue 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 98 with BValue

use of org.ballerinalang.model.values.BValue 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)

Example 99 with BValue

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

the class BJSONValueTest method testUpdateJsonInArray.

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

Example 100 with BValue

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

the class BJSONValueTest method testUpdateString.

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

Aggregations

BValue (org.ballerinalang.model.values.BValue)1043 Test (org.testng.annotations.Test)923 BString (org.ballerinalang.model.values.BString)437 BInteger (org.ballerinalang.model.values.BInteger)323 BStruct (org.ballerinalang.model.values.BStruct)188 BFloat (org.ballerinalang.model.values.BFloat)118 BJSON (org.ballerinalang.model.values.BJSON)112 BBoolean (org.ballerinalang.model.values.BBoolean)79 CompileResult (org.ballerinalang.launcher.util.CompileResult)60 BRefValueArray (org.ballerinalang.model.values.BRefValueArray)45 BMap (org.ballerinalang.model.values.BMap)43 BXMLItem (org.ballerinalang.model.values.BXMLItem)42 BXML (org.ballerinalang.model.values.BXML)40 BStringArray (org.ballerinalang.model.values.BStringArray)30 BIntArray (org.ballerinalang.model.values.BIntArray)25 BBlob (org.ballerinalang.model.values.BBlob)23 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)19 BeforeTest (org.testng.annotations.BeforeTest)19 HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)19 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)16