Search in sources :

Example 76 with GitMaterial

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

the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.

@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
    HgMaterial hgMaterial = hgRepo.material();
    SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
    GitMaterial gitMaterial = gitRepo.createMaterial();
    Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
    MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
    assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
    assertThat(revisions.getMaterialRevision(2).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
    assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 77 with GitMaterial

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

the class MaterialDatabaseUpdaterTest method shouldFailWithAReasonableMessageWhenExceptionMessageIsNull.

@Test
public void shouldFailWithAReasonableMessageWhenExceptionMessageIsNull() throws Exception {
    Material material = new GitMaterial("url", "branch");
    Exception exceptionWithNullMessage = new RuntimeException(null, new RuntimeException("Inner exception has non-null message"));
    String message = "Modification check failed for material: " + material.getLongDescription();
    when(materialRepository.findMaterialInstance(material)).thenThrow(exceptionWithNullMessage);
    try {
        materialDatabaseUpdater.updateMaterial(material);
        fail("should have thrown exception");
    } catch (Exception e) {
        assertThat(e, is(exceptionWithNullMessage));
    }
    verify(healthService).update(ServerHealthState.error(message, "Unknown error", HealthStateType.general(HealthStateScope.forMaterial(material))));
}
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) Test(org.junit.Test)

Example 78 with GitMaterial

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

the class GitPostCommitHookImplementerTest method shouldReturnTrueWhenURLIsAnExactMatch.

@Test
public void shouldReturnTrueWhenURLIsAnExactMatch() throws Exception {
    boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("http://repo-url.git"));
    assertThat(isEqual, is(true));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Test(org.junit.Test)

Example 79 with GitMaterial

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

the class GitPostCommitHookImplementerTest method shouldReturnEmptyListIfParamHasNoValueForRepoURL.

@Test
public void shouldReturnEmptyListIfParamHasNoValueForRepoURL() throws Exception {
    GitMaterial material1 = mock(GitMaterial.class);
    when(material1.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    HashMap params = new HashMap();
    params.put(GitPostCommitHookImplementer.REPO_URL_PARAM_KEY, "");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.Test)

Example 80 with GitMaterial

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

the class GitPostCommitHookImplementerTest method shouldReturnTrueWhenBasicAuthWithoutPasswordIsProvidedInURL.

@Test
public void shouldReturnTrueWhenBasicAuthWithoutPasswordIsProvidedInURL() throws Exception {
    boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("http://user:@repo-url.git"));
    assertThat(isEqual, is(true));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) 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