Search in sources :

Example 1 with CreatePipelineConfigCommand

use of com.thoughtworks.go.config.update.CreatePipelineConfigCommand in project gocd by gocd.

the class PipelineConfigService method createPipelineConfig.

public void createPipelineConfig(final Username currentUser, final PipelineConfig pipelineConfig, final LocalizedOperationResult result, final String groupName) {
    validatePluggableTasks(pipelineConfig);
    CreatePipelineConfigCommand createPipelineConfigCommand = new CreatePipelineConfigCommand(goConfigService, pipelineConfig, currentUser, result, groupName);
    update(currentUser, pipelineConfig, result, createPipelineConfigCommand);
}
Also used : CreatePipelineConfigCommand(com.thoughtworks.go.config.update.CreatePipelineConfigCommand)

Example 2 with CreatePipelineConfigCommand

use of com.thoughtworks.go.config.update.CreatePipelineConfigCommand in project gocd by gocd.

the class CachedGoConfigIntegrationTest method shouldFailWhenTryingToAddPipelineWithTheSameNameAsAnotherPipelineDefinedRemotely_EntitySave.

@Test
public void shouldFailWhenTryingToAddPipelineWithTheSameNameAsAnotherPipelineDefinedRemotely_EntitySave() throws Exception {
    assertThat(configWatchList.getCurrentConfigRepos().size(), is(1));
    repoConfigDataSource.onCheckoutComplete(configRepo.getMaterialConfig(), externalConfigRepo, latestCommit);
    assertThat(cachedGoConfig.currentConfig().hasPipelineNamed(new CaseInsensitiveString("pipe1")), is(true));
    PipelineConfig dupPipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndSvnMaterialsAtUrl("pipe1", "ut", "www.spring.com");
    try {
        goConfigDao.updateConfig(new CreatePipelineConfigCommand(goConfigService, dupPipelineConfig, Username.ANONYMOUS, new DefaultLocalizedOperationResult(), "default"), Username.ANONYMOUS);
        fail("Should have thrown");
    } catch (RuntimeException ex) {
        PipelineConfig pipe1 = goConfigService.pipelineConfigNamed(new CaseInsensitiveString("pipe1"));
        String errorMessage = dupPipelineConfig.errors().on(PipelineConfig.NAME);
        assertThat(errorMessage, containsString("You have defined multiple pipelines named 'pipe1'. Pipeline names must be unique. Source(s):"));
        Matcher matcher = Pattern.compile("^.*\\[(.*),\\s(.*)\\].*$").matcher(errorMessage);
        assertThat(matcher.matches(), is(true));
        assertThat(matcher.groupCount(), is(2));
        List<String> expectedSources = asList(dupPipelineConfig.getOriginDisplayName(), pipe1.getOriginDisplayName());
        List<String> actualSources = new ArrayList<>();
        for (int i = 1; i <= matcher.groupCount(); i++) {
            actualSources.add(matcher.group(i));
        }
        assertThat(actualSources.size(), is(expectedSources.size()));
        assertThat(actualSources.containsAll(expectedSources), is(true));
    }
}
Also used : CreatePipelineConfigCommand(com.thoughtworks.go.config.update.CreatePipelineConfigCommand) Matcher(java.util.regex.Matcher) DefaultLocalizedOperationResult(com.thoughtworks.go.server.service.result.DefaultLocalizedOperationResult) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) StringContains.containsString(org.hamcrest.core.StringContains.containsString)

Aggregations

CreatePipelineConfigCommand (com.thoughtworks.go.config.update.CreatePipelineConfigCommand)2 DefaultLocalizedOperationResult (com.thoughtworks.go.server.service.result.DefaultLocalizedOperationResult)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1