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");
}
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");
}
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");
}
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);
}
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");
}
Aggregations