Package org.teiid.query.sql.symbol

Examples of org.teiid.query.sql.symbol.SearchedCaseExpression


        expr.setType(null);
        assertNull(expr.getType());
    }
   
    public void testEquals() {
        SearchedCaseExpression sc1 = example(3);
        assertTrue(sc1.equals(sc1));
        assertTrue(sc1.equals(sc1.clone()));
        assertTrue(sc1.clone().equals(sc1));
        assertTrue(sc1.equals(example(3)));
       
        SearchedCaseExpression sc2 = example(4);
       
        assertFalse(sc1.equals(sc2));
        assertFalse(sc2.equals(sc1));
       
        SearchedCaseExpression sc3 = example(3);
        sc3.setElseExpression(new ElementSymbol("y")); //$NON-NLS-1$
        assertFalse(sc1.equals(sc3));
        assertFalse(sc3.equals(sc1));
    }
View Full Code Here


        thens.add(new Constant(new Integer(0)));
        whens.add(new CompareCriteria(y, CompareCriteria.EQ, new Constant(new Integer(1))));
        thens.add(new Constant(new Integer(1)));
        whens.add(new CompareCriteria(y, CompareCriteria.EQ, new Constant(new Integer(2))));
        thens.add(new Constant(new Integer(2)));
        SearchedCaseExpression mapped = new SearchedCaseExpression(whens, thens);
        mapped.setElseExpression(new Constant(new Integer(9999)));
       
        helpTest(TestSearchedCaseExpression.example(3), map, mapped);
    }
View Full Code Here

      
        helpTest(query, query, q);
    }
   
    @Test public void testCaseExpression3() {
        SearchedCaseExpression expr = TestSearchedCaseExpression.example2(4);
        Select select = new Select();
        select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
        From from = new From();
        from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
        CompareCriteria where = new CompareCriteria(new ElementSymbol("z"), CompareCriteria.EQ, expr); //$NON-NLS-1$
View Full Code Here

            .append(" END").toString(); //$NON-NLS-1$
        helpTest(query, query, q);
    }
   
    @Test public void testSearchedCaseExpression1() {
        SearchedCaseExpression expr = TestSearchedCaseExpression.example(4);
        Select select = new Select();
        select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
        select.addSymbol(new ElementSymbol("z")); //$NON-NLS-1$
        // The parser hard-codes the name "expr"
        select.addSymbol(new ExpressionSymbol("expr", expr)); //$NON-NLS-1$
View Full Code Here

            .append(" FROM m.g").toString(); //$NON-NLS-1$
        helpTest(query, query, q);
    }
   
    @Test public void testSearchedCaseExpression2() {
        SearchedCaseExpression expr = TestSearchedCaseExpression.example(4);
        expr.setElseExpression(null);
        Select select = new Select();
        select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
        select.addSymbol(new ElementSymbol("z")); //$NON-NLS-1$
        // The parser hard-codes the name "expr"
        select.addSymbol(new ExpressionSymbol("expr", expr)); //$NON-NLS-1$
View Full Code Here

            .append(" FROM m.g").toString(); //$NON-NLS-1$
        helpTest(query, query, q);
    }
   
    @Test public void testSearchedCaseExpression3() {
        SearchedCaseExpression expr = TestSearchedCaseExpression.example(4);
        Select select = new Select();
        select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
        From from = new From();
        from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
        CompareCriteria where = new CompareCriteria(new ElementSymbol("z"), CompareCriteria.EQ, expr); //$NON-NLS-1$
View Full Code Here

      f.setTypeString("CLOB");
      helpTestExpression("xmlserialize(x as CLOB)", "XMLSERIALIZE(x AS CLOB)", f);
    }
   
    @Test public void testExpressionCriteria() throws Exception {
      SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new ExpressionCriteria(new ElementSymbol("x"))), Arrays.asList(new ElementSymbol("y")));
      helpTestExpression("case when x then y end", "CASE WHEN x THEN y END", sce);
    }
View Full Code Here

      SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new ExpressionCriteria(new ElementSymbol("x"))), Arrays.asList(new ElementSymbol("y")));
      helpTestExpression("case when x then y end", "CASE WHEN x THEN y END", sce);
    }
   
    @Test public void testExpressionCriteria1() throws Exception {
      SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new NotCriteria(new ExpressionCriteria(new ElementSymbol("x")))), Arrays.asList(new ElementSymbol("y")));
      helpTestExpression("case when not x then y end", "CASE WHEN NOT (x) THEN y END", sce);
    }
View Full Code Here

                 "CASE WHEN x = 0 THEN 0 WHEN x = 1 THEN 1 ELSE 9999 END"); //$NON-NLS-1$
       
    }
   
    public void testSearchedCaseExpression2() {
        SearchedCaseExpression example = TestSearchedCaseExpression.example(2);
        example.setElseExpression(null);
        helpTest(example,
                 "CASE WHEN x = 0 THEN 0 WHEN x = 1 THEN 1 END"); //$NON-NLS-1$
       
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.symbol.SearchedCaseExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.