Program: 7139
Project: 7139
Buggy source:
@Test public void previewResultsTest() throws Exception {
  Id.DatasetInstance myTable2=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable3=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable4=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable5=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable6=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  datasetFramework.addInstance("String_Node_Str",myTable2,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable3,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable4,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable5,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable6,DatasetProperties.EMPTY);
  try {
    QueryHandle handle=exploreService.execute(NAMESPACE_ID,"String_Node_Str");
    QueryStatus status=waitForCompletionStatus(handle,200,TimeUnit.MILLISECONDS,50);
    Assert.assertEquals(QueryStatus.OpStatus.FINISHED,status.getStatus());
    List<QueryResult> firstPreview=exploreService.previewResults(handle);
    Assert.assertEquals(ImmutableList.of(new QueryResult(ImmutableList.<Object>of(MY_TABLE_NAME)),new QueryResult(ImmutableList.<Object>of("String_Node_Str")),new QueryResult(ImmutableList.<Object>of("String_Node_Str")),new QueryResult(ImmutableList.<Object>of("String_Node_Str")),new QueryResult(ImmutableList.<Object>of("String_Node_Str"))),firstPreview);
    List<QueryResult> endResults=exploreService.nextResults(handle,100);
    Assert.assertEquals(ImmutableList.of(new QueryResult(ImmutableList.<Object>of("String_Node_Str"))),endResults);
    List<QueryResult> secondPreview=exploreService.previewResults(handle);
    Assert.assertEquals(firstPreview,secondPreview);
    Assert.assertEquals(ImmutableList.of(),exploreService.nextResults(handle,100));
    try {
      exploreService.previewResults(handle);
      Assert.fail("String_Node_Str");
    }
 catch (    HandleNotFoundException e) {
      Assert.assertTrue(e.isInactive());
    }
  }
  finally {
    datasetFramework.deleteInstance(myTable2);
    datasetFramework.deleteInstance(myTable3);
    datasetFramework.deleteInstance(myTable4);
    datasetFramework.deleteInstance(myTable5);
    datasetFramework.deleteInstance(myTable6);
  }
}

Fixed version (ground truth):
@Test public void previewResultsTest() throws Exception {
  Id.DatasetInstance myTable2=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable3=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable4=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable5=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  Id.DatasetInstance myTable6=Id.DatasetInstance.from(NAMESPACE_ID,"String_Node_Str");
  datasetFramework.addInstance("String_Node_Str",myTable2,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable3,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable4,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable5,DatasetProperties.EMPTY);
  datasetFramework.addInstance("String_Node_Str",myTable6,DatasetProperties.EMPTY);
  try {
    QueryHandle handle=exploreService.execute(NAMESPACE_ID,"String_Node_Str");
    QueryStatus status=waitForCompletionStatus(handle,200,TimeUnit.MILLISECONDS,50);
    Assert.assertEquals(QueryStatus.OpStatus.FINISHED,status.getStatus());
    List<QueryResult> firstPreview=exploreService.previewResults(handle);
    Assert.assertEquals(ImmutableList.of(new QueryResult(ImmutableList.<Object>of(MY_TABLE_NAME)),new QueryResult(ImmutableList.<Object>of(getDatasetHiveName(myTable2))),new QueryResult(ImmutableList.<Object>of(getDatasetHiveName(myTable3))),new QueryResult(ImmutableList.<Object>of(getDatasetHiveName(myTable4))),new QueryResult(ImmutableList.<Object>of(getDatasetHiveName(myTable5)))),firstPreview);
    List<QueryResult> endResults=exploreService.nextResults(handle,100);
    Assert.assertEquals(ImmutableList.of(new QueryResult(ImmutableList.<Object>of(getDatasetHiveName(myTable6)))),endResults);
    List<QueryResult> secondPreview=exploreService.previewResults(handle);
    Assert.assertEquals(firstPreview,secondPreview);
    Assert.assertEquals(ImmutableList.of(),exploreService.nextResults(handle,100));
    try {
      exploreService.previewResults(handle);
      Assert.fail("String_Node_Str");
    }
 catch (    HandleNotFoundException e) {
      Assert.assertTrue(e.isInactive());
    }
    handle=exploreService.execute(NAMESPACE_ID,"String_Node_Str" + getDatasetHiveName(myTable2));
    status=waitForCompletionStatus(handle,200,TimeUnit.MILLISECONDS,50);
    Assert.assertEquals(QueryStatus.OpStatus.FINISHED,status.getStatus());
    Assert.assertTrue(exploreService.previewResults(handle).isEmpty());
    Assert.assertTrue(exploreService.previewResults(handle).isEmpty());
  }
  finally {
    datasetFramework.deleteInstance(myTable2);
    datasetFramework.deleteInstance(myTable3);
    datasetFramework.deleteInstance(myTable4);
    datasetFramework.deleteInstance(myTable5);
    datasetFramework.deleteInstance(myTable6);
  }
}