use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ValueStreamMapServiceTest method currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision.
@Test
public void currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision() {
/*
/-> P1 -- \
git -> p3
\-> P2 -- /
*/
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
Modification rev1 = ModificationsMother.oneModifiedFile("rev1");
Modification rev2 = ModificationsMother.oneModifiedFile("rev2");
Modification rev3 = ModificationsMother.oneModifiedFile("rev3");
BuildCause p1buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3, rev2, rev1));
BuildCause p2buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3));
BuildCause p3buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1), dependencyMaterial("p2", 1)), new ArrayList<>(), new ArrayList<>());
when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
PipelineConfig p3Config = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
assertNull(graph.getCurrentPipeline().getViewType());
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel.
@Test
public void shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel() throws Exception {
/*
* +-------------+
* | v
* g---->p1---->p2 ---> p3
* | ^
* -------------+
*
* */
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
String p1 = "p1";
String p2 = "p2";
String p3 = "p3";
BuildCause p3buildCause = createBuildCause(asList(p1, p2), new ArrayList<>());
BuildCause p2buildCause = createBuildCause(asList(p1), asList(git));
BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
when(pipelineService.buildCauseFor(p3, 1)).thenReturn(p3buildCause);
when(pipelineService.buildCauseFor(p2, 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor(p1, 1)).thenReturn(p1buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig(p1, new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig(p2, new MaterialConfigs(gitConfig, new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name())));
PipelineConfig p3Config = PipelineConfigMother.pipelineConfig(p3, new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "p3-label", p3buildCause));
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(p3, 1, user, result);
List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
assertThat(graph.getCurrentPipeline().getName(), is(p3));
assertThat(nodesAtEachLevel.size(), is(4));
List<Node> firstLevel = nodesAtEachLevel.get(0);
assertThat(firstLevel.size(), is(1));
assertLayerHasNode(firstLevel, git.getDisplayName(), git.getFingerprint(), p1);
List<Node> secondLevel = nodesAtEachLevel.get(1);
assertThat(secondLevel.size(), is(2));
assertLayerHasNode(secondLevel, p1, p1, p2);
assertLayerHasDummyNodeWithDependents(secondLevel, p2);
List<Node> thirdLevel = nodesAtEachLevel.get(2);
assertThat(thirdLevel.size(), is(2));
assertLayerHasNode(thirdLevel, p2, p2, p3);
assertLayerHasDummyNodeWithDependents(thirdLevel, p3);
List<Node> fourthLevel = nodesAtEachLevel.get(3);
assertThat(fourthLevel.size(), is(1));
assertLayerHasNode(fourthLevel, p3, p3);
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigMigrationIntegrationTest method migration99_shouldMigrateHgMaterialsUnderConfigRepoAndRetainOnlyTheMinimalRequiredAttributes.
@Test
public void migration99_shouldMigrateHgMaterialsUnderConfigRepoAndRetainOnlyTheMinimalRequiredAttributes() throws Exception {
String configXml = "<cruise schemaVersion='98'>" + "<config-repos>\n" + " <config-repo pluginId=\"json.config.plugin\" id=\"config-repo-1\">\n" + " <hg url=\"test-repo\" dest='dest' autoUpdate='true' invertFilter='true' materialName=\"foo\">\n" + " <filter>\n" + " <ignore pattern=\"asdsd\" />\n" + " </filter>\n" + " </hg>" + " </config-repo>\n" + "</config-repos>" + "</cruise>";
assertThat(configXml, containsString("<filter>"));
assertThat(configXml, containsString("dest='dest'"));
assertThat(configXml, containsString("autoUpdate='true'"));
assertThat(configXml, containsString("invertFilter='true'"));
String migratedContent = migrateXmlString(configXml, 98);
CruiseConfig cruiseConfig = loader.deserializeConfig(migratedContent);
MaterialConfig materialConfig = cruiseConfig.getConfigRepos().getConfigRepo("config-repo-1").getMaterialConfig();
assertThat(migratedContent, not(containsString("<filter>")));
assertThat(migratedContent, not(containsString("dest='dest'")));
assertThat(migratedContent, not(containsString("invertFilter='true'")));
assertThat(materialConfig.getFolder(), is(Matchers.isNull()));
assertThat(materialConfig.filter().size(), is(0));
assertThat(materialConfig.isAutoUpdate(), is(true));
assertThat(materialConfig.isInvertFilter(), is(false));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method autoUpdateShouldUnderstandTrue.
@Test
public void autoUpdateShouldUnderstandTrue() throws Exception {
MaterialConfig hgMaterial = xmlLoader.fromXmlPartial("<hg url=\"file:///tmp/testSvnRepo/project1/trunk\" autoUpdate=\"true\"/>", HgMaterialConfig.class);
assertThat(hgMaterial.isAutoUpdate(), is(true));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldLoadFromSvnPartial.
@Test
public void shouldLoadFromSvnPartial() throws Exception {
String buildXmlPartial = "<svn url=\"http://foo.bar\" username=\"cruise\" password=\"password\" materialName=\"http___foo.bar\"/>";
MaterialConfig materialConfig = xmlLoader.fromXmlPartial(toInputStream(buildXmlPartial), SvnMaterialConfig.class);
MaterialConfig svnMaterial = MaterialConfigsMother.svnMaterialConfig("http://foo.bar", null, "cruise", "password", false, null);
assertThat(materialConfig, is(svnMaterial));
}
Aggregations