Program: 5926
Project: 5926
Buggy source:
private void assertDataEntitySearch() throws Exception {
  Id.DatasetInstance datasetInstance=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME);
  Id.DatasetInstance datasetInstance2=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME2);
  Id.DatasetInstance datasetInstance3=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME3);
  Id.DatasetInstance dsWithSchema=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DS_WITH_SCHEMA_NAME);
  Id.Stream streamId=Id.Stream.from(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME);
  Id.Stream.View view=Id.Stream.View.from(streamId,"String_Node_Str");
  Set<MetadataSearchResultRecord> expected=ImmutableSet.of(new MetadataSearchResultRecord(streamId),new MetadataSearchResultRecord(mystream));
  Set<MetadataSearchResultRecord> expectedWithView=ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expected).add(new MetadataSearchResultRecord(myview)).build();
  Set<MetadataSearchResultRecord> metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedWithView,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str" + Schema.Type.STRING.toString());
  Assert.assertEquals(expected,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedWithView,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expected,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expected).add(new MetadataSearchResultRecord(dsWithSchema)).build(),metadataSearchResultRecords);
  Schema viewSchema=Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.BYTES))));
  streamViewClient.createOrUpdate(view,new ViewSpecification(new FormatSpecification("String_Node_Str",viewSchema)));
  Map<String,String> datasetProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
  addProperties(datasetInstance,datasetProperties);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expectedWithView).add(new MetadataSearchResultRecord(datasetInstance)).add(new MetadataSearchResultRecord(dsWithSchema)).add(new MetadataSearchResultRecord(view)).build(),metadataSearchResultRecords);
  ImmutableSet<MetadataSearchResultRecord> expectedKvTables=ImmutableSet.of(new MetadataSearchResultRecord(datasetInstance),new MetadataSearchResultRecord(datasetInstance2),new MetadataSearchResultRecord(datasetInstance3),new MetadataSearchResultRecord(myds));
  ImmutableSet<MetadataSearchResultRecord> expectedAllDatasets=ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expectedKvTables).add(new MetadataSearchResultRecord(dsWithSchema)).build();
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedAllDatasets,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,KeyValueTable.class.getName());
  Assert.assertEquals(expectedKvTables,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedAllDatasets,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expected,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(streamId),new MetadataSearchResultRecord(view)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME,MetadataSearchTargetType.STREAM);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(streamId)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME,MetadataSearchTargetType.VIEW);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(view)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str",MetadataSearchTargetType.VIEW);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(view)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(datasetInstance)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.DS_WITH_SCHEMA_NAME);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(dsWithSchema)),metadataSearchResultRecords);
}

Fixed version (ground truth):
private void assertDataEntitySearch() throws Exception {
  Id.DatasetInstance datasetInstance=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME);
  Id.DatasetInstance datasetInstance2=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME2);
  Id.DatasetInstance datasetInstance3=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME3);
  Id.DatasetInstance datasetInstance4=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME4);
  Id.DatasetInstance datasetInstance5=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME5);
  Id.DatasetInstance datasetInstance6=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME6);
  Id.DatasetInstance datasetInstance7=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME7);
  Id.DatasetInstance dsWithSchema=Id.DatasetInstance.from(Id.Namespace.DEFAULT,AllProgramsApp.DS_WITH_SCHEMA_NAME);
  Id.Stream streamId=Id.Stream.from(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME);
  Id.Stream.View view=Id.Stream.View.from(streamId,"String_Node_Str");
  Set<MetadataSearchResultRecord> expected=ImmutableSet.of(new MetadataSearchResultRecord(streamId),new MetadataSearchResultRecord(mystream));
  Set<MetadataSearchResultRecord> expectedWithView=ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expected).add(new MetadataSearchResultRecord(myview)).build();
  Set<MetadataSearchResultRecord> metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedWithView,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str" + Schema.Type.STRING.toString());
  Assert.assertEquals(expected,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedWithView,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expected,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expected).add(new MetadataSearchResultRecord(dsWithSchema)).build(),metadataSearchResultRecords);
  Schema viewSchema=Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.BYTES))));
  streamViewClient.createOrUpdate(view,new ViewSpecification(new FormatSpecification("String_Node_Str",viewSchema)));
  Map<String,String> datasetProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
  addProperties(datasetInstance,datasetProperties);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expectedWithView).add(new MetadataSearchResultRecord(datasetInstance)).add(new MetadataSearchResultRecord(dsWithSchema)).add(new MetadataSearchResultRecord(view)).build(),metadataSearchResultRecords);
  ImmutableSet<MetadataSearchResultRecord> expectedKvTables=ImmutableSet.of(new MetadataSearchResultRecord(datasetInstance),new MetadataSearchResultRecord(datasetInstance2),new MetadataSearchResultRecord(datasetInstance3),new MetadataSearchResultRecord(myds));
  ImmutableSet<MetadataSearchResultRecord> expectedExplorableDatasets=ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expectedKvTables).add(new MetadataSearchResultRecord(datasetInstance4)).add(new MetadataSearchResultRecord(datasetInstance5)).add(new MetadataSearchResultRecord(dsWithSchema)).build();
  ImmutableSet<MetadataSearchResultRecord> expectedAllDatasets=ImmutableSet.<MetadataSearchResultRecord>builder().addAll(expectedExplorableDatasets).add(new MetadataSearchResultRecord(datasetInstance6)).add(new MetadataSearchResultRecord(datasetInstance7)).build();
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedExplorableDatasets,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,KeyValueTable.class.getName());
  Assert.assertEquals(expectedKvTables,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expectedAllDatasets,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str");
  Assert.assertEquals(expected,metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(streamId),new MetadataSearchResultRecord(view)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME,MetadataSearchTargetType.STREAM);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(streamId)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.STREAM_NAME,MetadataSearchTargetType.VIEW);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(view)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,"String_Node_Str",MetadataSearchTargetType.VIEW);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(view)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.DATASET_NAME);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(datasetInstance)),metadataSearchResultRecords);
  metadataSearchResultRecords=searchMetadata(Id.Namespace.DEFAULT,AllProgramsApp.DS_WITH_SCHEMA_NAME);
  Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(dsWithSchema)),metadataSearchResultRecords);
}