Program: 6501
Project: 6501
Buggy source:
@Test public void testSimpleLineage() throws Exception {
  LineageStore lineageStore=new LineageStore(getTxExecFactory(),getDatasetFramework(),Id.DatasetInstance.from("String_Node_Str","String_Node_Str"));
  Store store=getInjector().getInstance(Store.class);
  BusinessMetadataStore businessMetadataStore=getInjector().getInstance(BusinessMetadataStore.class);
  LineageAdmin lineageAdmin=new LineageAdmin(lineageStore,store,businessMetadataStore,new NoOpEntityValidator());
  MetadataRecord run1AppMeta=new MetadataRecord(program1.getApplication(),toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  MetadataRecord run1ProgramMeta=new MetadataRecord(program1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  MetadataRecord run1Data1Meta=new MetadataRecord(dataset1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  MetadataRecord run1Data2Meta=new MetadataRecord(dataset2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  businessMetadataStore.setProperties(program1.getApplication(),run1AppMeta.getProperties());
  businessMetadataStore.addTags(program1.getApplication(),run1AppMeta.getTags().toArray(new String[0]));
  businessMetadataStore.setProperties(program1,run1ProgramMeta.getProperties());
  businessMetadataStore.addTags(program1,run1ProgramMeta.getTags().toArray(new String[0]));
  businessMetadataStore.setProperties(dataset1,run1Data1Meta.getProperties());
  businessMetadataStore.addTags(dataset1,run1Data1Meta.getTags().toArray(new String[0]));
  businessMetadataStore.setProperties(dataset2,run1Data2Meta.getProperties());
  businessMetadataStore.addTags(dataset2,run1Data2Meta.getTags().toArray(new String[0]));
  TimeUnit.MILLISECONDS.sleep(1);
  Id.Run run1=new Id.Run(program1,RunIds.generate(System.currentTimeMillis()).getId());
  Id.Run run2=new Id.Run(program2,RunIds.generate(System.currentTimeMillis()).getId());
  addRuns(store,run1,run2);
  lineageStore.addAccess(run1,dataset1,AccessType.WRITE,System.currentTimeMillis(),flowlet1);
  lineageStore.addAccess(run1,dataset2,AccessType.READ,System.currentTimeMillis(),flowlet1);
  lineageStore.addAccess(run2,dataset2,AccessType.WRITE,System.currentTimeMillis(),flowlet2);
  lineageStore.addAccess(run2,dataset3,AccessType.READ,System.currentTimeMillis(),flowlet2);
  Lineage expectedLineage=new Lineage(ImmutableSet.of(new Relation(dataset1,program1,AccessType.WRITE,twillRunId(run1),toSet(flowlet1)),new Relation(dataset2,program1,AccessType.READ,twillRunId(run1),toSet(flowlet1)),new Relation(dataset2,program2,AccessType.WRITE,twillRunId(run2),toSet(flowlet2)),new Relation(dataset3,program2,AccessType.READ,twillRunId(run2),toSet(flowlet2))));
  Assert.assertEquals(expectedLineage,lineageAdmin.computeLineage(dataset1,500,System.currentTimeMillis() + 10000,100));
  Assert.assertEquals(expectedLineage,lineageAdmin.computeLineage(dataset2,500,System.currentTimeMillis() + 10000,100));
  Lineage oneLevelLineage=lineageAdmin.computeLineage(dataset1,500,System.currentTimeMillis() + 10000,1);
  Assert.assertEquals(ImmutableSet.of(new Relation(dataset1,program1,AccessType.WRITE,twillRunId(run1),toSet(flowlet1)),new Relation(dataset2,program1,AccessType.READ,twillRunId(run1),toSet(flowlet1))),oneLevelLineage.getRelations());
  Assert.assertEquals(toSet(run1AppMeta,run1ProgramMeta,run1Data1Meta,run1Data2Meta),lineageAdmin.getMetadataForRun(run1));
}

Fixed version (ground truth):
@Test public void testSimpleLineage() throws Exception {
  LineageStore lineageStore=new LineageStore(getTxExecFactory(),getDatasetFramework(),Id.DatasetInstance.from("String_Node_Str","String_Node_Str"));
  Store store=getInjector().getInstance(Store.class);
  BusinessMetadataStore businessMetadataStore=getInjector().getInstance(BusinessMetadataStore.class);
  LineageAdmin lineageAdmin=new LineageAdmin(lineageStore,store,businessMetadataStore,new NoOpEntityValidator());
  MetadataRecord run1AppMeta=new MetadataRecord(program1.getApplication(),toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  MetadataRecord run1ProgramMeta=new MetadataRecord(program1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  MetadataRecord run1Data1Meta=new MetadataRecord(dataset1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  MetadataRecord run1Data2Meta=new MetadataRecord(dataset2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  businessMetadataStore.setProperties(program1.getApplication(),run1AppMeta.getProperties());
  businessMetadataStore.addTags(program1.getApplication(),run1AppMeta.getTags().toArray(new String[0]));
  businessMetadataStore.setProperties(program1,run1ProgramMeta.getProperties());
  businessMetadataStore.addTags(program1,run1ProgramMeta.getTags().toArray(new String[0]));
  businessMetadataStore.setProperties(dataset1,run1Data1Meta.getProperties());
  businessMetadataStore.addTags(dataset1,run1Data1Meta.getTags().toArray(new String[0]));
  businessMetadataStore.setProperties(dataset2,run1Data2Meta.getProperties());
  businessMetadataStore.addTags(dataset2,run1Data2Meta.getTags().toArray(new String[0]));
  TimeUnit.MILLISECONDS.sleep(1);
  Id.Run run1=new Id.Run(program1,RunIds.generate(System.currentTimeMillis()).getId());
  Id.Run run2=new Id.Run(program2,RunIds.generate(System.currentTimeMillis()).getId());
  addRuns(store,run1,run2);
  lineageStore.addAccess(run1,dataset1,AccessType.WRITE,System.currentTimeMillis(),flowlet1);
  lineageStore.addAccess(run1,dataset2,AccessType.READ,System.currentTimeMillis(),flowlet1);
  lineageStore.addAccess(run2,dataset2,AccessType.WRITE,System.currentTimeMillis(),flowlet2);
  lineageStore.addAccess(run2,dataset3,AccessType.READ,System.currentTimeMillis(),flowlet2);
  Lineage expectedLineage=new Lineage(ImmutableSet.of(new Relation(dataset1,program1,AccessType.WRITE,twillRunId(run1),toSet(flowlet1)),new Relation(dataset2,program1,AccessType.READ,twillRunId(run1),toSet(flowlet1)),new Relation(dataset2,program2,AccessType.WRITE,twillRunId(run2),toSet(flowlet2)),new Relation(dataset3,program2,AccessType.READ,twillRunId(run2),toSet(flowlet2))));
  Assert.assertEquals(expectedLineage,lineageAdmin.computeLineage(dataset1,500,System.currentTimeMillis() + 10000,100));
  Assert.assertEquals(expectedLineage,lineageAdmin.computeLineage(dataset2,500,System.currentTimeMillis() + 10000,100));
  Lineage oneLevelLineage=lineageAdmin.computeLineage(dataset1,500,System.currentTimeMillis() + 10000,1);
  Assert.assertEquals(ImmutableSet.of(new Relation(dataset1,program1,AccessType.WRITE,twillRunId(run1),toSet(flowlet1)),new Relation(dataset2,program1,AccessType.READ,twillRunId(run1),toSet(flowlet1))),oneLevelLineage.getRelations());
  Assert.assertEquals(toSet(run1AppMeta,run1ProgramMeta,run1Data1Meta,run1Data2Meta),lineageAdmin.getMetadataForRun(run1));
  Id.Namespace customNamespace=Id.Namespace.from("String_Node_Str");
  Id.DatasetInstance customDataset1=Id.DatasetInstance.from(customNamespace,dataset1.getId());
  Id.Run customRun1=new Id.Run(Id.Program.from(customNamespace,program1.getApplicationId(),program1.getType(),program1.getId()),run1.getId());
  Assert.assertEquals(new Lineage(ImmutableSet.<Relation>of()),lineageAdmin.computeLineage(customDataset1,500,System.currentTimeMillis() + 10000,100));
  Assert.assertEquals(ImmutableSet.<MetadataRecord>of(),lineageAdmin.getMetadataForRun(customRun1));
}