public void deleteGroup(String groupName) {
        Iterator<PipelineConfigs> iterator = this.iterator();
        while (iterator.hasNext()) {
            PipelineConfigs currentGroup = iterator.next();
            if (currentGroup.isNamed(groupName)) {
                if (!currentGroup.isEmpty()) {
                    throw new UnprocessableEntityException("Failed to delete group " + groupName + " because it was not empty.");
                }
                iterator.remove();
                break;
            }
        }
    }
@Test
    public void shouldDeleteGroupWithSameNameWhenEmpty() {
        PipelineConfigs group = createGroup("group", new PipelineConfig[]{});
        group.setAuthorization(new Authorization(new ViewConfig(new AdminUser(new CaseInsensitiveString("user")))));

        PipelineGroups groups = new PipelineGroups(group);
        groups.deleteGroup("group");

        assertThat(groups.size(), is(0));
    }