@Test
public void groupLengthNotMatchProfileLength() throws Exception {

    User user = userRepo.findOneByUsername(username);
    assertNull("User already exists", user);
    String group = groupname + "1" + config.getArraySeparator() + groupname + "2" + config.getArraySeparator()
            + groupname + "3";
    String profile = Profile.Editor.name();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader(this.config.getEmailKey(), email);
    request.addHeader(this.config.getFirstnameKey(), firstname);
    request.addHeader(this.config.getGroupKey(), group);
    request.addHeader(this.config.getProfileKey(), profile);
    request.addHeader(this.config.getSurnameKey(), surname);
    request.addHeader(this.config.getUsernameKey(), username);
    request.addHeader(this.config.getOrganisationKey(), organisation);
    utils.setupUser(request, this.config);
    // Checks
    user = userRepo.findOneByUsername(username);
    assertNotNull("User was not created", user);
    assertSame("The profile should be the highest in the list", Profile.Editor, user.getProfile());
    List<Integer> idGroups = userGroupRepo.findGroupIds(UserGroupSpecs.hasUserId(user.getId()));
    assertSame("Groups size is wrong", idGroups.size(), 3);
    List<UserGroup> groups = userGroupRepo.findAll(UserGroupSpecs.hasUserId(user.getId()));
    for (UserGroup ug : groups) {
        if (ug.getProfile().equals(Profile.Editor)) {
            assertTrue(ug.getGroup().getName().equalsIgnoreCase(groupname + "1"));
        } else if (ug.getProfile().equals(Profile.Guest)) {
            assertTrue(ug.getGroup().getName().equalsIgnoreCase(groupname + "2")
                    || ug.getGroup().getName().equalsIgnoreCase(groupname + "3"));
        } else {
            assertTrue("We have a usergroup we shouldn't have", false);
        }
    }
}