Program: 25391
Project: 25391
Buggy source:
@Test public void testCubeQuery() throws ParseException, SemanticException, GrillException {
  CubeGrillDriver mockedDriver=Mockito.spy(cubeDriver);
  CubeQueryRewriter mockWriter=getMockedRewriter();
  Mockito.doReturn(mockWriter).when(mockedDriver).getRewriter(any(GrillDriver.class));
  String q1="String_Node_Str";
  Assert.assertFalse(cubeDriver.isCubeQuery(q1));
  List<CubeQueryInfo> cubeQueries=mockedDriver.findCubePositions(q1);
  Assert.assertEquals(cubeQueries.size(),0);
  mockedDriver.rewriteQuery(q1);
  String q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(mockedDriver.getReplacedQuery(q2));
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str" + "String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.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");
  mockedDriver.rewriteQuery(q2);
}

Fixed version (ground truth):
@Test public void testCubeQuery() throws ParseException, SemanticException, GrillException {
  CubeGrillDriver mockedDriver=Mockito.spy(cubeDriver);
  CubeQueryRewriter mockWriter=getMockedRewriter();
  Mockito.doReturn(mockWriter).when(mockedDriver).getRewriter(any(GrillDriver.class));
  String q1="String_Node_Str";
  Assert.assertFalse(cubeDriver.isCubeQuery(q1));
  List<CubeQueryInfo> cubeQueries=mockedDriver.findCubePositions(q1);
  Assert.assertEquals(cubeQueries.size(),0);
  mockedDriver.rewriteQuery(q1);
  String q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(mockedDriver.getReplacedQuery(q2));
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str" + "String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  mockedDriver.rewriteQuery(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  Assert.assertEquals(cubeQueries.size(),1);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  mockedDriver.rewriteQuery(q2);
  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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  mockedDriver.rewriteQuery(q2);
  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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.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");
  mockedDriver.rewriteQuery(q2);
  q2="String_Node_Str" + "String_Node_Str";
  Assert.assertTrue(cubeDriver.isCubeQuery(q2));
  cubeQueries=mockedDriver.findCubePositions(q2);
  mockedDriver.rewriteQuery(q2);
  Assert.assertEquals(cubeQueries.size(),2);
  Assert.assertEquals(cubeQueries.get(0).query,"String_Node_Str");
  Assert.assertEquals(cubeQueries.get(1).query,"String_Node_Str");
  mockedDriver.rewriteQuery(q2);
}