Search in sources :

Example 41 with BValue

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

the class PermissionStoreTest method testReadGroupsForUser.

@Test(description = "Test case for reading groups of a user")
public void testReadGroupsForUser() {
    BValue[] returns = BRunUtil.invoke(compileResult, "testReadGroupsForUser");
    Assert.assertTrue(returns != null);
    BString groups = (BString) returns[0];
    log.info("Groups for user: " + groups);
    Assert.assertNotNull(groups);
    Assert.assertEquals(groups.stringValue(), "prq,lmn");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 42 with BValue

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

the class PermissionStoreTest method testReadGroupsForScope.

@Test(description = "Test case for reading groups of a scope")
public void testReadGroupsForScope() {
    BValue[] returns = BRunUtil.invoke(compileResult, "testReadGroupsForScope");
    Assert.assertTrue(returns != null);
    BString groups = (BString) returns[0];
    log.info("Groups for scope: " + groups);
    Assert.assertNotNull(groups);
    Assert.assertEquals(groups.stringValue(), "xyz,pqr");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 43 with BValue

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

the class CachingTest method testCacheEviction3.

@Test
public void testCacheEviction3() {
    String cacheName = "userCache";
    int expiryTime = 20000;
    int capacity = 10;
    float evictionFactor = 0.2f;
    BValue[] args = new BValue[4];
    args[0] = new BString(cacheName);
    args[1] = new BInteger(expiryTime);
    args[2] = new BInteger(capacity);
    args[3] = new BFloat(evictionFactor);
    BValue[] returns = BRunUtil.invoke(compileResult, "testCacheEviction3", args);
    Assert.assertTrue(returns.length == 2);
    Assert.assertTrue(returns[0] instanceof BStringArray);
    Assert.assertEquals(((BStringArray) returns[0]).get(0), "A");
    Assert.assertEquals(((BStringArray) returns[0]).get(1), "B");
    Assert.assertEquals(((BStringArray) returns[0]).get(2), "E");
    Assert.assertEquals(((BStringArray) returns[0]).get(3), "F");
    Assert.assertEquals(((BStringArray) returns[0]).get(4), "G");
    Assert.assertEquals(((BStringArray) returns[0]).get(5), "H");
    Assert.assertEquals(((BStringArray) returns[0]).get(6), "I");
    Assert.assertEquals(((BStringArray) returns[0]).get(7), "J");
    Assert.assertEquals(((BStringArray) returns[0]).get(8), "K");
    Assert.assertEquals(((BInteger) returns[1]).intValue(), 9);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) BInteger(org.ballerinalang.model.values.BInteger) BFloat(org.ballerinalang.model.values.BFloat) BString(org.ballerinalang.model.values.BString) BStringArray(org.ballerinalang.model.values.BStringArray) Test(org.testng.annotations.Test)

Example 44 with BValue

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

the class CachingTest method testGet.

@Test
public void testGet() {
    String cacheName = "userCache";
    int expiryTime = 20000;
    int capacity = 10;
    float evictionFactor = 0.1f;
    String key = "Ballerina";
    String value = "Rocks";
    BValue[] args = new BValue[6];
    args[0] = new BString(cacheName);
    args[1] = new BInteger(expiryTime);
    args[2] = new BInteger(capacity);
    args[3] = new BFloat(evictionFactor);
    args[4] = new BString(key);
    args[5] = new BString(value);
    BValue[] returns = BRunUtil.invoke(compileResult, "testGet", args);
    Assert.assertTrue(returns.length == 2);
    Assert.assertTrue(returns[0] instanceof BInteger);
    Assert.assertTrue(returns[1] instanceof BString);
    Assert.assertEquals(((BInteger) returns[0]).intValue(), 1);
    Assert.assertEquals(returns[1].stringValue(), "Rocks");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) BInteger(org.ballerinalang.model.values.BInteger) BFloat(org.ballerinalang.model.values.BFloat) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 45 with BValue

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

the class CachingTest method testRemove.

@Test
public void testRemove() {
    String cacheName = "userCache";
    int expiryTime = 20000;
    int capacity = 10;
    float evictionFactor = 0.1f;
    String key = "Ballerina";
    String value = "Rocks";
    BValue[] args = new BValue[6];
    args[0] = new BString(cacheName);
    args[1] = new BInteger(expiryTime);
    args[2] = new BInteger(capacity);
    args[3] = new BFloat(evictionFactor);
    args[4] = new BString(key);
    args[5] = new BString(value);
    BValue[] returns = BRunUtil.invoke(compileResult, "testRemove", args);
    Assert.assertTrue(returns.length == 1);
    Assert.assertEquals(((BInteger) returns[0]).intValue(), 0);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) BInteger(org.ballerinalang.model.values.BInteger) BFloat(org.ballerinalang.model.values.BFloat) BString(org.ballerinalang.model.values.BString) 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