Program: 5825
Project: 5825
Buggy source:
@Test public void testUsageRegistry(){
  UsageRegistry registry=new DefaultUsageRegistry(new TransactionExecutorFactory(){
    @Override public TransactionExecutor createExecutor(    Iterable<TransactionAware> iterable){
      return dsFrameworkUtil.newInMemoryTransactionExecutor(iterable);
    }
  }
,new ForwardingDatasetFramework(dsFrameworkUtil.getFramework()){
    @Nullable @Override public <T extends Dataset>T getDataset(    Id.DatasetInstance datasetInstanceId,    @Nullable Map<String,String> arguments,    @Nullable ClassLoader classLoader) throws DatasetManagementException, IOException {
      T t=super.getDataset(datasetInstanceId,arguments,classLoader);
      if (t instanceof UsageDataset) {
        @SuppressWarnings("String_Node_Str") T t1=(T)new WrappedUsageDataset((UsageDataset)t);
        return t1;
      }
      return t;
    }
  }
);
  registry.register(flow11,datasetInstance1);
  registry.register(flow12,stream1);
  registry.registerAll(ImmutableList.of(flow21,flow22),datasetInstance2);
  registry.registerAll(ImmutableList.of(flow21,flow22),stream1);
  int count=WrappedUsageDataset.registerCount;
  Assert.assertEquals(ImmutableSet.of(datasetInstance1),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(flow11),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow12,flow21,flow22),registry.getPrograms(stream1));
  registry.register(flow11,datasetInstance1);
  registry.registerAll(ImmutableList.of(flow21,flow22),datasetInstance2);
  Assert.assertEquals(count,WrappedUsageDataset.registerCount);
  Assert.assertEquals(ImmutableSet.of(datasetInstance1),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(flow11),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow12,flow21,flow22),registry.getPrograms(stream1));
  registry.unregister(flow11.getApplication());
  Assert.assertEquals(ImmutableSet.of(),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(stream1));
  registry.register(flow11,datasetInstance1);
  registry.register(flow12,stream1);
  Assert.assertEquals(ImmutableSet.of(datasetInstance1),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(flow11),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow12,flow21,flow22),registry.getPrograms(stream1));
  Assert.assertEquals(count + 2,WrappedUsageDataset.registerCount);
}

Fixed version (ground truth):
@Test public void testUsageRegistry(){
  UsageRegistry registry=new DefaultUsageRegistry(new TransactionExecutorFactory(){
    @Override public TransactionExecutor createExecutor(    Iterable<TransactionAware> iterable){
      return dsFrameworkUtil.newInMemoryTransactionExecutor(iterable);
    }
  }
,new ForwardingDatasetFramework(dsFrameworkUtil.getFramework()){
    @Nullable @Override public <T extends Dataset>T getDataset(    Id.DatasetInstance datasetInstanceId,    @Nullable Map<String,String> arguments,    @Nullable ClassLoader classLoader) throws DatasetManagementException, IOException {
      T t=super.getDataset(datasetInstanceId,arguments,classLoader);
      if (t instanceof UsageDataset) {
        @SuppressWarnings("String_Node_Str") T t1=(T)new WrappedUsageDataset((UsageDataset)t);
        return t1;
      }
      return t;
    }
  }
);
  registry.register(flow11,datasetInstance1);
  registry.register(flow12,stream1);
  registry.registerAll(ImmutableList.of(flow21,flow22),datasetInstance2);
  registry.registerAll(ImmutableList.of(flow21,flow22),stream1);
  int count=WrappedUsageDataset.registerCount;
  Assert.assertEquals(ImmutableSet.of(datasetInstance1),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(flow11),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow12,flow21,flow22),registry.getPrograms(stream1));
  registry.register(flow11,datasetInstance1);
  registry.registerAll(ImmutableList.of(flow21,flow22),datasetInstance2);
  count+=3;
  Assert.assertEquals(count,WrappedUsageDataset.registerCount);
  Assert.assertEquals(ImmutableSet.of(datasetInstance1),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(flow11),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow12,flow21,flow22),registry.getPrograms(stream1));
  registry.unregister(flow11.getApplication());
  Assert.assertEquals(ImmutableSet.of(),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(stream1));
  registry.register(flow11,datasetInstance1);
  registry.register(flow12,stream1);
  Assert.assertEquals(ImmutableSet.of(datasetInstance1),registry.getDatasets(flow11));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow12));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow21));
  Assert.assertEquals(ImmutableSet.of(datasetInstance2),registry.getDatasets(flow22));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow21));
  Assert.assertEquals(ImmutableSet.of(stream1),registry.getStreams(flow22));
  Assert.assertEquals(ImmutableSet.of(flow11),registry.getPrograms(datasetInstance1));
  Assert.assertEquals(ImmutableSet.of(flow21,flow22),registry.getPrograms(datasetInstance2));
  Assert.assertEquals(ImmutableSet.of(flow12,flow21,flow22),registry.getPrograms(stream1));
  Assert.assertEquals(count + 2,WrappedUsageDataset.registerCount);
}