use of com.thoughtworks.go.config.BasicPipelineConfigs in project gocd by gocd.
the class MaterialConfigServiceTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
user = "looser";
when(securityService.hasViewPermissionForGroup(user, "group1")).thenReturn(true);
when(securityService.hasViewPermissionForGroup(user, "group2")).thenReturn(false);
when(securityService.hasViewPermissionForGroup(user, "group3")).thenReturn(true);
PipelineConfigs pipelineGroup1 = new BasicPipelineConfigs();
pipelineGroup1.setGroup("group1");
PipelineConfig pipelineConfig1 = new PipelineConfig();
GitMaterialConfig gitMaterialConfig1 = new GitMaterialConfig("http://test.com");
pipelineConfig1.addMaterialConfig(gitMaterialConfig1);
GitMaterialConfig getMaterialConfig2 = new GitMaterialConfig("http://crap.com");
pipelineConfig1.addMaterialConfig(getMaterialConfig2);
pipelineGroup1.add(pipelineConfig1);
PipelineConfigs pipelineGroup2 = new BasicPipelineConfigs();
pipelineGroup2.setGroup("group2");
PipelineConfig pipelineConfig2 = new PipelineConfig();
GitMaterialConfig gitMaterialConfig3 = new GitMaterialConfig("http://another.com");
pipelineConfig2.addMaterialConfig(gitMaterialConfig3);
pipelineGroup2.add(pipelineConfig2);
PipelineConfigs pipelineGroup3 = new BasicPipelineConfigs();
pipelineGroup3.setGroup("group3");
PipelineConfig pipelineConfig3 = new PipelineConfig();
GitMaterialConfig gitMaterialConfig4 = new GitMaterialConfig("http://test.com");
pipelineConfig1.addMaterialConfig(gitMaterialConfig4);
pipelineGroup3.add(pipelineConfig3);
PipelineGroups pipelineGroups = new PipelineGroups(pipelineGroup1, pipelineGroup2, pipelineGroup3);
when(goConfigService.groups()).thenReturn(pipelineGroups);
materialConfigService = new MaterialConfigService(goConfigService, securityService);
}
use of com.thoughtworks.go.config.BasicPipelineConfigs in project gocd by gocd.
the class FanInGraphTest method shouldConstructAFaninGraph.
@Test
public void shouldConstructAFaninGraph() throws Exception {
GitMaterialConfig git = new GitMaterialConfig("giturl", "dest");
HgMaterialConfig hg = new HgMaterialConfig("hgurl", "dest");
PipelineConfig p1 = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(git));
DependencyMaterialConfig p1Dep = new DependencyMaterialConfig(p1.name(), p1.get(0).name());
PipelineConfig p2 = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(p1Dep));
PipelineConfig p3 = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(p1Dep, hg));
DependencyMaterialConfig p2Dep = new DependencyMaterialConfig(p2.name(), p2.get(0).name());
DependencyMaterialConfig p3Dep = new DependencyMaterialConfig(p3.name(), p3.get(0).name());
PipelineConfig p4 = PipelineConfigMother.pipelineConfig("p4", new MaterialConfigs(p2Dep, p3Dep));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1, p2, p3, p4));
FanInGraph faninGraph = new FanInGraph(cruiseConfig, p4.name(), null, null, null, null);
List<ScmMaterialConfig> scmMaterialNodes = faninGraph.getScmMaterials();
List<String> scmMaterialUrls = new ArrayList<>();
for (ScmMaterialConfig scmMaterialNode : scmMaterialNodes) {
scmMaterialUrls.add(scmMaterialNode.getUrl().toString());
}
assertThat(scmMaterialUrls.contains("giturl"), is(true));
assertThat(scmMaterialUrls.contains("hgurl"), is(true));
}
Aggregations