Program: 6496
Project: 6496
Buggy source:
@Test public void testFlowLineage() 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.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)));
    ImmutableMap<String,String> appProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(app,appProperties).getResponseCode());
    Assert.assertEquals(appProperties,getProperties(app));
    ImmutableSet<String> appTags=ImmutableSet.of("String_Node_Str");
    Assert.assertEquals(200,addTags(app,appTags).getResponseCode());
    Assert.assertEquals(appTags,getTags(app));
    ImmutableMap<String,String> flowProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(flow,flowProperties).getResponseCode());
    Assert.assertEquals(flowProperties,getProperties(flow));
    ImmutableSet<String> flowTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addTags(flow,flowTags).getResponseCode());
    Assert.assertEquals(flowTags,getTags(flow));
    ImmutableMap<String,String> dataProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(dataset,dataProperties).getResponseCode());
    Assert.assertEquals(dataProperties,getProperties(dataset));
    ImmutableSet<String> dataTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addTags(dataset,dataTags).getResponseCode());
    Assert.assertEquals(dataTags,getTags(dataset));
    ImmutableMap<String,String> streamProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(stream,streamProperties).getResponseCode());
    Assert.assertEquals(streamProperties,getProperties(stream));
    ImmutableSet<String> streamTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addTags(stream,streamTags).getResponseCode());
    Assert.assertEquals(streamTags,getTags(stream));
    long startTime=TimeMathParser.nowInSeconds();
    RunId flowRunId=runAndWait(flow);
    TimeUnit.SECONDS.sleep(2);
    waitForStop(flow,true);
    long stopTime=TimeMathParser.nowInSeconds();
    HttpResponse httpResponse=fetchLineage(dataset,startTime,stopTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    LineageRecord lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    LineageRecord expected=new LineageRecord(startTime,stopTime,ImmutableSet.of(new Relation(dataset,flow,AccessType.UNKNOWN,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME))),new Relation(stream,flow,AccessType.READ,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME)))));
    Assert.assertEquals(expected,lineage);
    httpResponse=fetchLineage(dataset,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected.getRelations(),lineage.getRelations());
    httpResponse=fetchLineage(stream,startTime,stopTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected,lineage);
    httpResponse=fetchLineage(stream,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected.getRelations(),lineage.getRelations());
    Id.Program programForFlow=Id.Program.from(flow.getApplication(),flow.getType(),flow.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,appProperties,appTags),new MetadataRecord(programForFlow,flowProperties,flowTags),new MetadataRecord(dataset,dataProperties,dataTags),new MetadataRecord(stream,streamProperties,streamTags)),fetchRunMetadata(new Id.Run(flow,flowRunId.getId())));
    long laterStartTime=stopTime + 1000;
    long laterEndTime=stopTime + 5000;
    httpResponse=fetchLineage(stream,laterStartTime,laterEndTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(new LineageRecord(laterStartTime,laterEndTime,ImmutableSet.<Relation>of()),lineage);
    long earlierStartTime=startTime - 5000;
    long earlierEndTime=startTime - 1000;
    httpResponse=fetchLineage(stream,earlierStartTime,earlierEndTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(new LineageRecord(earlierStartTime,earlierEndTime,ImmutableSet.<Relation>of()),lineage);
    httpResponse=fetchLineage(dataset,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(400,httpResponse.getResponseCode());
    httpResponse=fetchLineage(dataset,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(400,httpResponse.getResponseCode());
    httpResponse=fetchRunMetadataResponse(new Id.Run(flow,RunIds.generate(1000).getId()));
    Assert.assertEquals(404,httpResponse.getResponseCode());
  }
  finally {
    try {
      deleteNamespace(namespace);
    }
 catch (    Throwable e) {
      LOG.error("String_Node_Str",namespace,e);
    }
  }
}

Fixed version (ground truth):
@Test public void testFlowLineage() 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.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)));
    ImmutableMap<String,String> appProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(app,appProperties).getResponseCode());
    Assert.assertEquals(appProperties,getProperties(app));
    ImmutableSet<String> appTags=ImmutableSet.of("String_Node_Str");
    Assert.assertEquals(200,addTags(app,appTags).getResponseCode());
    Assert.assertEquals(appTags,getTags(app));
    ImmutableMap<String,String> flowProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(flow,flowProperties).getResponseCode());
    Assert.assertEquals(flowProperties,getProperties(flow));
    ImmutableSet<String> flowTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addTags(flow,flowTags).getResponseCode());
    Assert.assertEquals(flowTags,getTags(flow));
    ImmutableMap<String,String> dataProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(dataset,dataProperties).getResponseCode());
    Assert.assertEquals(dataProperties,getProperties(dataset));
    ImmutableSet<String> dataTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addTags(dataset,dataTags).getResponseCode());
    Assert.assertEquals(dataTags,getTags(dataset));
    ImmutableMap<String,String> streamProperties=ImmutableMap.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addProperties(stream,streamProperties).getResponseCode());
    Assert.assertEquals(streamProperties,getProperties(stream));
    ImmutableSet<String> streamTags=ImmutableSet.of("String_Node_Str","String_Node_Str");
    Assert.assertEquals(200,addTags(stream,streamTags).getResponseCode());
    Assert.assertEquals(streamTags,getTags(stream));
    long startTime=TimeMathParser.nowInSeconds();
    RunId flowRunId=runAndWait(flow);
    TimeUnit.SECONDS.sleep(2);
    waitForStop(flow,true);
    long stopTime=TimeMathParser.nowInSeconds();
    HttpResponse httpResponse=fetchLineage(dataset,startTime,stopTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    LineageRecord lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    LineageRecord expected=LineageSerializer.toLineageRecord(startTime,stopTime,new Lineage(ImmutableSet.of(new Relation(dataset,flow,AccessType.UNKNOWN,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME))),new Relation(stream,flow,AccessType.READ,flowRunId,ImmutableSet.of(Id.Flow.Flowlet.from(flow,AllProgramsApp.A.NAME))))));
    Assert.assertEquals(expected,lineage);
    httpResponse=fetchLineage(dataset,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected.getRelations(),lineage.getRelations());
    httpResponse=fetchLineage(stream,startTime,stopTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected,lineage);
    httpResponse=fetchLineage(stream,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(expected.getRelations(),lineage.getRelations());
    Id.Program programForFlow=Id.Program.from(flow.getApplication(),flow.getType(),flow.getId());
    Assert.assertEquals(toSet(new MetadataRecord(app,appProperties,appTags),new MetadataRecord(programForFlow,flowProperties,flowTags),new MetadataRecord(dataset,dataProperties,dataTags),new MetadataRecord(stream,streamProperties,streamTags)),fetchRunMetadata(new Id.Run(flow,flowRunId.getId())));
    long laterStartTime=stopTime + 1000;
    long laterEndTime=stopTime + 5000;
    httpResponse=fetchLineage(stream,laterStartTime,laterEndTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(LineageSerializer.toLineageRecord(laterStartTime,laterEndTime,new Lineage(ImmutableSet.<Relation>of())),lineage);
    long earlierStartTime=startTime - 5000;
    long earlierEndTime=startTime - 1000;
    httpResponse=fetchLineage(stream,earlierStartTime,earlierEndTime,10);
    Assert.assertEquals(200,httpResponse.getResponseCode());
    lineage=GSON.fromJson(httpResponse.getResponseBodyAsString(),LineageRecord.class);
    Assert.assertEquals(LineageSerializer.toLineageRecord(earlierStartTime,earlierEndTime,new Lineage(ImmutableSet.<Relation>of())),lineage);
    httpResponse=fetchLineage(dataset,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(400,httpResponse.getResponseCode());
    httpResponse=fetchLineage(dataset,"String_Node_Str","String_Node_Str",10);
    Assert.assertEquals(400,httpResponse.getResponseCode());
    httpResponse=fetchRunMetadataResponse(new Id.Run(flow,RunIds.generate(1000).getId()));
    Assert.assertEquals(404,httpResponse.getResponseCode());
  }
  finally {
    try {
      deleteNamespace(namespace);
    }
 catch (    Throwable e) {
      LOG.error("String_Node_Str",namespace,e);
    }
  }
}