Search in sources :

Example 66 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class MaterialRevisionBuilder method depInstance.

public Tuple depInstance(String pipelineName, int counter, Date modifiedTime, Tuple... buildCause) {
    String key = key(pipelineName, counter, modifiedTime);
    if (!instanceToRevision.containsKey(key)) {
        if (buildCause.length == 0) {
            throw new RuntimeException("Cannot create instance without a buildcause. You can retrive it without buildcause once it has been created");
        }
        DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(STAGE_NAME));
        DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, counter, "label", STAGE_NAME, 1);
        instanceToRevision.put(key, revision.convert(material, modifiedTime));
        final long id = getNextId();
        org.mockito.Mockito.when(pipelineDao.findPipelineByNameAndCounter(pipelineName, counter)).thenReturn(pipeline(id));
        org.mockito.Mockito.when(materialRepository.findMaterialRevisionsForPipeline(id)).thenReturn(buildCauseOfThisPipeline(buildCause));
    }
    MaterialRevision materialRevision = instanceToRevision.get(key);
    Materials materials = new Materials();
    for (MaterialRevision revision : buildCauseOfThisPipeline(buildCause)) {
        materials.add(revision.getMaterial());
    }
    PipelineConfig config = new PipelineConfig(new CaseInsensitiveString(pipelineName), materials.convertToConfigs(), new StageConfig(new CaseInsensitiveString(STAGE_NAME), new JobConfigs()));
    return new Tuple(new PipelineConfigDependencyGraph(config, dependencyGraphsFor(buildCause)), materialRevision);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 67 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldPersistMaterialsWithRealPassword.

@Test
public void shouldPersistMaterialsWithRealPassword() {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    addRevision(materialRevisions, MaterialsMother.svnMaterial("http://username:password@localhost"));
    addRevision(materialRevisions, MaterialsMother.hgMaterial("http://username:password@localhost"));
    addRevision(materialRevisions, new GitMaterial("git://username:password@localhost"));
    addRevision(materialRevisions, new P4Material("localhost:1666", "view"));
    BuildCause buildCause = BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS);
    Pipeline pipeline = new Pipeline("Test", buildCause);
    save(pipeline);
    Pipeline loaded = pipelineDao.mostRecentPipeline("Test");
    Materials materials = loaded.getMaterials();
    for (Material material : materials) {
        assertThat(((ScmMaterial) material).getUrl(), not(containsString("******")));
    }
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.jupiter.api.Test)

Example 68 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModifications.

@Test
public void shouldCreateBuildCauseWithModifications() throws Exception {
    repositoryForMaterial(new SvnTestRepo(tempDir));
    prepareAPipelineWithHistory();
    checkInFiles("foo");
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    materialDatabaseUpdater.updateMaterial(svnMaterial);
    buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
    assertThat(result.canContinue(), is(true));
    BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(mingleConfig.name());
    MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
    assertThat(materialRevisions.getRevisions().size(), is(1));
    Materials materials = materialRevisions.getMaterials();
    assertThat(materials.size(), is(1));
    assertThat(materials.get(0), is(svnMaterial));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.jupiter.api.Test)

Example 69 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal.

@Test
public void shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal() throws Exception {
    SvnTestRepoWithExternal repo = new SvnTestRepoWithExternal(tempDir);
    repositoryForMaterial(repo);
    prepareAPipelineWithHistory();
    checkInFiles("foo");
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    materialDatabaseUpdater.updateMaterial(svnMaterial);
    buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
    assertThat(result.canContinue(), is(true));
    BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(mingleConfig.name());
    MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
    assertThat(materialRevisions.getRevisions().size(), is(2));
    Materials materials = materialRevisions.getMaterials();
    assertThat(materials.size(), is(2));
    assertThat(materials.get(0), is(svnMaterial));
    SvnMaterial external = (SvnMaterial) materials.get(1);
    assertThat(external.getUrl(), is(repo.externalRepositoryUrl()));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) SvnTestRepoWithExternal(com.thoughtworks.go.helper.SvnTestRepoWithExternal) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.jupiter.api.Test)

Example 70 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class PipelineServiceIntegrationTest method shouldReturnPMRsInCorrectOrder.

@Test
public void shouldReturnPMRsInCorrectOrder() throws Exception {
    File file1 = new File("file1");
    File file2 = new File("file2");
    File file3 = new File("file3");
    File file4 = new File("file4");
    Material hg1 = new HgMaterial("url1", "Dest1");
    Material hg2 = new HgMaterial("url2", "Dest2");
    String[] hgRevs = new String[] { "h1", "h2" };
    Date latestModification = new Date();
    u.checkinFiles(hg2, "h2", a(file1, file2, file3, file4), ModifiedAction.added, org.apache.commons.lang3.time.DateUtils.addDays(latestModification, -1));
    u.checkinFiles(hg1, "h1", a(file1, file2, file3, file4), ModifiedAction.added, latestModification);
    ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg1), u.m(hg2));
    u.runAndPass(pair01, hgRevs);
    Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
    MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
    Materials materials = materialRevisions.getMaterials();
    assertThat(materials.size(), is(2));
    assertThat(materials.get(0), is(hg1));
    assertThat(materials.get(1), is(hg2));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) File(java.io.File) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)70 Test (org.junit.jupiter.api.Test)52 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)31 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)18 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)17 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)17 Modification (com.thoughtworks.go.domain.materials.Modification)15 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)14 Material (com.thoughtworks.go.domain.materials.Material)14 File (java.io.File)14 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)11 TimeProvider (com.thoughtworks.go.util.TimeProvider)10 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 Date (java.util.Date)6 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5