use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class SQLActionsTest method testSelectIntFloatData.
@Test(groups = "ConnectorTest for int float types")
public void testSelectIntFloatData() {
BValue[] returns = BRunUtil.invoke(result, "testSelectIntFloatData");
Assert.assertEquals(returns.length, 4);
Assert.assertSame(returns[0].getClass(), BInteger.class);
Assert.assertSame(returns[1].getClass(), BInteger.class);
Assert.assertSame(returns[2].getClass(), BFloat.class);
Assert.assertSame(returns[3].getClass(), BFloat.class);
BInteger intVal = (BInteger) returns[0];
BInteger longVal = (BInteger) returns[1];
BFloat floatVal = (BFloat) returns[2];
BFloat doubleVal = (BFloat) returns[3];
long intExpected = 10;
long longExpected = 9223372036854774807L;
double floatExpected = 123.34;
double doubleExpected = 2139095039;
Assert.assertEquals(intVal.intValue(), intExpected);
Assert.assertEquals(longVal.intValue(), longExpected);
Assert.assertEquals(floatVal.floatValue(), floatExpected, DELTA);
Assert.assertEquals(doubleVal.floatValue(), doubleExpected);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class SQLActionsTest method testArrayInParameters.
@Test(groups = "ConnectorTest")
public void testArrayInParameters() {
BValue[] returns = BRunUtil.invoke(result, "testArrayInParameters");
BInteger retValue = (BInteger) returns[0];
Assert.assertEquals(retValue.intValue(), 1);
Assert.assertTrue(returns[1] instanceof BIntArray);
BIntArray intArray = (BIntArray) returns[1];
Assert.assertEquals(intArray.get(0), 1);
Assert.assertTrue(returns[2] instanceof BIntArray);
BIntArray longArray = (BIntArray) returns[2];
Assert.assertEquals(longArray.get(0), 1503383034226L);
Assert.assertEquals(longArray.get(1), 1503383034224L);
Assert.assertEquals(longArray.get(2), 1503383034225L);
Assert.assertTrue(returns[3] instanceof BFloatArray);
BFloatArray doubleArray = (BFloatArray) returns[3];
Assert.assertEquals(doubleArray.get(0), 1503383034226.23D);
Assert.assertEquals(doubleArray.get(1), 1503383034224.43D);
Assert.assertEquals(doubleArray.get(2), 1503383034225.123D);
Assert.assertTrue(returns[4] instanceof BStringArray);
BStringArray stringArray = (BStringArray) returns[4];
Assert.assertEquals(stringArray.get(0), "Hello");
Assert.assertEquals(stringArray.get(1), "Ballerina");
Assert.assertTrue(returns[5] instanceof BBooleanArray);
BBooleanArray booleanArray = (BBooleanArray) returns[5];
Assert.assertEquals(booleanArray.get(0), 1);
Assert.assertEquals(booleanArray.get(1), 0);
Assert.assertEquals(booleanArray.get(2), 1);
Assert.assertTrue(returns[6] instanceof BFloatArray);
BFloatArray floatArray = (BFloatArray) returns[6];
Assert.assertEquals(floatArray.get(0), 245.23);
Assert.assertEquals(floatArray.get(1), 5559.49);
Assert.assertEquals(floatArray.get(2), 8796.123);
}
use of org.ballerinalang.model.values.BInteger 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.BInteger 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");
}
use of org.ballerinalang.model.values.BInteger 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);
}
Aggregations