Program: 63845
Project: 63845
Buggy source:
@Test public void testCollectErrors(){
  ArrayListMultimap<String,String> nodesWithErrors=ArrayListMultimap.create();
  nodesWithErrors.putAll("String_Node_Str",Arrays.asList("String_Node_Str" + "String_Node_Str","String_Node_Str" + "String_Node_Str","String_Node_Str","String_Node_Str"));
  nodesWithErrors.put("String_Node_Str","String_Node_Str" + "String_Node_Str");
  CloudbreakOrchestratorFailedException exception=new CloudbreakOrchestratorFailedException(EXCEPTION_MESSAGE,nodesWithErrors);
  Recipe failingRecipe1=new Recipe();
  failingRecipe1.setName("String_Node_Str");
  Recipe failingRecipe2=new Recipe();
  failingRecipe2.setName("String_Node_Str");
  Recipe goodRecipe=new Recipe();
  goodRecipe.setName("String_Node_Str");
  HostGroup master=new HostGroup();
  master.setName("String_Node_Str");
  master.setRecipes(Sets.newHashSet(failingRecipe1,goodRecipe));
  HostGroup worker=new HostGroup();
  worker.setName("String_Node_Str");
  worker.setRecipes(Sets.newHashSet(failingRecipe1,failingRecipe2));
  RecipeModel failingRecipeModel1=new RecipeModel("String_Node_Str",POST_AMBARI_START,"String_Node_Str");
  RecipeModel failingRecipeModel2=new RecipeModel("String_Node_Str",PRE_AMBARI_START,"String_Node_Str");
  RecipeModel goodRecipeModel=new RecipeModel("String_Node_Str",POST_AMBARI_START,"String_Node_Str");
  Map<HostGroup,List<RecipeModel>> hostgroupToRecipeMap=new HashMap<>();
  hostgroupToRecipeMap.put(master,Arrays.asList(failingRecipeModel1,goodRecipeModel));
  hostgroupToRecipeMap.put(worker,Arrays.asList(failingRecipeModel1,failingRecipeModel2));
  Set<InstanceGroup> instanceGroups=new HashSet<>();
  InstanceMetaData instanceMetaData1=new InstanceMetaData();
  instanceMetaData1.setDiscoveryFQDN("String_Node_Str");
  InstanceGroup instanceGroup1=new InstanceGroup();
  instanceGroup1.setGroupName("String_Node_Str");
  instanceGroup1.setInstanceMetaData(Sets.newHashSet(instanceMetaData1));
  InstanceMetaData instanceMetaData2=new InstanceMetaData();
  instanceMetaData2.setDiscoveryFQDN("String_Node_Str");
  InstanceGroup instanceGroup2=new InstanceGroup();
  instanceGroup2.setGroupName("String_Node_Str");
  instanceGroup2.setInstanceMetaData(Sets.newHashSet(instanceMetaData2));
  instanceGroups.add(instanceGroup1);
  instanceGroups.add(instanceGroup2);
  Set<RecipeExecutionFailure> recipeExecutionFailures=recipeExecutionFailureHandler.collectErrors(exception,hostgroupToRecipeMap,instanceGroups);
  assertEquals(3,recipeExecutionFailures.size());
  long recipe1Failures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getRecipe().getName())).count();
  assertEquals(2,recipe1Failures);
  long recipe2Failures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getRecipe().getName())).count();
  assertEquals(1,recipe2Failures);
  long workerInstanceFailures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getInstanceMetaData().getDiscoveryFQDN())).count();
  assertEquals(2,workerInstanceFailures);
  long masterInstanceFailures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getInstanceMetaData().getDiscoveryFQDN())).peek(failure -> assertEquals("String_Node_Str",failure.getRecipe().getName())).count();
  assertEquals(1,masterInstanceFailures);
}

Fixed version (ground truth):
@Test public void testCollectErrors(){
  ArrayListMultimap<String,String> nodesWithErrors=getNodesWithErrors();
  CloudbreakOrchestratorFailedException exception=new CloudbreakOrchestratorFailedException(EXCEPTION_MESSAGE,nodesWithErrors);
  Recipe failingRecipe1=new Recipe();
  failingRecipe1.setName("String_Node_Str");
  Recipe failingRecipe2=new Recipe();
  failingRecipe2.setName("String_Node_Str");
  Recipe goodRecipe=new Recipe();
  goodRecipe.setName("String_Node_Str");
  HostGroup master=new HostGroup();
  master.setName("String_Node_Str");
  master.setRecipes(Sets.newHashSet(failingRecipe1,goodRecipe));
  HostGroup worker=new HostGroup();
  worker.setName("String_Node_Str");
  worker.setRecipes(Sets.newHashSet(failingRecipe1,failingRecipe2));
  RecipeModel failingRecipeModel1=new RecipeModel("String_Node_Str",POST_AMBARI_START,"String_Node_Str");
  RecipeModel failingRecipeModel2=new RecipeModel("String_Node_Str",PRE_AMBARI_START,"String_Node_Str");
  RecipeModel goodRecipeModel=new RecipeModel("String_Node_Str",POST_AMBARI_START,"String_Node_Str");
  Map<HostGroup,List<RecipeModel>> hostgroupToRecipeMap=new HashMap<>();
  hostgroupToRecipeMap.put(master,Arrays.asList(failingRecipeModel1,goodRecipeModel));
  hostgroupToRecipeMap.put(worker,Arrays.asList(failingRecipeModel1,failingRecipeModel2));
  Set<InstanceGroup> instanceGroups=new HashSet<>();
  InstanceMetaData instanceMetaData1=new InstanceMetaData();
  instanceMetaData1.setDiscoveryFQDN("String_Node_Str");
  InstanceGroup instanceGroup1=new InstanceGroup();
  instanceGroup1.setGroupName("String_Node_Str");
  instanceGroup1.setInstanceMetaData(Sets.newHashSet(instanceMetaData1));
  InstanceMetaData instanceMetaData2=new InstanceMetaData();
  instanceMetaData2.setDiscoveryFQDN("String_Node_Str");
  InstanceGroup instanceGroup2=new InstanceGroup();
  instanceGroup2.setGroupName("String_Node_Str");
  instanceGroup2.setInstanceMetaData(Sets.newHashSet(instanceMetaData2));
  instanceGroups.add(instanceGroup1);
  instanceGroups.add(instanceGroup2);
  Set<RecipeExecutionFailure> recipeExecutionFailures=recipeExecutionFailureHandler.collectErrors(exception,hostgroupToRecipeMap,instanceGroups);
  assertEquals(3,recipeExecutionFailures.size());
  long recipe1Failures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getRecipe().getName())).count();
  assertEquals(2,recipe1Failures);
  long recipe2Failures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getRecipe().getName())).count();
  assertEquals(1,recipe2Failures);
  long workerInstanceFailures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getInstanceMetaData().getDiscoveryFQDN())).count();
  assertEquals(2,workerInstanceFailures);
  long masterInstanceFailures=recipeExecutionFailures.stream().filter(failure -> "String_Node_Str".equals(failure.getInstanceMetaData().getDiscoveryFQDN())).peek(failure -> assertEquals("String_Node_Str",failure.getRecipe().getName())).count();
  assertEquals(1,masterInstanceFailures);
}