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 shouldThrowExceptionWhenDeletingGroupWhenNotEmpty() {
        PipelineConfig p1Config = createPipelineConfig("pipeline1", "stage1");

        PipelineConfigs group = createGroup("group", p1Config);

        PipelineGroups groups = new PipelineGroups(group);

        assertThrows(UnprocessableEntityException.class, () -> groups.deleteGroup("group"));
    }