Search in sources :

Example 56 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class CreateTemplateConfigCommandTest method setup.

@BeforeEach
public void setup() {
    result = new HttpLocalizedOperationResult();
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    pipelineTemplateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 57 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class GoConfigServiceTest method shouldReturnSpecificPipelinesForAGroupAdmin.

@Test
public void shouldReturnSpecificPipelinesForAGroupAdmin() throws Exception {
    GoConfigMother configMother = new GoConfigMother();
    BasicCruiseConfig config = GoConfigMother.defaultCruiseConfig();
    GoConfigMother.enableSecurityWithPasswordFilePlugin(config);
    GoConfigMother.addUserAsSuperAdmin(config, "superadmin");
    PipelineConfig pipelineConfig1 = configMother.addPipelineWithGroup(config, "group1", "p1", "s1", "j1");
    PipelineConfig pipelineConfig2 = configMother.addPipelineWithGroup(config, "group2", "p2", "s1", "j1");
    configMother.addAdminUserForPipelineGroup(config, "groupAdmin", "group1");
    when(goConfigDao.loadForEditing()).thenReturn(config);
    expectLoad(config);
    List<PipelineConfig> pipelines = goConfigService.getAllPipelineConfigsForEditForUser(new Username("groupAdmin"));
    assertThat(pipelines, contains(pipelineConfig1));
    assertThat(pipelines, not(contains(pipelineConfig2)));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.jupiter.api.Test)

Example 58 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class GoConfigServiceTest method shouldReturnNullIfNoPipelineExistByPipelineName.

@Test
public void shouldReturnNullIfNoPipelineExistByPipelineName() throws Exception {
    GoConfigMother configMother = new GoConfigMother();
    BasicCruiseConfig config = GoConfigMother.defaultCruiseConfig();
    configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1", "job1");
    configMother.addPipelineWithGroup(config, "group1", "pipeline2", "stage1", "job1");
    configMother.addPipelineWithGroup(config, "group2", "pipeline3", "stage1", "job1");
    expectLoad(config);
    assertThat(goConfigService.findPipelineByName(new CaseInsensitiveString("invalid")), is(nullValue()));
}
Also used : GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.jupiter.api.Test)

Example 59 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class GoConfigServiceTest method shouldReturnInvalidWhenPipelineGroupPartialHasInvalidAttributeValue.

@Test
public void shouldReturnInvalidWhenPipelineGroupPartialHasInvalidAttributeValue() throws Exception {
    String groupName = "group_name";
    String md5 = "md5";
    cruiseConfig = new BasicCruiseConfig();
    expectLoad(cruiseConfig);
    new GoConfigMother().addPipelineWithGroup(cruiseConfig, groupName, "pipeline_name", "stage_name", "job_name");
    expectLoadForEditing(cruiseConfig);
    when(goConfigDao.md5OfConfigFile()).thenReturn(md5);
    String pipelineGroupContent = groupXmlWithInvalidAttributeValue(groupName);
    GoConfigValidity validity = goConfigService.groupSaver(groupName).saveXml(pipelineGroupContent, "md5");
    assertThat(validity.isValid(), Matchers.is(false));
    assertThat(((GoConfigValidity.InvalidGoConfig) validity).errorMessage(), containsString("Name is invalid. \"pipeline@$^\""));
    verify(goConfigDao, never()).updateConfig(any(UpdateConfigCommand.class));
}
Also used : GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) GoConfigValidity(com.thoughtworks.go.config.validation.GoConfigValidity) Test(org.junit.jupiter.api.Test)

Example 60 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class GoConfigServiceTest method shouldIncludeAllLocalPipelinesWithSpecificFingerprint.

@Test
public void shouldIncludeAllLocalPipelinesWithSpecificFingerprint() throws Exception {
    cruiseConfig = new BasicCruiseConfig();
    expectLoad(cruiseConfig);
    PipelineConfig pipelineConfig = new GoConfigMother().addPipelineWithGroup(cruiseConfig, "group", "pipeline_name", "stage_name", "job_name");
    GitMaterialConfig gitMaterialConfig = git("https://foo");
    MaterialConfigs materialConfigs = new MaterialConfigs(gitMaterialConfig);
    pipelineConfig.setMaterialConfigs(materialConfigs);
    List<CaseInsensitiveString> pipelineNames = goConfigService.pipelinesWithMaterial(gitMaterialConfig.getFingerprint());
    assertThat(pipelineNames, contains(new CaseInsensitiveString("pipeline_name")));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.jupiter.api.Test)

Aggregations

GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)102 Test (org.junit.jupiter.api.Test)64 Username (com.thoughtworks.go.server.domain.Username)30 BeforeEach (org.junit.jupiter.api.BeforeEach)19 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)13 GoConfigValidity (com.thoughtworks.go.config.validation.GoConfigValidity)12 File (java.io.File)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)8 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 SCM (com.thoughtworks.go.domain.scm.SCM)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)3 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)3 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)3 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)3 Configuration (com.thoughtworks.go.domain.config.Configuration)3 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)3