Package org.teiid.query.sql.proc

Examples of org.teiid.query.sql.proc.Block


    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, b1, b1a);
  }
 
  public void testNonEquivalence(){
    Block b1 = sample1();
    Block b2 = sample2();
    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, b1, b2);
  }
View Full Code Here


    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, b1, b2);
  }
 
  public void testClone() {
    Block b1 = sample1();
    Block b2 = (Block)b1.clone();
    UnitTestUtil.helpTestEquivalence(0, b1, b2);
    assertNotSame(b1.getStatements().get(0), b2.getStatements().get(0));
  }
View Full Code Here

 
 
  // ################################## TEST HELPERS ################################ 

  public static final IfStatement sample1() {
    Block ifBlock = TestBlock.sample1();
    Block elseBlock = TestBlock.sample2();
    Criteria criteria = TestHasCriteria.sample1();
    return new IfStatement(criteria, ifBlock, elseBlock);
  }
View Full Code Here

    Criteria criteria = TestHasCriteria.sample1();
    return new IfStatement(criteria, ifBlock, elseBlock);
  }

  public static final IfStatement sample2() {
    Block ifBlock = TestBlock.sample2();
    Block elseBlock = TestBlock.sample1();
    Criteria criteria = TestHasCriteria.sample2();
    return new IfStatement(criteria, ifBlock, elseBlock);
  }
View Full Code Here

        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      AssignmentStatement assigStmt =  new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1))); //$NON-NLS-1$
      RaiseErrorStatement errStmt =  new RaiseErrorStatement(new Constant("My Error")); //$NON-NLS-1$
      Block b = new Block();
      b.addStatement(cmdStmt);
      b.addStatement(assigStmt);
      b.addStatement(errStmt);
    helpTest(b, "BEGIN\nDELETE FROM g;\na = 1;\nERROR 'My Error';\nEND"); //$NON-NLS-1$
    }
View Full Code Here

    // construct If statement

        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      Block ifblock = new Block(cmdStmt);
    // construct If criteria     
    ElementSymbol sy1 = new ElementSymbol("x"); //$NON-NLS-1$
    List elmnts = new ArrayList(1);
    elmnts.add(sy1);
    CriteriaSelector cs = new CriteriaSelector(CriteriaSelector.LIKE, elmnts);     
      Criteria crit = new HasCriteria(cs);     
      IfStatement ifStmt = new IfStatement(crit, ifblock);     
     
      // other statements
      RaiseErrorStatement errStmt =  new RaiseErrorStatement(new Constant("My Error")); //$NON-NLS-1$
      Block b = new Block();
      b.addStatement(cmdStmt);
      b.addStatement(ifStmt);
      b.addStatement(errStmt);     

    helpTest(b, "BEGIN\nDELETE FROM g;\nIF(HAS LIKE CRITERIA ON (x))\nBEGIN\nDELETE FROM g;\nEND\nERROR 'My Error';\nEND"); //$NON-NLS-1$
    }
View Full Code Here

        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      AssignmentStatement assigStmt =  new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1))); //$NON-NLS-1$
      RaiseErrorStatement errStmt =  new RaiseErrorStatement(new Constant("My Error")); //$NON-NLS-1$
      Block ifblock = new Block();
      ifblock.addStatement(cmdStmt);
      ifblock.addStatement(assigStmt);
      ifblock.addStatement(errStmt);

    // construct If criteria     
    ElementSymbol sy1 = new ElementSymbol("x"); //$NON-NLS-1$
    List elmnts = new ArrayList(1);
    elmnts.add(sy1);
View Full Code Here

    public void testIfStatement2() {
    // construct If block
        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      Block ifblock = new Block(cmdStmt);

    // construct If criteria     
    ElementSymbol sy1 = new ElementSymbol("x"); //$NON-NLS-1$
    List elmnts = new ArrayList(1);
    elmnts.add(sy1);
View Full Code Here

        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      AssignmentStatement assigStmt =  new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1))); //$NON-NLS-1$
      RaiseErrorStatement errStmt =  new RaiseErrorStatement(new Constant("My Error")); //$NON-NLS-1$
      Block ifblock = new Block();
      ifblock.addStatement(cmdStmt);
      ifblock.addStatement(assigStmt);
      ifblock.addStatement(errStmt);

    // construct If criteria     
    ElementSymbol sy1 = new ElementSymbol("x"); //$NON-NLS-1$
    List elmnts = new ArrayList(1);
    elmnts.add(sy1);
    CriteriaSelector cs = new CriteriaSelector(CriteriaSelector.LIKE, elmnts);     
      Criteria crit = new HasCriteria(cs);
     
      Block elseblock = new Block();
      elseblock.addStatement(cmdStmt);
     
      IfStatement ifStmt = new IfStatement(crit, ifblock, elseblock);
    helpTest(ifStmt, "IF(HAS LIKE CRITERIA ON (x))\nBEGIN\nDELETE FROM g;\na = 1;\nERROR 'My Error';\nEND\nELSE\nBEGIN\nDELETE FROM g;\nEND"); //$NON-NLS-1$
    }   
View Full Code Here

        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      AssignmentStatement assigStmt =  new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1))); //$NON-NLS-1$
      RaiseErrorStatement errStmt =  new RaiseErrorStatement(new Constant("My Error")); //$NON-NLS-1$
      Block b = new Block();
      b.addStatement(cmdStmt);
      b.addStatement(assigStmt);
      b.addStatement(errStmt);
      CreateUpdateProcedureCommand cup = new CreateUpdateProcedureCommand(b);
    helpTest(cup, "CREATE PROCEDURE\nBEGIN\nDELETE FROM g;\na = 1;\nERROR 'My Error';\nEND");       //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.proc.Block

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.