@Test public void testPatternWithoutWildCardChar() { String patternStr = ReduceSinkOperator.getOperatorName() + "%" + SelectOperator.getOperatorName() + "%" + FileSinkOperator.getOperatorName() + "%"; RuleRegExp rule1 = new RuleRegExp("R1", patternStr); assertEquals(rule1.rulePatternIsValidWithoutWildCardChar(), true); assertEquals(rule1.rulePatternIsValidWithWildCardChar(), false); // positive test Stack<Node> ns1 = new Stack<Node>(); ns1.push(new TestNode(ReduceSinkOperator.getOperatorName())); ns1.push(new TestNode(SelectOperator.getOperatorName())); ns1.push(new TestNode(FileSinkOperator.getOperatorName())); try { assertEquals(rule1.cost(ns1), patternStr.length()); } catch (SemanticException e) { fail(e.getMessage()); } // negative test Stack<Node> ns2 = new Stack<Node>(); ns2.push(new TestNode(ReduceSinkOperator.getOperatorName())); ns1.push(new TestNode(TableScanOperator.getOperatorName())); ns1.push(new TestNode(FileSinkOperator.getOperatorName())); try { assertEquals(rule1.cost(ns2), -1); } catch (SemanticException e) { fail(e.getMessage()); } }
ns1.push(new TestNode(TableScanOperator.getOperatorName())); ns1.push(new TestNode(FilterOperator.getOperatorName())); Stack<Node> ns2 = new Stack<Node>(); ns2.push(new TestNode(TableScanOperator.getOperatorName())); ns2.push(new TestNode(FileSinkOperator.getOperatorName())); try { assertNotEquals(rule1.cost(ns1), -1); ns3.push(new TestNode(ReduceSinkOperator.getOperatorName())); ns3.push(new TestNode(ReduceSinkOperator.getOperatorName())); ns3.push(new TestNode(FileSinkOperator.getOperatorName())); try { assertEquals(rule1.cost(ns3), -1);