Program: 37626
Project: 37626
Buggy source:
@Test public void testParentReassignmentUponProxyTaskGroupActivation(){
  final LinkedList<String> group1Items=new LinkedList<>();
  final TaskGroup group1=createSampleTaskGroup("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",group1Items);
  final List<String> group2Items=new ArrayList<>();
  final TaskGroup group2=createSampleTaskGroup("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",group2Items);
  group2.addDependencyTaskGroup(group1);
  Assert.assertEquals(1,group1.parentDAGs.size());
  Assert.assertTrue(group1.parentDAGs.contains(group2));
  final LinkedList<String> group3Items=new LinkedList<>();
  final TaskGroup group3=createSampleTaskGroup("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",group3Items);
  group1.addPostRunDependentTaskGroup(group3);
  Assert.assertEquals(2,group1.parentDAGs.size());
  Assert.assertTrue(group1.parentDAGs.contains(group3));
  Assert.assertTrue(group1.parentDAGs.contains(group1.proxyTaskGroupWrapper.proxyTaskGroup()));
  Assert.assertEquals(1,group1.proxyTaskGroupWrapper.proxyTaskGroup().parentDAGs.size());
  Assert.assertTrue(group1.proxyTaskGroupWrapper.proxyTaskGroup().parentDAGs.contains(group2));
  Map<String,Set<String>> shouldNotSee=new HashMap<>();
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str"}));
  Set<String> seen=new HashSet<>();
  group2.prepareForEnumeration();
  for (TaskGroupEntry<TaskItem> entry=group2.getNext(); entry != null; entry=group2.getNext()) {
    Assert.assertTrue(shouldNotSee.containsKey(entry.key()));
    Assert.assertFalse(seen.contains(entry.key()));
    Sets.SetView<String> common=Sets.intersection(shouldNotSee.get(entry.key()),seen);
    if (common.size() > 0) {
      Assert.assertTrue("String_Node_Str" + common + "String_Node_Str"+ entry.key(),false);
    }
    seen.add(entry.key());
    group2.reportCompletion(entry);
  }
  Assert.assertEquals(19,seen.size());
  Set<String> expectedToSee=new HashSet<>();
  expectedToSee.addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  Sets.SetView<String> diff=Sets.difference(seen,expectedToSee);
  Assert.assertEquals(0,diff.size());
  seen.clear();
  TaskGroup group1Proxy=group1.proxyTaskGroupWrapper.proxyTaskGroup();
  group1Proxy.prepareForEnumeration();
  for (TaskGroupEntry<TaskItem> entry=group1Proxy.getNext(); entry != null; entry=group1Proxy.getNext()) {
    Assert.assertTrue(shouldNotSee.containsKey(entry.key()));
    Assert.assertFalse(seen.contains(entry.key()));
    Sets.SetView<String> common=Sets.intersection(shouldNotSee.get(entry.key()),seen);
    if (common.size() > 0) {
      Assert.assertTrue("String_Node_Str" + common + "String_Node_Str"+ entry.key(),false);
    }
    seen.add(entry.key());
    group1Proxy.reportCompletion(entry);
  }
  Assert.assertEquals(13,seen.size());
  expectedToSee.clear();
  expectedToSee.addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
}

Fixed version (ground truth):
@Test public void testParentReassignmentUponProxyTaskGroupActivation(){
  final LinkedList<String> group1Items=new LinkedList<>();
  final TaskGroup group1=createSampleTaskGroup("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",group1Items);
  final List<String> group2Items=new ArrayList<>();
  final TaskGroup group2=createSampleTaskGroup("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",group2Items);
  group2.addDependencyTaskGroup(group1);
  Assert.assertEquals(1,group1.parentDAGs.size());
  Assert.assertTrue(group1.parentDAGs.contains(group2));
  final LinkedList<String> group3Items=new LinkedList<>();
  final TaskGroup group3=createSampleTaskGroup("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",group3Items);
  group1.addPostRunDependentTaskGroup(group3);
  Assert.assertEquals(2,group1.parentDAGs.size());
  Assert.assertTrue(group1.parentDAGs.contains(group3));
  Assert.assertTrue(group1.parentDAGs.contains(group1.proxyTaskGroupWrapper.taskGroup()));
  Assert.assertEquals(1,group1.proxyTaskGroupWrapper.taskGroup().parentDAGs.size());
  Assert.assertTrue(group1.proxyTaskGroupWrapper.taskGroup().parentDAGs.contains(group2));
  Map<String,Set<String>> shouldNotSee=new HashMap<>();
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str"}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{}));
  shouldNotSee.put("String_Node_Str",new HashSet<String>());
  shouldNotSee.get("String_Node_Str").addAll(Arrays.asList(new String[]{"String_Node_Str"}));
  Set<String> seen=new HashSet<>();
  group2.prepareForEnumeration();
  for (TaskGroupEntry<TaskItem> entry=group2.getNext(); entry != null; entry=group2.getNext()) {
    Assert.assertTrue(shouldNotSee.containsKey(entry.key()));
    Assert.assertFalse(seen.contains(entry.key()));
    Sets.SetView<String> common=Sets.intersection(shouldNotSee.get(entry.key()),seen);
    if (common.size() > 0) {
      Assert.assertTrue("String_Node_Str" + common + "String_Node_Str"+ entry.key(),false);
    }
    seen.add(entry.key());
    group2.reportCompletion(entry);
  }
  Assert.assertEquals(19,seen.size());
  Set<String> expectedToSee=new HashSet<>();
  expectedToSee.addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
  Sets.SetView<String> diff=Sets.difference(seen,expectedToSee);
  Assert.assertEquals(0,diff.size());
  seen.clear();
  TaskGroup group1Proxy=group1.proxyTaskGroupWrapper.taskGroup();
  group1Proxy.prepareForEnumeration();
  for (TaskGroupEntry<TaskItem> entry=group1Proxy.getNext(); entry != null; entry=group1Proxy.getNext()) {
    Assert.assertTrue(shouldNotSee.containsKey(entry.key()));
    Assert.assertFalse(seen.contains(entry.key()));
    Sets.SetView<String> common=Sets.intersection(shouldNotSee.get(entry.key()),seen);
    if (common.size() > 0) {
      Assert.assertTrue("String_Node_Str" + common + "String_Node_Str"+ entry.key(),false);
    }
    seen.add(entry.key());
    group1Proxy.reportCompletion(entry);
  }
  Assert.assertEquals(13,seen.size());
  expectedToSee.clear();
  expectedToSee.addAll(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"}));
}