Program: 85992
Project: 85992
Buggy source:
@Test public void testUpdateACLForWorkflowWithAnExistingACL() throws Exception {
  Map<String,String> userEntries=new HashMap<>();
  Map<String,String> grpEntries=new HashMap<>();
  User user2=new User(workspace,WorkflowUtil.USER2_LOGIN,WorkflowUtil.USER2_NAME,WorkflowUtil.USER2_MAIL,"String_Node_Str");
  User user3=new User(workspace,WorkflowUtil.USER3_LOGIN,WorkflowUtil.USER3_NAME,WorkflowUtil.USER3_MAIL,"String_Node_Str");
  UserGroup group1=new UserGroup(workspace,WorkflowUtil.GRP1_ID);
  WorkflowModel workflowModel=new WorkflowModel(workspace,WorkflowUtil.WORKSPACE_ID,user,"String_Node_Str");
  ACL acl=new ACL();
  acl.addEntry(user2,ACL.Permission.READ_ONLY);
  acl.addEntry(group1,ACL.Permission.FULL_ACCESS);
  workflowModel.setAcl(acl);
  userEntries.put(user.getLogin(),ACL.Permission.FORBIDDEN.name());
  userEntries.put(user2.getLogin(),ACL.Permission.FORBIDDEN.name());
  userEntries.put(user3.getLogin(),ACL.Permission.FULL_ACCESS.name());
  group1.addUser(user2);
  group1.addUser(user);
  grpEntries.put(group1.getId(),ACL.Permission.FULL_ACCESS.name());
  Mockito.when(userManager.checkWorkspaceReadAccess(WorkflowUtil.WORKSPACE_ID)).thenReturn(user);
  Mockito.when(em.find(WorkflowModel.class,new WorkflowModelKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.WORKFLOW_MODEL_ID))).thenReturn(workflowModel);
  Mockito.when(em.find(User.class,new UserKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.USER_LOGIN))).thenReturn(user);
  Mockito.when(em.find(User.class,new UserKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.USER2_LOGIN))).thenReturn(user2);
  Mockito.when(em.find(User.class,new UserKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.USER3_LOGIN))).thenReturn(user3);
  WorkflowModel workflow=workflowManagerBean.updateACLForWorkflow(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.WORKFLOW_MODEL_ID,userEntries,grpEntries);
  Assert.assertEquals(workflow.getAcl().getGroupEntries().size(),1);
  Assert.assertEquals(workflow.getAcl().getUserEntries().size(),3);
  Assert.assertEquals(workflow.getAcl().getUserEntries().get(user).getPermission(),ACL.Permission.FORBIDDEN);
  Assert.assertEquals(workflow.getAcl().getUserEntries().get(user2).getPermission(),ACL.Permission.FORBIDDEN);
  Assert.assertEquals(workflow.getAcl().getUserEntries().get(user3).getPermission(),ACL.Permission.FULL_ACCESS);
}

Fixed version (ground truth):
@Test public void testUpdateACLForWorkflowWithAnExistingACL() throws Exception {
  Map<String,String> userEntries=new HashMap<>();
  Map<String,String> grpEntries=new HashMap<>();
  User user2=new User(workspace,WorkflowUtil.USER2_LOGIN,WorkflowUtil.USER2_NAME,WorkflowUtil.USER2_MAIL,"String_Node_Str");
  User user3=new User(workspace,WorkflowUtil.USER3_LOGIN,WorkflowUtil.USER3_NAME,WorkflowUtil.USER3_MAIL,"String_Node_Str");
  UserGroup group1=new UserGroup(workspace,WorkflowUtil.GRP1_ID);
  WorkflowModel workflowModel=new WorkflowModel(workspace,WorkflowUtil.WORKSPACE_ID,user,"String_Node_Str");
  ACL acl=new ACL();
  acl.addEntry(user2,ACL.Permission.READ_ONLY);
  acl.addEntry(group1,ACL.Permission.FULL_ACCESS);
  workflowModel.setAcl(acl);
  userEntries.put(user.getLogin(),ACL.Permission.FORBIDDEN.name());
  userEntries.put(user2.getLogin(),ACL.Permission.FORBIDDEN.name());
  userEntries.put(user3.getLogin(),ACL.Permission.FULL_ACCESS.name());
  group1.addUser(user2);
  group1.addUser(user);
  grpEntries.put(group1.getId(),ACL.Permission.FULL_ACCESS.name());
  Mockito.when(userManager.checkWorkspaceReadAccess(WorkflowUtil.WORKSPACE_ID)).thenReturn(user);
  Mockito.when(em.find(WorkflowModel.class,new WorkflowModelKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.WORKFLOW_MODEL_ID))).thenReturn(workflowModel);
  Mockito.when(em.find(User.class,new UserKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.USER_LOGIN))).thenReturn(user);
  Mockito.when(em.find(User.class,new UserKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.USER2_LOGIN))).thenReturn(user2);
  Mockito.when(em.find(User.class,new UserKey(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.USER3_LOGIN))).thenReturn(user3);
  Mockito.when(em.getReference(UserGroup.class,new UserGroupKey(WorkflowUtil.WORKSPACE_ID,group1.getId()))).thenReturn(group1);
  Mockito.when(em.getReference(User.class,user.getKey())).thenReturn(user);
  Mockito.when(em.getReference(User.class,user2.getKey())).thenReturn(user2);
  Mockito.when(em.getReference(User.class,user3.getKey())).thenReturn(user3);
  WorkflowModel workflow=workflowManagerBean.updateACLForWorkflow(WorkflowUtil.WORKSPACE_ID,WorkflowUtil.WORKFLOW_MODEL_ID,userEntries,grpEntries);
  Assert.assertEquals(workflow.getAcl().getGroupEntries().size(),1);
  Assert.assertEquals(workflow.getAcl().getUserEntries().size(),3);
  Assert.assertEquals(workflow.getAcl().getUserEntries().get(user).getPermission(),ACL.Permission.FORBIDDEN);
  Assert.assertEquals(workflow.getAcl().getUserEntries().get(user2).getPermission(),ACL.Permission.FORBIDDEN);
  Assert.assertEquals(workflow.getAcl().getUserEntries().get(user3).getPermission(),ACL.Permission.FULL_ACCESS);
}