Search in sources :

Example 1 with JaqyInterpreter

use of com.teradata.jaqy.JaqyInterpreter in project jaqy by Teradata.

the class S3PathHandlerTest method test2.

@Test(expected = IllegalArgumentException.class)
public void test2() throws Exception {
    Globals globals = new Globals();
    JaqyInterpreter interpreter = new JaqyInterpreter(globals, null, null);
    S3PathHandler handler = new S3PathHandler();
    handler.getPath("s3", interpreter);
}
Also used : Globals(com.teradata.jaqy.Globals) JaqyInterpreter(com.teradata.jaqy.JaqyInterpreter) Test(org.junit.Test)

Example 2 with JaqyInterpreter

use of com.teradata.jaqy.JaqyInterpreter in project jaqy by Teradata.

the class WhereParserTest method test3.

@Test
public void test3() throws Exception {
    Globals globals = new Globals();
    JaqyInterpreter interpreter = new JaqyInterpreter(globals, null, null);
    VariableManager vm = interpreter.getVariableManager();
    ExpNode exp;
    exp = WhereParser.getExp("1 is NULL");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 is not NULL");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
}
Also used : Globals(com.teradata.jaqy.Globals) VariableManager(com.teradata.jaqy.VariableManager) JaqyInterpreter(com.teradata.jaqy.JaqyInterpreter) ExpNode(com.teradata.jaqy.utils.exp.ExpNode) Test(org.junit.Test)

Example 3 with JaqyInterpreter

use of com.teradata.jaqy.JaqyInterpreter in project jaqy by Teradata.

the class WhereParserTest method test2.

@Test
public void test2() throws Exception {
    Globals globals = new Globals();
    JaqyInterpreter interpreter = new JaqyInterpreter(globals, null, null);
    VariableManager vm = interpreter.getVariableManager();
    ExpNode exp;
    exp = WhereParser.getExp("1 < any (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 < some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 <= some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 = some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 <> some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 > some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 >= some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 < ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 <= ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 = ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 <> ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 > ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 >= ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 IN (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("'abc' like 'a'");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("'abc' like 'a$'");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("'abc' like 'a.*'");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
}
Also used : Globals(com.teradata.jaqy.Globals) VariableManager(com.teradata.jaqy.VariableManager) JaqyInterpreter(com.teradata.jaqy.JaqyInterpreter) ExpNode(com.teradata.jaqy.utils.exp.ExpNode) Test(org.junit.Test)

Example 4 with JaqyInterpreter

use of com.teradata.jaqy.JaqyInterpreter in project jaqy by Teradata.

the class WhereParserTest method test4.

@Test
public void test4() throws Exception {
    Globals globals = new Globals();
    JaqyInterpreter interpreter = new JaqyInterpreter(globals, null, null);
    VariableManager vm = interpreter.getVariableManager();
    ExpNode exp;
    exp = WhereParser.getExp("1 > 0 AND 2 < 4");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 > 0 OR 4 < 2");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
}
Also used : Globals(com.teradata.jaqy.Globals) VariableManager(com.teradata.jaqy.VariableManager) JaqyInterpreter(com.teradata.jaqy.JaqyInterpreter) ExpNode(com.teradata.jaqy.utils.exp.ExpNode) Test(org.junit.Test)

Example 5 with JaqyInterpreter

use of com.teradata.jaqy.JaqyInterpreter in project jaqy by Teradata.

the class WhereParserTest method test1.

@Test
public void test1() throws Exception {
    Globals globals = new Globals();
    JaqyInterpreter interpreter = new JaqyInterpreter(globals, null, null);
    VariableManager vm = interpreter.getVariableManager();
    ExpNode exp;
    exp = WhereParser.getExp("1");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Integer(1), exp.get());
    exp = WhereParser.getExp("1--1");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Integer(2), exp.get());
    exp = WhereParser.getExp("1-1");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Integer(0), exp.get());
    exp = WhereParser.getExp("1 + 2 * 3 % 5 * 2 / 1");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Integer(3), exp.get());
    exp = WhereParser.getExp("-1 + 2 * 3 % 5 * -2.125 - 2");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Double(-5.125), exp.get());
    exp = WhereParser.getExp("4 & 8 | 3");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Integer(3), exp.get());
    exp = WhereParser.getExp("1 ^ 2");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Integer(3), exp.get());
    exp = WhereParser.getExp("~2");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Integer(-3), exp.get());
    exp = WhereParser.getExp("'abc'");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals("abc", exp.get());
    exp = WhereParser.getExp("1 < 2");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 <= (2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 = 2");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 <> 2");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 > 2");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 >= 2");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("Math.sqrt(4)");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(new Double(2), exp.get());
    exp = WhereParser.getExp("Math.random()");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals(Double.class, exp.get().getClass());
    exp = WhereParser.getExp("1 || 2");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals("12", exp.get());
    exp = WhereParser.getExp("'abc' || 2");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals("abc2", exp.get());
    exp = WhereParser.getExp("'abc' || 1 || 2");
    exp.bind(null, vm, interpreter);
    Assert.assertEquals("abc12", exp.get());
}
Also used : Globals(com.teradata.jaqy.Globals) VariableManager(com.teradata.jaqy.VariableManager) JaqyInterpreter(com.teradata.jaqy.JaqyInterpreter) ExpNode(com.teradata.jaqy.utils.exp.ExpNode) Test(org.junit.Test)

Aggregations

Globals (com.teradata.jaqy.Globals)6 JaqyInterpreter (com.teradata.jaqy.JaqyInterpreter)6 Test (org.junit.Test)6 VariableManager (com.teradata.jaqy.VariableManager)4 ExpNode (com.teradata.jaqy.utils.exp.ExpNode)4 ActorSystem (akka.actor.ActorSystem)1 AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)1 S3Mock (io.findify.s3mock.S3Mock)1 InMemoryProvider (io.findify.s3mock.provider.InMemoryProvider)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1