Program: 6497
Project: 6497
Buggy source:
@Test public void testAllProgramsLineage() throws Exception {
  String namespace="String_Node_Str";
  Id.Application app=Id.Application.from(namespace,AllProgramsApp.NAME);
  Id.Flow flow=Id.Flow.from(app,AllProgramsApp.NoOpFlow.NAME);
  Id.Program mapreduce=Id.Program.from(app,ProgramType.MAPREDUCE,AllProgramsApp.NoOpMR.NAME);
  Id.Program spark=Id.Program.from(app,ProgramType.SPARK,AllProgramsApp.NoOpSpark.NAME);
  Id.Program service=Id.Program.from(app,ProgramType.SERVICE,AllProgramsApp.NoOpService.NAME);
  Id.Program worker=Id.Program.from(app,ProgramType.WORKER,AllProgramsApp.NoOpWorker.NAME);
  Id.Program workflow=Id.Program.from(app,ProgramType.WORKFLOW,AllProgramsApp.NoOpWorkflow.NAME);
  Id.DatasetInstance dataset=Id.DatasetInstance.from(namespace,AllProgramsApp.DATASET_NAME);
  Id.Stream stream=Id.Stream.from(namespace,AllProgramsApp.STREAM_NAME);
  Assert.assertEquals(200,status(createNamespace(namespace)));
  try {
    Assert.assertEquals(200,status(deploy(AllProgramsApp.class,Constants.Gateway.API_VERSION_3_TOKEN,namespace)));
    ImmutableSet<String> sparkTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    addTags(spark,sparkTags);
    Assert.assertEquals(sparkTags,getTags(spark));
    ImmutableSet<String> workerTags=ImmutableSet.of("String_Node_Str");
    addTags(worker,workerTags);
    Assert.assertEquals(workerTags,getTags(worker));
    ImmutableMap<String,String> datasetProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    addProperties(dataset,datasetProperties);
    Assert.assertEquals(datasetProperties,getProperties(dataset));
    RunId flowRunId=runAndWait(flow);
    RunId mrRunId=runAndWait(mapreduce);
    RunId sparkRunId=runAndWait(spark);
    runAndWait(workflow);
    RunId workflowMrRunId=getRunId(mapreduce,mrRunId);
    RunId serviceRunId=runAndWait(service);
    RunId workerRunId=runAndWait(worker);
    waitForStop(flow,true);
    waitForStop(mapreduce,false);
    waitForStop(spark,false);
    waitForStop(workflow,false);
    waitForStop(worker,false);
    waitForStop(service,true);
    long now=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
    long oneHour=TimeUnit.HOURS.toSeconds(1);
    HttpResponse httpResponse=fetchLineage(dataset,now - oneHour,now + oneHour,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    LineageRecord lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    LineageRecord expected=new LineageRecord(now - oneHour,now + oneHour,ImmutableSet.of(new Relation(dataset,flow,AccessType.UNKNOWN,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME))),new Relation(dataset,mapreduce,AccessType.UNKNOWN,mrRunId),new Relation(dataset,spark,AccessType.UNKNOWN,sparkRunId),new Relation(dataset,mapreduce,AccessType.UNKNOWN,workflowMrRunId),new Relation(dataset,service,AccessType.UNKNOWN,serviceRunId),new Relation(dataset,worker,AccessType.UNKNOWN,workerRunId),new Relation(stream,flow,AccessType.READ,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME))),new Relation(stream,mapreduce,AccessType.READ,mrRunId),new Relation(stream,spark,AccessType.READ,sparkRunId),new Relation(stream,mapreduce,AccessType.READ,workflowMrRunId),new Relation(stream,worker,AccessType.WRITE,workerRunId)));
    Assert.assertEquals(expected,lineage);
    httpResponse=fetchLineage(stream,now - oneHour,now + oneHour,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected,lineage);
    Id.Program programForFlow=Id.Program.from(flow.getApplication(),flow.getType(),flow.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,emptyMap(),emptySet()),new MetadataRecord(programForFlow,emptyMap(),emptySet()),new MetadataRecord(dataset,datasetProperties,emptySet()),new MetadataRecord(stream,emptyMap(),emptySet())),fetchRunMetadata(new Id.Run(flow,flowRunId.getId())));
    Id.Program programForWorker=Id.Program.from(worker.getApplication(),worker.getType(),worker.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,emptyMap(),emptySet()),new MetadataRecord(programForWorker,emptyMap(),workerTags),new MetadataRecord(dataset,datasetProperties,emptySet()),new MetadataRecord(stream,emptyMap(),emptySet())),fetchRunMetadata(new Id.Run(worker,workerRunId.getId())));
    Id.Program programForSpark=Id.Program.from(spark.getApplication(),spark.getType(),spark.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,emptyMap(),emptySet()),new MetadataRecord(programForSpark,emptyMap(),sparkTags),new MetadataRecord(dataset,datasetProperties,emptySet()),new MetadataRecord(stream,emptyMap(),emptySet())),fetchRunMetadata(new Id.Run(spark,sparkRunId.getId())));
  }
  finally {
    try {
      deleteNamespace(namespace);
    }
 catch (    Throwable e) {
      LOG.error("String_Node_Str",namespace,e);
    }
  }
}

