Search in sources :

Example 26 with BString

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

the class FileBasedUserstoreTest method testReadGroupsOfUser.

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

Example 27 with BString

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

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

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

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

Aggregations

BString (org.ballerinalang.model.values.BString)418 BValue (org.ballerinalang.model.values.BValue)339 Test (org.testng.annotations.Test)321 BInteger (org.ballerinalang.model.values.BInteger)77 BStruct (org.ballerinalang.model.values.BStruct)76 BMap (org.ballerinalang.model.values.BMap)37 BBoolean (org.ballerinalang.model.values.BBoolean)36 BFloat (org.ballerinalang.model.values.BFloat)34 BJSON (org.ballerinalang.model.values.BJSON)28 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)21 BRefValueArray (org.ballerinalang.model.values.BRefValueArray)18 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)11 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)11 CompileResult (org.ballerinalang.launcher.util.CompileResult)11 BBlob (org.ballerinalang.model.values.BBlob)11 BStringArray (org.ballerinalang.model.values.BStringArray)11 BType (org.ballerinalang.model.types.BType)10 BIntArray (org.ballerinalang.model.values.BIntArray)9 BRefType (org.ballerinalang.model.values.BRefType)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7