Program: 25376
Project: 25376
Buggy source:
@Test public void testCubeQuery() throws ParseException, SemanticException, GrillException {
  List<GrillDriver> drivers=new ArrayList<GrillDriver>();
  MockDriver driver=new MockDriver();
  Configuration conf=new Configuration();
  driver.configure(conf);
  drivers.add(driver);
  CubeQueryRewriter mockWriter=getMockedRewriter();
  PowerMockito.stub(PowerMockito.method(RewriteUtil.class,"String_Node_Str")).toReturn(mockWriter);
  String q1="String_Node_Str";
  Assert.assertFalse(RewriteUtil.isCubeQuery(q1));
  List<RewriteUtil.CubeQueryInfo> cubeQueries=RewriteUtil.findCubePositions(q1);
  Assert.assertEquals(cubeQueries.size(),0);
  RewriteUtil.rewriteQuery(q1,drivers,conf);
  String q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(RewriteUtil.getReplacedQuery(q2));
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str" + "String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),3);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(2).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),3);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(2).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
}

Fixed version (ground truth):
@Test public void testCubeQuery() throws ParseException, SemanticException, GrillException {
  List<GrillDriver> drivers=new ArrayList<GrillDriver>();
  MockDriver driver=new MockDriver();
  Configuration conf=new Configuration();
  driver.configure(conf);
  drivers.add(driver);
  CubeQueryRewriter mockWriter=getMockedRewriter();
  PowerMockito.stub(PowerMockito.method(RewriteUtil.class,"String_Node_Str")).toReturn(mockWriter);
  String q1="String_Node_Str";
  Assert.assertFalse(RewriteUtil.isCubeQuery(q1));
  List<RewriteUtil.CubeQueryInfo> cubeQueries=RewriteUtil.findCubePositions(q1);
  Assert.assertEquals(cubeQueries.size(),0);
  RewriteUtil.rewriteQuery(q1,drivers,conf);
  String q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(RewriteUtil.getReplacedQuery(q2));
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str" + "String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),3);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(2).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),3);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(2).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  q2="String_Node_Str";
  Assert.assertTrue(RewriteUtil.isCubeQuery(q2));
  cubeQueries=RewriteUtil.findCubePositions(q2);
  RewriteUtil.rewriteQuery(q2,drivers,conf);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  RewriteUtil.rewriteQuery(q2,drivers,conf);
}