Program: 5549
Project: 5549
Buggy source:
@Test public void testSearchPagination() throws BadRequestException {
  NamespaceId ns=new NamespaceId("String_Node_Str");
  ProgramId flow=ns.app("String_Node_Str").flow("String_Node_Str");
  StreamId stream=ns.stream("String_Node_Str");
  DatasetId dataset=ns.dataset("String_Node_Str");
  DatasetId trackerDataset=ns.dataset("String_Node_Str");
  store.addTags(MetadataScope.USER,flow,"String_Node_Str","String_Node_Str");
  store.addTags(MetadataScope.USER,stream,"String_Node_Str","String_Node_Str");
  store.addTags(MetadataScope.USER,dataset,"String_Node_Str","String_Node_Str");
  store.addTags(MetadataScope.USER,trackerDataset,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  MetadataSearchResultRecord flowSearchResult=new MetadataSearchResultRecord(flow);
  MetadataSearchResultRecord streamSearchResult=new MetadataSearchResultRecord(stream);
  MetadataSearchResultRecord datasetSearchResult=new MetadataSearchResultRecord(dataset);
  MetadataSearchResultRecord trackerDatasetSearchResult=new MetadataSearchResultRecord(trackerDataset);
  MetadataSearchResponse response=search(ns.getNamespace(),"String_Node_Str",0,Integer.MAX_VALUE,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(datasetSearchResult,streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",0,Integer.MAX_VALUE,1,true);
  Assert.assertEquals(4,response.getTotal());
  Assert.assertEquals(ImmutableList.of(trackerDatasetSearchResult,datasetSearchResult,streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",0,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(datasetSearchResult,streamSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",1,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",1,3,1,true);
  Assert.assertEquals(4,response.getTotal());
  Assert.assertEquals(ImmutableList.of(datasetSearchResult,streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",2,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",4,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.<MetadataSearchResultRecord>of(),ImmutableList.copyOf(stripMetadata(response.getResults())));
}

Fixed version (ground truth):
@Test public void testSearchPagination() throws BadRequestException {
  NamespaceId ns=new NamespaceId("String_Node_Str");
  ProgramId flow=ns.app("String_Node_Str").flow("String_Node_Str");
  StreamId stream=ns.stream("String_Node_Str");
  DatasetId dataset=ns.dataset("String_Node_Str");
  DatasetId trackerDataset=ns.dataset("String_Node_Str");
  store.addTags(MetadataScope.USER,flow,"String_Node_Str","String_Node_Str");
  store.addTags(MetadataScope.USER,stream,"String_Node_Str","String_Node_Str");
  store.addTags(MetadataScope.USER,dataset,"String_Node_Str","String_Node_Str");
  store.addTags(MetadataScope.USER,trackerDataset,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  MetadataSearchResultRecord flowSearchResult=new MetadataSearchResultRecord(flow);
  MetadataSearchResultRecord streamSearchResult=new MetadataSearchResultRecord(stream);
  MetadataSearchResultRecord datasetSearchResult=new MetadataSearchResultRecord(dataset);
  MetadataSearchResultRecord trackerDatasetSearchResult=new MetadataSearchResultRecord(trackerDataset);
  MetadataSearchResponse response=search(ns.getNamespace(),"String_Node_Str",0,Integer.MAX_VALUE,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(datasetSearchResult,streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",0,Integer.MAX_VALUE,1,true);
  Assert.assertEquals(4,response.getTotal());
  Assert.assertEquals(ImmutableList.of(trackerDatasetSearchResult,datasetSearchResult,streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",0,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(datasetSearchResult,streamSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",1,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",1,3,1,true);
  Assert.assertEquals(4,response.getTotal());
  Assert.assertEquals(ImmutableList.of(datasetSearchResult,streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",2,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",4,2,1);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.<MetadataSearchResultRecord>of(),ImmutableList.copyOf(stripMetadata(response.getResults())));
  response=search(ns.getNamespace(),"String_Node_Str",1,Integer.MAX_VALUE,0);
  Assert.assertEquals(3,response.getTotal());
  Assert.assertEquals(ImmutableList.of(streamSearchResult,flowSearchResult),ImmutableList.copyOf(stripMetadata(response.getResults())));
}