use of org.ballerinalang.model.values.BValue 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.BValue in project ballerina by ballerina-lang.
the class SQLActionsTest method testQueryParameters.
@Test(groups = "ConnectorTest")
public void testQueryParameters() {
BValue[] returns = BRunUtil.invoke(result, "testQueryParameters");
BString retValue = (BString) returns[0];
final String expected = "Peter";
Assert.assertEquals(retValue.stringValue(), expected);
}
use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.
the class SQLActionsTest method testStructOutParameters.
@Test(groups = "ConnectorTest")
public void testStructOutParameters() {
BValue[] returns = BRunUtil.invoke(result, "testStructOutParameters");
BString retValue = (BString) returns[0];
String expected = "10";
Assert.assertEquals(retValue.stringValue(), expected);
}
use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.
the class SQLActionsTest method testArrayofQueryParameters.
@Test(groups = "ConnectorTest")
public void testArrayofQueryParameters() {
BValue[] returns = BRunUtil.invoke(result, "testArrayofQueryParameters");
BString retValue = (BString) returns[0];
final String expected = "Peter";
Assert.assertEquals(retValue.stringValue(), expected);
}
use of org.ballerinalang.model.values.BValue 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);
}
Aggregations