Program: 6691
Project: 6691
Buggy source:
@Test public void testMultipleRelations() throws Exception {
  LineageDataset lineageDataset=getLineageDataset("String_Node_Str");
  Assert.assertNotNull(lineageDataset);
  RunId runId1=RunIds.generate(10000);
  RunId runId2=RunIds.generate(20000);
  RunId runId3=RunIds.generate(30000);
  RunId runId4=RunIds.generate(40000);
  Id.DatasetInstance datasetInstance1=Id.DatasetInstance.from("String_Node_Str","String_Node_Str");
  Id.DatasetInstance datasetInstance2=Id.DatasetInstance.from("String_Node_Str","String_Node_Str");
  Id.Stream stream1=Id.Stream.from("String_Node_Str","String_Node_Str");
  Id.Stream stream2=Id.Stream.from("String_Node_Str","String_Node_Str");
  Id.Program program1=Id.Program.from("String_Node_Str","String_Node_Str",ProgramType.FLOW,"String_Node_Str");
  Id.Flow.Flowlet flowlet1=Id.Flow.Flowlet.from(program1.getApplication(),program1.getId(),"String_Node_Str");
  Id.Program program2=Id.Program.from("String_Node_Str","String_Node_Str",ProgramType.WORKER,"String_Node_Str");
  Id.Program program3=Id.Program.from("String_Node_Str","String_Node_Str",ProgramType.SERVICE,"String_Node_Str");
  Id.Run run11=new Id.Run(program1,runId1.getId());
  Id.Run run22=new Id.Run(program2,runId2.getId());
  Id.Run run23=new Id.Run(program2,runId3.getId());
  Id.Run run34=new Id.Run(program3,runId4.getId());
  Set<MetadataRecord> metaProgram1Data1Run1=toSet(new MetadataRecord(program1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")),new MetadataRecord(datasetInstance1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  MetadataRecord metadataRecordProgram2Run2=new MetadataRecord(program2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  Set<MetadataRecord> metaProgram2Data2Run2=toSet(metadataRecordProgram2Run2,new MetadataRecord(datasetInstance2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  Set<MetadataRecord> metaProgram2Stream1Run2=toSet(metadataRecordProgram2Run2,new MetadataRecord(stream1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  MetadataRecord metadataRecordProgram2Run3=new MetadataRecord(program2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  Set<MetadataRecord> metaProgram2Stream2Run3=toSet(metadataRecordProgram2Run3,new MetadataRecord(stream2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  Set<MetadataRecord> metaProgram2Data2Run3=toSet(metadataRecordProgram2Run3,new MetadataRecord(datasetInstance2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  Set<MetadataRecord> metaProgram3Data2Run4=toSet(new MetadataRecord(program3,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")),new MetadataRecord(datasetInstance2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  lineageDataset.addAccess(run11,datasetInstance1,AccessType.READ,metaProgram1Data1Run1,flowlet1);
  lineageDataset.addAccess(run22,datasetInstance2,AccessType.WRITE,metaProgram2Data2Run2);
  lineageDataset.addAccess(run22,stream1,AccessType.READ,metaProgram2Stream1Run2);
  lineageDataset.addAccess(run23,stream2,AccessType.READ,metaProgram2Stream2Run3);
  lineageDataset.addAccess(run23,datasetInstance2,AccessType.WRITE,metaProgram2Data2Run3);
  lineageDataset.addAccess(run34,datasetInstance2,AccessType.READ_WRITE,metaProgram3Data2Run4);
  lineageDataset.addAccess(run34,stream2,AccessType.UNKNOWN,EMPTY_METADATA);
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance1,program1,AccessType.READ,ImmutableSet.of(runId1),ImmutableSet.of(flowlet1))),lineageDataset.getRelations(datasetInstance1,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId2)),new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId3)),new Relation(datasetInstance2,program3,AccessType.READ_WRITE,ImmutableSet.of(runId4))),lineageDataset.getRelations(datasetInstance2,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(stream1,program2,AccessType.READ,ImmutableSet.of(runId2))),lineageDataset.getRelations(stream1,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(stream2,program2,AccessType.READ,ImmutableSet.of(runId3)),new Relation(stream2,program3,AccessType.UNKNOWN,ImmutableSet.of(runId4))),lineageDataset.getRelations(stream2,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId2)),new Relation(stream1,program2,AccessType.READ,ImmutableSet.of(runId2)),new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId3)),new Relation(stream2,program2,AccessType.READ,ImmutableSet.of(runId3))),lineageDataset.getRelations(program2,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId2)),new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId3))),lineageDataset.getRelations(datasetInstance2,0,35000));
  Assert.assertEquals(metaProgram1Data1Run1,lineageDataset.getAccesses(run11));
  Assert.assertEquals(2,lineageDataset.getAccesses(run11).size());
  Assert.assertEquals(toSet(metaProgram2Data2Run2,metaProgram2Stream1Run2),lineageDataset.getAccesses(run22));
  Assert.assertEquals(3,lineageDataset.getAccesses(run22).size());
  Assert.assertEquals(toSet(metaProgram2Stream2Run3,metaProgram2Data2Run3),lineageDataset.getAccesses(run23));
  Assert.assertEquals(3,lineageDataset.getAccesses(run23).size());
  Assert.assertEquals(metaProgram3Data2Run4,lineageDataset.getAccesses(run34));
  Assert.assertEquals(2,lineageDataset.getAccesses(run34).size());
}

