/** * Compare two queries for equality. Blocks will only evaluate to equal if * they are IDENTICAL: statements in the block are equal and are in the same order. * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Quick same object test if(this == obj) { return true; } // Quick fail tests if(!(obj instanceof Block)) { return false; } Block other = (Block)obj; // Compare the statements on the block return this.atomic == other.atomic && StringUtil.equalsIgnoreCase(label, other.label) && EquivalenceUtil.areEqual(getStatements(), other.getStatements()) && EquivalenceUtil.areEqual(exceptionGroup, other.exceptionGroup) && EquivalenceUtil.areEqual(exceptionStatements, exceptionStatements); }
/** * Compare two queries for equality. Blocks will only evaluate to equal if * they are IDENTICAL: statements in the block are equal and are in the same order. * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Quick same object test if(this == obj) { return true; } // Quick fail tests if(!(obj instanceof Block)) { return false; } Block other = (Block)obj; // Compare the statements on the block return this.atomic == other.atomic && StringUtil.equalsIgnoreCase(label, other.label) && EquivalenceUtil.areEqual(getStatements(), other.getStatements()) && EquivalenceUtil.areEqual(exceptionGroup, other.exceptionGroup) && EquivalenceUtil.areEqual(exceptionStatements, exceptionStatements); }
@Test public void testClone() { Block b1 = sample1(); Block b2 = b1.clone(); UnitTestUtil.helpTestEquivalence(0, b1, b2); assertNotSame(b1.getStatements().get(0), b2.getStatements().get(0)); }
public void visit(Block obj) { preVisitVisitor(obj); visitNodes(obj.getStatements()); visitNodes(obj.getExceptionStatements()); postVisitVisitor(obj); } public void visit(BranchingStatement obj) {
public void visit(Block obj) { preVisitVisitor(obj); visitNodes(obj.getStatements()); visitNodes(obj.getExceptionStatements()); postVisitVisitor(obj); } public void visit(BranchingStatement obj) {
public void visit(Block obj) { preVisitVisitor(obj); visitNodes(obj.getStatements()); visitNodes(obj.getExceptionStatements()); postVisitVisitor(obj); } public void visit(BranchingStatement obj) {
@Test public void testGetStatements1() { Block b1 = sample1(); List<Statement> stmts = b1.getStatements(); assertTrue("Incorrect number of statements in the Block", (stmts.size() == 4)); //$NON-NLS-1$ }
private Block rewriteBlock(Block block) throws TeiidComponentException { List<Statement> statements = block.getStatements(); List<Statement> newStmts = rewriteStatements(statements); block.setStatements(newStmts); if (block.getExceptionStatements() != null) { block.setExceptionStatements(rewriteStatements(block.getExceptionStatements())); } return block; }
private Block rewriteBlock(Block block) throws TeiidComponentException { List<Statement> statements = block.getStatements(); List<Statement> newStmts = rewriteStatements(statements); block.setStatements(newStmts); if (block.getExceptionStatements() != null) { block.setExceptionStatements(rewriteStatements(block.getExceptionStatements())); } return block; }
private Block rewriteBlock(Block block) throws TeiidComponentException { List<Statement> statements = block.getStatements(); List<Statement> newStmts = rewriteStatements(statements); block.setStatements(newStmts); if (block.getExceptionStatements() != null) { block.setExceptionStatements(rewriteStatements(block.getExceptionStatements())); } return block; }
@Test public void testGetStatements2() { Block b1 = sample1(); Statement stmt = b1.getStatements().get(1); assertTrue("Incorrect statement in the Block", stmt.equals(TestCommandStatement.sample1())); //$NON-NLS-1$ }
AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1); assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getName()); assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getExpression()).getGroupSymbol().getName()); Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock(); assStmt = (AssignmentStatement)inner.getStatements().get(0);
@Test public void testaddStatement2() { Block b1 = sample2().clone(); b1.addStatement(TestCommandStatement.sample2()); Statement stmt = b1.getStatements().get(4); assertTrue("Incorrect statement in the Block", stmt.equals(TestCommandStatement.sample2())); //$NON-NLS-1$ }
/** * Constants will now auto resolve if they are consistently representable in the target type */ @Test public void testDefect23257() throws Exception{ CreateProcedureCommand command = (CreateProcedureCommand) helpResolve("EXEC pm6.vsp59()", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ CommandStatement cs = (CommandStatement)command.getBlock().getStatements().get(1); Insert insert = (Insert)cs.getCommand(); assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType()); }
@Test public void testaddStatement1() { Block b1 = sample1().clone(); b1.addStatement(TestCommandStatement.sample2()); assertTrue("Incorrect number of statements in the Block", (b1.getStatements().size() == 5)); //$NON-NLS-1$ }
@Test public void testReturnAndResultSet() throws Exception { String ddl = "CREATE FOREIGN PROCEDURE proc (OUT param STRING RESULT) RETURNS TABLE (a INTEGER, b STRING);"; //$NON-NLS-1$ TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "y"); StoredProcedure sp = (StoredProcedure) TestResolver.helpResolve("exec proc()", tm); assertEquals(2, sp.getProjectedSymbols().size()); assertEquals("y.proc.b", sp.getProjectedSymbols().get(1).toString()); assertTrue(sp.returnsResultSet()); sp.setCallableStatement(true); assertEquals(3, sp.getProjectedSymbols().size()); assertEquals("y.proc.param", sp.getProjectedSymbols().get(2).toString()); CreateProcedureCommand cpc = (CreateProcedureCommand) TestResolver.helpResolve("begin exec proc(); end", tm); assertEquals(2, cpc.getProjectedSymbols().size()); assertEquals(2, ((CommandStatement)cpc.getBlock().getStatements().get(0)).getCommand().getProjectedSymbols().size()); assertTrue(cpc.returnsResultSet()); TestValidator.helpValidate("begin declare string var; var = exec proc(); select var; end", new String[] {"SELECT var;"}, tm); }
@Test public void testAlterProcedure() { AlterProcedure alterProc = (AlterProcedure) helpResolve("alter procedure MMSP5 as begin select param1; end", RealMetadataFactory.exampleBQTCached()); assertNotNull(alterProc.getTarget().getMetadataID()); Query q = (Query)((CommandStatement)alterProc.getDefinition().getBlock().getStatements().get(0)).getCommand(); assertTrue(((ElementSymbol)q.getSelect().getSymbol(0)).isExternalReference()); }
@Override public void visit( Block obj ) { addLabel(obj); List<Statement> statements = obj.getStatements(); // Add first clause append(BEGIN); if (obj.isAtomic()) { append(SPACE); append(ATOMIC); } append("\n"); //$NON-NLS-1$ addStatements(statements); if (obj.getExceptionGroup() != null) { append(NonReserved.EXCEPTION); append(SPACE); outputDisplayName(obj.getExceptionGroup()); append("\n"); //$NON-NLS-1$ if (obj.getExceptionStatements() != null) { addStatements(obj.getExceptionStatements()); } } append(END); }
@Override public void visit( Block obj ) { addLabel(obj); List<Statement> statements = obj.getStatements(); // Add first clause append(BEGIN); if (obj.isAtomic()) { append(SPACE); append(ATOMIC); } append("\n"); //$NON-NLS-1$ addStatements(statements); if (obj.getExceptionGroup() != null) { append(NonReserved.EXCEPTION); append(SPACE); outputDisplayName(obj.getExceptionGroup()); append("\n"); //$NON-NLS-1$ if (obj.getExceptionStatements() != null) { addStatements(obj.getExceptionStatements()); } } append(END); }
@Override public void visit( Block obj ) { addLabel(obj); List<Statement> statements = obj.getStatements(); // Add first clause append(BEGIN); if (obj.isAtomic()) { append(SPACE); append(ATOMIC); } append("\n"); //$NON-NLS-1$ addStatements(statements); if (obj.getExceptionGroup() != null) { append(NonReserved.EXCEPTION); append(SPACE); outputDisplayName(obj.getExceptionGroup()); append("\n"); //$NON-NLS-1$ if (obj.getExceptionStatements() != null) { addStatements(obj.getExceptionStatements()); } } append(END); }