Search in sources :

Example 41 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldHaveUrlInGitMaterials.

@Test
public void shouldHaveUrlInGitMaterials() throws SQLException {
    Materials gitMaterials = MaterialsMother.gitMaterials("gitUrl");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(gitMaterials.convertToConfigs());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    Materials materials = pipelineFromDB.getMaterials();
    GitMaterial gitMaterial = (GitMaterial) materials.get(0);
    assertThat(gitMaterial.getUrl(), is("gitUrl"));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.jupiter.api.Test)

Example 42 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldUnPauseAPausedPipeline.

@Test
public void shouldUnPauseAPausedPipeline() throws Exception {
    PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("some-pipeline", "dev");
    schedulePipelineWithStages(mingleConfig);
    pipelineDao.pause(mingleConfig.name().toString(), "cause", "by");
    pipelineDao.unpause(mingleConfig.name().toString());
    PipelinePauseInfo actual = pipelineDao.pauseState(mingleConfig.name().toString());
    PipelinePauseInfo expected = new PipelinePauseInfo(false, null, null);
    assertThat(actual, is(expected));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Test(org.junit.jupiter.api.Test)

Example 43 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldThrowExceptionWhenBuildCauseIsAskedForAPipelineWithInvalidCounter.

@Test
public void shouldThrowExceptionWhenBuildCauseIsAskedForAPipelineWithInvalidCounter() {
    String pipelineName = "P1";
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages(pipelineName, "S1");
    String username = "username";
    BuildCause manualForced = BuildCause.createManualForced(modifyOneFile(pipelineConfig), new Username(new CaseInsensitiveString(username)));
    Pipeline pipeline = dbHelper.schedulePipeline(pipelineConfig, manualForced, username, new TimeProvider());
    dbHelper.pass(pipeline);
    BuildCause buildCause = pipelineDao.findBuildCauseOfPipelineByNameAndCounter(pipelineName, 1);
    assertThat(buildCause, is(notNullValue()));
    try {
        pipelineDao.findBuildCauseOfPipelineByNameAndCounter(pipelineName, 10);
        fail("should have thrown RecordNotFoundException");
    } catch (Exception e) {
        assertThat(e instanceof RecordNotFoundException, is(true));
        assertThat(e.getMessage(), is("Pipeline P1 with counter 10 was not found"));
    }
}
Also used : RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) SQLException(java.sql.SQLException) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.jupiter.api.Test)

Example 44 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveHgMaterialsFromDatabase.

@Test
public void shouldStoreAndRetrieveHgMaterialsFromDatabase() throws SQLException {
    Materials materials = MaterialsMother.hgMaterials("hgUrl", "hgdir");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
    final MaterialRevisions originalMaterialRevision = multipleModificationsInHg(pipelineConfig);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(originalMaterialRevision, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    save(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    final MaterialRevisions materialRevisions = pipelineFromDB.getBuildCause().getMaterialRevisions();
    assertEquals(originalMaterialRevision, materialRevisions);
    assertThat(materialRevisions.getMaterialRevision(0).getRevision().getRevision(), is("9fdcf27f16eadc362733328dd481d8a2c29915e1"));
    assertThat(pipelineFromDB.getMaterials(), is(materials));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.jupiter.api.Test)

Example 45 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldReturnPageNumberOfThePageInWhichThePIMWouldBePresent.

@Test
public void shouldReturnPageNumberOfThePageInWhichThePIMWouldBePresent() throws Exception {
    PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("some-pipeline", "dev");
    Pipeline pipeline1 = schedulePipelineWithStages(mingleConfig);
    Pipeline pipeline2 = schedulePipelineWithStages(mingleConfig);
    Pipeline pipeline3 = schedulePipelineWithStages(mingleConfig);
    Pipeline pipeline4 = schedulePipelineWithStages(mingleConfig);
    Pipeline pipeline5 = schedulePipelineWithStages(mingleConfig);
    assertThat(pipelineDao.getPageNumberForCounter("some-pipeline", pipeline4.getCounter(), 1), is(2));
    assertThat(pipelineDao.getPageNumberForCounter("some-pipeline", pipeline5.getCounter(), 1), is(1));
    assertThat(pipelineDao.getPageNumberForCounter("some-pipeline", pipeline1.getCounter(), 2), is(3));
    assertThat(pipelineDao.getPageNumberForCounter("some-pipeline", pipeline2.getCounter(), 3), is(2));
    assertThat(pipelineDao.getPageNumberForCounter("some-pipeline", pipeline3.getCounter(), 10), is(1));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Test(org.junit.jupiter.api.Test)

Aggregations

PipelineConfig (com.thoughtworks.go.config.PipelineConfig)285 Test (org.junit.jupiter.api.Test)185 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)142 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)52 TimeProvider (com.thoughtworks.go.util.TimeProvider)33 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)24 Test (org.junit.Test)23 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)21 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)19 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 Materials (com.thoughtworks.go.config.materials.Materials)14 Date (java.util.Date)14 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)13 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)13 StageConfig (com.thoughtworks.go.config.StageConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 Pipeline (com.thoughtworks.go.domain.Pipeline)12 Modification (com.thoughtworks.go.domain.materials.Modification)12