Fixed version (ground truth):
@Test public void testMultipleRelations() throws Exception {
  LineageDataset lineageDataset=getLineageDataset("String_Node_Str");
  Assert.assertNotNull(lineageDataset);
  RunId runId1=RunIds.generate(10000);
  RunId runId2=RunIds.generate(20000);
  RunId runId3=RunIds.generate(30000);
  RunId runId4=RunIds.generate(40000);
  Id.DatasetInstance datasetInstance1=Id.DatasetInstance.from("String_Node_Str","String_Node_Str");
  Id.DatasetInstance datasetInstance2=Id.DatasetInstance.from("String_Node_Str","String_Node_Str");
  Id.Stream stream1=Id.Stream.from("String_Node_Str","String_Node_Str");
  Id.Stream stream2=Id.Stream.from("String_Node_Str","String_Node_Str");
  Id.Program program1=Id.Program.from("String_Node_Str","String_Node_Str",ProgramType.FLOW,"String_Node_Str");
  Id.Flow.Flowlet flowlet1=Id.Flow.Flowlet.from(program1.getApplication(),program1.getId(),"String_Node_Str");
  Id.Program program2=Id.Program.from("String_Node_Str","String_Node_Str",ProgramType.WORKER,"String_Node_Str");
  Id.Program program3=Id.Program.from("String_Node_Str","String_Node_Str",ProgramType.SERVICE,"String_Node_Str");
  Id.Run run11=new Id.Run(program1,runId1.getId());
  Id.Run run22=new Id.Run(program2,runId2.getId());
  Id.Run run23=new Id.Run(program2,runId3.getId());
  Id.Run run34=new Id.Run(program3,runId4.getId());
  Set<MetadataRecord> metaProgram1Data1Run1=toSet(new MetadataRecord(program1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")),new MetadataRecord(datasetInstance1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  MetadataRecord metadataRecordProgram2Run2=new MetadataRecord(program2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  Set<MetadataRecord> metaProgram2Data2Run2=toSet(metadataRecordProgram2Run2,new MetadataRecord(datasetInstance2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  Set<MetadataRecord> metaProgram2Stream1Run2=toSet(metadataRecordProgram2Run2,new MetadataRecord(stream1,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  MetadataRecord metadataRecordProgram2Run3=new MetadataRecord(program2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str"));
  Set<MetadataRecord> metaProgram2Stream2Run3=toSet(metadataRecordProgram2Run3,new MetadataRecord(stream2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  Set<MetadataRecord> metaProgram2Data2Run3=toSet(metadataRecordProgram2Run3,new MetadataRecord(datasetInstance2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  Set<MetadataRecord> metaProgram3Data2Run4=toSet(new MetadataRecord(program3,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")),new MetadataRecord(datasetInstance2,toMap("String_Node_Str","String_Node_Str"),toSet("String_Node_Str")));
  lineageDataset.addAccess(run11,datasetInstance1,AccessType.READ,metaProgram1Data1Run1,flowlet1);
  lineageDataset.addAccess(run22,datasetInstance2,AccessType.WRITE,metaProgram2Data2Run2);
  lineageDataset.addAccess(run22,stream1,AccessType.READ,metaProgram2Stream1Run2);
  lineageDataset.addAccess(run23,stream2,AccessType.READ,metaProgram2Stream2Run3);
  lineageDataset.addAccess(run23,datasetInstance2,AccessType.WRITE,metaProgram2Data2Run3);
  lineageDataset.addAccess(run34,datasetInstance2,AccessType.READ_WRITE,metaProgram3Data2Run4);
  lineageDataset.addAccess(run34,stream2,AccessType.UNKNOWN,EMPTY_METADATA);
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance1,program1,AccessType.READ,ImmutableSet.of(runId1),ImmutableSet.of(flowlet1))),lineageDataset.getRelations(datasetInstance1,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId2)),new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId3)),new Relation(datasetInstance2,program3,AccessType.READ_WRITE,ImmutableSet.of(runId4))),lineageDataset.getRelations(datasetInstance2,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(stream1,program2,AccessType.READ,ImmutableSet.of(runId2))),lineageDataset.getRelations(stream1,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(stream2,program2,AccessType.READ,ImmutableSet.of(runId3)),new Relation(stream2,program3,AccessType.UNKNOWN,ImmutableSet.of(runId4))),lineageDataset.getRelations(stream2,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId2)),new Relation(stream1,program2,AccessType.READ,ImmutableSet.of(runId2)),new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId3)),new Relation(stream2,program2,AccessType.READ,ImmutableSet.of(runId3))),lineageDataset.getRelations(program2,0,100000));
  Assert.assertEquals(ImmutableSet.of(new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId2)),new Relation(datasetInstance2,program2,AccessType.WRITE,ImmutableSet.of(runId3))),lineageDataset.getRelations(datasetInstance2,0,35000));
  Assert.assertEquals(metaProgram1Data1Run1,lineageDataset.getRunMetadata(run11));
  Assert.assertEquals(2,lineageDataset.getRunMetadata(run11).size());
  Assert.assertEquals(toSet(metaProgram2Data2Run2,metaProgram2Stream1Run2),lineageDataset.getRunMetadata(run22));
  Assert.assertEquals(3,lineageDataset.getRunMetadata(run22).size());
  Assert.assertEquals(toSet(metaProgram2Stream2Run3,metaProgram2Data2Run3),lineageDataset.getRunMetadata(run23));
  Assert.assertEquals(3,lineageDataset.getRunMetadata(run23).size());
  Assert.assertEquals(metaProgram3Data2Run4,lineageDataset.getRunMetadata(run34));
  Assert.assertEquals(2,lineageDataset.getRunMetadata(run34).size());
}