Fixed version (ground truth):
@Test public void testAllProgramsLineage() throws Exception {
  String namespace="String_Node_Str";
  Id.Application app=Id.Application.from(namespace,AllProgramsApp.NAME);
  Id.Flow flow=Id.Flow.from(app,AllProgramsApp.NoOpFlow.NAME);
  Id.Program mapreduce=Id.Program.from(app,ProgramType.MAPREDUCE,AllProgramsApp.NoOpMR.NAME);
  Id.Program spark=Id.Program.from(app,ProgramType.SPARK,AllProgramsApp.NoOpSpark.NAME);
  Id.Program service=Id.Program.from(app,ProgramType.SERVICE,AllProgramsApp.NoOpService.NAME);
  Id.Program worker=Id.Program.from(app,ProgramType.WORKER,AllProgramsApp.NoOpWorker.NAME);
  Id.Program workflow=Id.Program.from(app,ProgramType.WORKFLOW,AllProgramsApp.NoOpWorkflow.NAME);
  Id.DatasetInstance dataset=Id.DatasetInstance.from(namespace,AllProgramsApp.DATASET_NAME);
  Id.Stream stream=Id.Stream.from(namespace,AllProgramsApp.STREAM_NAME);
  Assert.assertEquals(200,status(createNamespace(namespace)));
  try {
    Assert.assertEquals(200,status(deploy(AllProgramsApp.class,Constants.Gateway.API_VERSION_3_TOKEN,namespace)));
    ImmutableSet<String> sparkTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    addTags(spark,sparkTags);
    Assert.assertEquals(sparkTags,getTags(spark));
    ImmutableSet<String> workerTags=ImmutableSet.of("String_Node_Str");
    addTags(worker,workerTags);
    Assert.assertEquals(workerTags,getTags(worker));
    ImmutableMap<String,String> datasetProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    addProperties(dataset,datasetProperties);
    Assert.assertEquals(datasetProperties,getProperties(dataset));
    RunId flowRunId=runAndWait(flow);
    RunId mrRunId=runAndWait(mapreduce);
    RunId sparkRunId=runAndWait(spark);
    runAndWait(workflow);
    RunId workflowMrRunId=getRunId(mapreduce,mrRunId);
    RunId serviceRunId=runAndWait(service);
    RunId workerRunId=runAndWait(worker);
    waitForStop(flow,true);
    waitForStop(mapreduce,false);
    waitForStop(spark,false);
    waitForStop(workflow,false);
    waitForStop(worker,false);
    waitForStop(service,true);
    long now=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
    long oneHour=TimeUnit.HOURS.toSeconds(1);
    HttpResponse httpResponse=fetchLineage(dataset,now - oneHour,now + oneHour,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    LineageRecord lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    LineageRecord expected=LineageSerializer.toLineageRecord(now - oneHour,now + oneHour,new Lineage(ImmutableSet.of(new Relation(dataset,flow,AccessType.UNKNOWN,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME))),new Relation(dataset,mapreduce,AccessType.UNKNOWN,mrRunId),new Relation(dataset,spark,AccessType.UNKNOWN,sparkRunId),new Relation(dataset,mapreduce,AccessType.UNKNOWN,workflowMrRunId),new Relation(dataset,service,AccessType.UNKNOWN,serviceRunId),new Relation(dataset,worker,AccessType.UNKNOWN,workerRunId),new Relation(stream,flow,AccessType.READ,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME))),new Relation(stream,mapreduce,AccessType.READ,mrRunId),new Relation(stream,spark,AccessType.READ,sparkRunId),new Relation(stream,mapreduce,AccessType.READ,workflowMrRunId),new Relation(stream,worker,AccessType.WRITE,workerRunId))));
    Assert.assertEquals(expected,lineage);
    httpResponse=fetchLineage(stream,now - oneHour,now + oneHour,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected,lineage);
    Id.Program programForFlow=Id.Program.from(flow.getApplication(),flow.getType(),flow.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,emptyMap(),emptySet()),new MetadataRecord(programForFlow,emptyMap(),emptySet()),new MetadataRecord(dataset,datasetProperties,emptySet()),new MetadataRecord(stream,emptyMap(),emptySet())),fetchRunMetadata(new Id.Run(flow,flowRunId.getId())));
    Id.Program programForWorker=Id.Program.from(worker.getApplication(),worker.getType(),worker.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,emptyMap(),emptySet()),new MetadataRecord(programForWorker,emptyMap(),workerTags),new MetadataRecord(dataset,datasetProperties,emptySet()),new MetadataRecord(stream,emptyMap(),emptySet())),fetchRunMetadata(new Id.Run(worker,workerRunId.getId())));
    Id.Program programForSpark=Id.Program.from(spark.getApplication(),spark.getType(),spark.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,emptyMap(),emptySet()),new MetadataRecord(programForSpark,emptyMap(),sparkTags),new MetadataRecord(dataset,datasetProperties,emptySet()),new MetadataRecord(stream,emptyMap(),emptySet())),fetchRunMetadata(new Id.Run(spark,sparkRunId.getId())));
  }
  finally {
    try {
      deleteNamespace(namespace);
    }
 catch (    Throwable e) {
      LOG.error("String_Node_Str",namespace,e);
    }
  }
}