@Override public boolean hasPipeline() { return pipelinesFromAllGroups().isEmpty(); }
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 PipelineGroupNotEmptyException("Failed to delete group [" + groupName + "] not empty"); iterator.remove(); break; } } } }
@Override public List<PipelineConfig> getAllLocalPipelineConfigs(boolean excludeMembersOfRemoteEnvironments) { List<PipelineConfig> locals = new ArrayList<>(); PipelineGroups localGroups = BasicCruiseConfig.this.groups.getLocal(); for (PipelineConfigs pipelineConfigs : localGroups) { if (pipelineConfigs.getOrigin() instanceof UIConfigOrigin) { //then we have injected this so that UI has a piece to edit // we want to keep it only if there is something added if (!pipelineConfigs.isEmpty()) { for (PipelineConfig pipelineConfig : pipelineConfigs.getPipelines()) { if (excludeMembersOfRemoteEnvironments && BasicCruiseConfig.this.getEnvironments().isPipelineAssociatedWithRemoteEnvironment(pipelineConfig.name())) continue; locals.add(pipelineConfig); } } } else { //origin is local file for (PipelineConfig pipelineConfig : pipelineConfigs.getPipelines()) { if (excludeMembersOfRemoteEnvironments && BasicCruiseConfig.this.getEnvironments().isPipelineAssociatedWithRemoteEnvironment(pipelineConfig.name())) continue; locals.add(pipelineConfig); } } } return locals; }
@Test public void shouldReturnTrueWhenAllPartsEmpty(){ PipelineConfigs group = new MergePipelineConfigs( new BasicPipelineConfigs(), new BasicPipelineConfigs()); assertThat(group.isEmpty(),is(true)); } @Test
@Test public void shouldReturnFalseSomePartIsNotEmpty(){ PipelineConfigs group = new MergePipelineConfigs( new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("pipeline1")), new BasicPipelineConfigs()); assertThat(group.isEmpty(),is(false)); } @Test