Search in sources :

Example 6 with BBoolean

use of org.ballerinalang.model.values.BBoolean in project carbon-apimgt by wso2.

the class MapPutAndGetTestCase method testMapOperations.

@Test
public void testMapOperations() {
    // Create arguments to initiate map put
    BValue[] args = { new BString("testMapEntry"), new BString("testMapValue") };
    // Test ballerina map put and get for BString
    BValue[] returns = BLangFunctions.invokeNew(bLangProgram, "testMapPutAndGet", args);
    // Assert if map entry is BValue
    Assert.assertTrue(returns[0] instanceof BValue);
    final String expected = "testMapValue";
    // Assert if return entry matched with exact entry we put there
    Assert.assertEquals(returns[0].stringValue(), expected);
    // Test ballerina Boolean values.
    BValue[] argsBoolean = { new BString("testMapEntry"), new BBoolean(false) };
    BValue[] returnsBoolean = BLangFunctions.invokeNew(bLangProgram, "testMapPutAndGet", argsBoolean);
    Assert.assertTrue(returnsBoolean[0] instanceof BBoolean);
    // Test ballerina JSON values.
    BValue[] argsJSON = { new BString("testMapEntry"), new BJSON("{}") };
    BValue[] returnsJSON = BLangFunctions.invokeNew(bLangProgram, "testMapPutAndGet", argsJSON);
    Assert.assertTrue(returnsJSON[0] instanceof BJSON);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) BBoolean(org.ballerinalang.model.values.BBoolean) BString(org.ballerinalang.model.values.BString) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Aggregations

BBoolean (org.ballerinalang.model.values.BBoolean)6 BString (org.ballerinalang.model.values.BString)4 BValue (org.ballerinalang.model.values.BValue)3 Test (org.testng.annotations.Test)3 BJSON (org.ballerinalang.model.values.BJSON)2 BStruct (org.ballerinalang.model.values.BStruct)2 ProgramFile (org.ballerinalang.util.codegen.ProgramFile)1 APIMThreatAnalyzer (org.wso2.carbon.apimgt.ballerina.threatprotection.analyzer.APIMThreatAnalyzer)1 JSONConfig (org.wso2.carbon.apimgt.ballerina.threatprotection.configurations.JSONConfig)1 XMLConfig (org.wso2.carbon.apimgt.ballerina.threatprotection.configurations.XMLConfig)1