Search in sources :

Example 16 with GitMaterial

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

the class GitMaterialInstance method toOldMaterial.

@Override
public Material toOldMaterial(String name, String folder, String password) {
    GitMaterial git = new GitMaterial(url, branch, folder);
    setName(name, git);
    git.setSubmoduleFolder(submoduleFolder);
    git.setId(id);
    return git;
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial)

Example 17 with GitMaterial

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

the class PipelineSqlMapDaoCachingTest method shouldNotInvalidateCacheOfPipelineInstancesTriggeredWithMaterialRevision_WhenAPipelineInstanceIsCreatedWithDifferentMaterial.

@Test
public void shouldNotInvalidateCacheOfPipelineInstancesTriggeredWithMaterialRevision_WhenAPipelineInstanceIsCreatedWithDifferentMaterial() throws Exception {
    GitMaterialInstance materialInstance = new GitMaterialInstance("url", "branch", "submodule", "flyweight");
    String cacheKey = pipelineDao.cacheKeyForPipelineInstancesTriggeredWithDependencyMaterial("p1", materialInstance.getFingerprint(), "r1");
    List<PipelineIdentifier> result = Arrays.asList(new PipelineIdentifier("p1", 1, "1"));
    when(mockTemplate.queryForList(eq("pipelineInstancesTriggeredOffOfMaterialRevision"), anyString())).thenReturn(result);
    List<PipelineIdentifier> actual = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial("p1", materialInstance, "r1");
    assertThat(actual, Matchers.is(result));
    assertThat(goCache.get(cacheKey), is(result));
    MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(new GitMaterial("url", "branch"), new Modification("user", "comment", "email", new Date(), "r2")));
    Pipeline pipeline = new Pipeline("p1", BuildCause.createWithModifications(materialRevisions, ""));
    pipelineDao.save(pipeline);
    assertThat(goCache.get(cacheKey), is(result));
}
Also used : GitMaterialInstance(com.thoughtworks.go.domain.materials.git.GitMaterialInstance) Modification(com.thoughtworks.go.domain.materials.Modification) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 18 with GitMaterial

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

the class MaterialCheckerTest method updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore.

@Test
public void updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore() {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
    GitMaterial gitMaterial = new GitMaterial("git://foo");
    BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
    when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(10L);
    materialChecker.updateChangedRevisions(pipelineName, buildCause);
    MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
    assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L), mod(9L), mod(8L))));
    assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(false));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 19 with GitMaterial

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

the class MaterialCheckerTest method updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore.

@Test
public void updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore() {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
    GitMaterial gitMaterial = new GitMaterial("git://foo");
    BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
    when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(9L);
    materialChecker.updateChangedRevisions(pipelineName, buildCause);
    MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
    assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L))));
    assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(true));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 20 with GitMaterial

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

the class MaterialDatabaseUpdaterTest method shouldThrowExceptionWithLongDescriptionOfMaterialWhenUpdateFails.

@Test
public void shouldThrowExceptionWithLongDescriptionOfMaterialWhenUpdateFails() throws Exception {
    Material material = new GitMaterial("url", "branch");
    Exception exception = new RuntimeException("failed");
    String message = "Modification check failed for material: " + material.getLongDescription();
    ServerHealthState error = ServerHealthState.error(message, exception.getMessage(), HealthStateType.general(HealthStateScope.forMaterial(material)));
    when(materialRepository.findMaterialInstance(material)).thenThrow(exception);
    try {
        materialDatabaseUpdater.updateMaterial(material);
        fail("should have thrown exception");
    } catch (Exception e) {
        assertThat(e, is(exception));
    }
    verify(healthService).update(error);
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Material(com.thoughtworks.go.domain.materials.Material) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) Test(org.junit.Test)

Aggregations

GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)146 Test (org.junit.Test)137 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)70 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)55 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)31 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)20 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)13 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 Modification (com.thoughtworks.go.domain.materials.Modification)11 File (java.io.File)11 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)10 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)10 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)9 Material (com.thoughtworks.go.domain.materials.Material)8 Materials (com.thoughtworks.go.config.materials.Materials)7