use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class TemplateConfigServiceTest method shouldPopulateErrorInResultOnFailure.
@Test
public void shouldPopulateErrorInResultOnFailure() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
Username user = new Username(new CaseInsensitiveString("user"));
String templateName = "template-name";
PipelineTemplateConfig pipelineTemplateConfig = new PipelineTemplateConfig(new CaseInsensitiveString(templateName), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
String errorMessage = "invalid template";
doThrow(new GoConfigInvalidException(new GoConfigMother().defaultCruiseConfig(), errorMessage)).when(goConfigService).updateConfig(any(CreateTemplateConfigCommand.class), any(Username.class));
service.createTemplateConfig(user, pipelineTemplateConfig, result);
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.unprocessableEntity(LocalizedMessage.string("ENTITY_CONFIG_VALIDATION_FAILED", "template", templateName, errorMessage));
assertThat(result.toString(), is(expectedResult.toString()));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class CcTrayViewAuthorityTest method setUp.
@Before
public void setUp() throws Exception {
configService = mock(GoConfigService.class);
service = new CcTrayViewAuthority(configService);
configMother = new GoConfigMother();
config = GoConfigMother.defaultCruiseConfig();
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigRepoConfigTest method validate_shouldNotAllowDisabledAutoUpdate.
@Test
public void validate_shouldNotAllowDisabledAutoUpdate() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
GoConfigMother mother = new GoConfigMother();
SvnMaterialConfig svn = new SvnMaterialConfig("url", false);
svn.setAutoUpdate(false);
ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(svn, "plug");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
configRepoConfig.validate(null);
assertThat(configRepoConfig.errors().isEmpty(), is(false));
assertThat(configRepoConfig.errors().on(ConfigRepoConfig.AUTO_UPDATE), is("Configuration repository material url must have autoUpdate enabled"));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigRepoConfigTest method validate_shouldNotAllowPipelineWithSameRepositoryAndDisabledAutoUpdate.
@Test
public void validate_shouldNotAllowPipelineWithSameRepositoryAndDisabledAutoUpdate() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
GoConfigMother mother = new GoConfigMother();
MaterialConfigs materialConfigs = new MaterialConfigs();
SvnMaterialConfig svn = new SvnMaterialConfig("url", false);
svn.setAutoUpdate(false);
materialConfigs.add(svn);
ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(svn, "plug");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
PipelineConfig pipeline1 = mother.addPipeline(cruiseConfig, "badpipe", "build", materialConfigs, "build");
configRepoConfig.validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
assertThat(svn.errors().isEmpty(), is(false));
assertThat(svn.errors().on(ScmMaterialConfig.AUTO_UPDATE), is("Material of type Subversion (url) is specified as a configuration repository and pipeline material with disabled autoUpdate. All copies of this material must have autoUpdate enabled or configuration repository must be removed"));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class PipelineConfigSaveValidationContextTest method shouldGetAllMaterialsByFingerPrint.
@Test
public void shouldGetAllMaterialsByFingerPrint() throws Exception {
CruiseConfig cruiseConfig = new GoConfigMother().cruiseConfigWithPipelineUsingTwoMaterials();
MaterialConfig expectedMaterial = MaterialConfigsMother.multipleMaterialConfigs().get(1);
PipelineConfigSaveValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig);
MaterialConfigs allMaterialsByFingerPrint = context.getAllMaterialsByFingerPrint(expectedMaterial.getFingerprint());
assertThat(allMaterialsByFingerPrint.size(), is(1));
assertThat(allMaterialsByFingerPrint.first(), is(expectedMaterial));
}
Aggregations