Program: 60606
Project: 60606
Buggy source:
@Test public void sync(){
  UserTO inUserTO=new UserTO();
  inUserTO.setPassword("String_Node_Str");
  String userName="String_Node_Str";
  inUserTO.setUsername(userName);
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addDerivedAttribute(attributeTO("String_Node_Str",null));
  inUserTO=createUser(inUserTO);
  assertNotNull(inUserTO);
  try {
    int usersPre=userService.count();
    assertNotNull(usersPre);
    SyncTaskTO task=taskService.read(TaskType.SYNCHRONIZATION,SYNC_TASK_ID);
    assertNotNull(task);
    task.setActionsClassName(TestSyncActions.class.getName());
    UserTO template=new UserTO();
    template.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
    template.addDerivedAttribute(attributeTO("String_Node_Str",null));
    template.addResource("String_Node_Str");
    MembershipTO membershipTO=new MembershipTO();
    membershipTO.setRoleId(8L);
    membershipTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
    template.addMembership(membershipTO);
    task.setUserTemplate(template);
    taskService.update(task.getId(),task);
    SyncTaskTO actual=taskService.read(TaskType.SYNCHRONIZATION,task.getId());
    assertNotNull(actual);
    assertEquals(task.getId(),actual.getId());
    assertEquals(TestSyncActions.class.getName(),actual.getActionsClassName());
    execSyncTask(SYNC_TASK_ID,50,false);
    UserTO userTO=userService.read(inUserTO.getId());
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getUsername());
    assertEquals(ActivitiDetector.isActivitiEnabledForUsers() ? "String_Node_Str" : "String_Node_Str",userTO.getStatus());
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    assertTrue(Integer.valueOf(userTO.getAttributeMap().get("String_Node_Str").getValues().get(0)) <= 10);
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    assertEquals(2,userTO.getResources().size());
    assertTrue(userTO.getResources().contains("String_Node_Str"));
    assertTrue(userTO.getResources().contains("String_Node_Str"));
    assertEquals(1,userTO.getMemberships().size());
    assertTrue(userTO.getMemberships().get(0).getAttributeMap().containsKey("String_Node_Str"));
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    int usersPost=userService.count();
    assertNotNull(usersPost);
    assertEquals(usersPre + 9,usersPost);
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getStatus());
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getStatus());
  }
  finally {
    for (int i=0; i < 10; i++) {
      String cUserName="String_Node_Str" + i;
      UserTO cUserTO=userService.read(cUserName);
      userService.delete(cUserTO.getId());
    }
  }
}

Fixed version (ground truth):
@Test public void sync(){
  removeTestUsers();
  UserTO inUserTO=new UserTO();
  inUserTO.setPassword("String_Node_Str");
  String userName="String_Node_Str";
  inUserTO.setUsername(userName);
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
  inUserTO.addDerivedAttribute(attributeTO("String_Node_Str",null));
  inUserTO=createUser(inUserTO);
  assertNotNull(inUserTO);
  try {
    int usersPre=userService.count();
    assertNotNull(usersPre);
    SyncTaskTO task=taskService.read(TaskType.SYNCHRONIZATION,SYNC_TASK_ID);
    assertNotNull(task);
    task.setActionsClassName(TestSyncActions.class.getName());
    UserTO template=new UserTO();
    template.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
    template.addDerivedAttribute(attributeTO("String_Node_Str",null));
    template.addResource("String_Node_Str");
    MembershipTO membershipTO=new MembershipTO();
    membershipTO.setRoleId(8L);
    membershipTO.addAttribute(attributeTO("String_Node_Str","String_Node_Str"));
    template.addMembership(membershipTO);
    task.setUserTemplate(template);
    taskService.update(task.getId(),task);
    SyncTaskTO actual=taskService.read(TaskType.SYNCHRONIZATION,task.getId());
    assertNotNull(actual);
    assertEquals(task.getId(),actual.getId());
    assertEquals(TestSyncActions.class.getName(),actual.getActionsClassName());
    execSyncTask(SYNC_TASK_ID,50,false);
    UserTO userTO=userService.read(inUserTO.getId());
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getUsername());
    assertEquals(ActivitiDetector.isActivitiEnabledForUsers() ? "String_Node_Str" : "String_Node_Str",userTO.getStatus());
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    assertTrue(Integer.valueOf(userTO.getAttributeMap().get("String_Node_Str").getValues().get(0)) <= 10);
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    assertEquals(2,userTO.getResources().size());
    assertTrue(userTO.getResources().contains("String_Node_Str"));
    assertTrue(userTO.getResources().contains("String_Node_Str"));
    assertEquals(1,userTO.getMemberships().size());
    assertTrue(userTO.getMemberships().get(0).getAttributeMap().containsKey("String_Node_Str"));
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getAttributeMap().get("String_Node_Str").getValues().get(0));
    int usersPost=userService.count();
    assertNotNull(usersPost);
    assertEquals(usersPre + 9,usersPost);
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getStatus());
    userTO=userService.read("String_Node_Str");
    assertNotNull(userTO);
    assertEquals("String_Node_Str",userTO.getStatus());
  }
  finally {
    removeTestUsers();
  }
}