@Test public void shouldLoadShallowCloneFlagForGitMaterialsBaseOnTheirOwnPipelineConfig() throws IOException { GitTestRepo testRepo = new GitTestRepo(); PipelineConfig shallowPipeline = PipelineConfigMother.pipelineConfig( "shallowPipeline", new StageConfig( new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig("job-one")))); shallowPipeline.materialConfigs().clear(); shallowPipeline.addMaterialConfig( new GitMaterialConfig(testRepo.projectRepositoryUrl(), null, true)); configHelper.addPipeline(shallowPipeline); PipelineConfig fullPipeline = PipelineConfigMother.pipelineConfig( "fullPipeline", new StageConfig( new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig("job-one")))); fullPipeline.materialConfigs().clear(); fullPipeline.addMaterialConfig( new GitMaterialConfig(testRepo.projectRepositoryUrl(), null, false)); configHelper.addPipeline(fullPipeline); Pipeline shallowPipelineInstance = createAndLoadModifyOneFilePipeline(shallowPipeline); MaterialRevisions shallowRevisions = shallowPipelineInstance.getBuildCause().getMaterialRevisions(); assertThat( ((GitMaterial) shallowRevisions.getRevisions().get(0).getMaterial()).isShallowClone(), is(true)); Pipeline fullPipelineInstance = createAndLoadModifyOneFilePipeline(fullPipeline); MaterialRevisions fullRevisions = fullPipelineInstance.getBuildCause().getMaterialRevisions(); assertThat( ((GitMaterial) fullRevisions.getRevisions().get(0).getMaterial()).isShallowClone(), is(false)); }
@Test // if other materials have expansion concept at some point, add more tests here public void shouldSetPasswordForExpandedSvnMaterial() { PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig( "last", new StageConfig( new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig("job-one")))); pipelineConfig.materialConfigs().clear(); SvnMaterialConfig materialConfig = svnRepo.materialConfig(); materialConfig.setConfigAttributes( Collections.singletonMap(SvnMaterialConfig.CHECK_EXTERNALS, String.valueOf(true))); materialConfig.setPassword("boozer"); pipelineConfig.addMaterialConfig(materialConfig); configHelper.addPipeline(pipelineConfig); Pipeline loadedPipeline = createAndLoadModifyOneFilePipeline(pipelineConfig); MaterialRevisions revisions = loadedPipeline.getBuildCause().getMaterialRevisions(); assertThat(revisions.getRevisions().size(), is(2)); assertThat( ((SvnMaterial) revisions.getRevisions().get(0).getMaterial()).getPassword(), is("boozer")); assertThat( ((SvnMaterial) revisions.getRevisions().get(1).getMaterial()).getPassword(), is("boozer")); }