Search in sources :

Example 51 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class SCMMaterialSourceTest method shouldReloadSchedulableMaterialsOnConfigRepoChange.

@Test
public void shouldReloadSchedulableMaterialsOnConfigRepoChange() {
    Set<MaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config(), gitMaterial.config()));
    when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
    when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial, gitMaterial)));
    when(serverHealthService.logs()).thenReturn(new ServerHealthStates());
    source.onEntityConfigChange(mock(ConfigRepoConfig.class));
    Set<Material> materials = source.materialsForUpdate();
    assertThat(materials.size(), is(2));
    assertTrue(materials.contains(svnMaterial));
    assertTrue(materials.contains(gitMaterial));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) Material(com.thoughtworks.go.domain.materials.Material) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 52 with Material

use of com.thoughtworks.go.domain.materials.Material 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 53 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class GitPostCommitHookImplementerTest method shouldQueryOnlyGitMaterialsWhilePruning.

@Test
public void shouldQueryOnlyGitMaterialsWhilePruning() throws Exception {
    SvnMaterial material1 = mock(SvnMaterial.class);
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    HashMap params = new HashMap();
    params.put(GitPostCommitHookImplementer.REPO_URL_PARAM_KEY, "https://machine.local.git");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) 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 54 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class MercurialPostCommitHookImplementerTest method shouldReturnEmptyListWhenURLIsSpecified.

@Test
public void shouldReturnEmptyListWhenURLIsSpecified() throws Exception {
    HgMaterial material = mock(HgMaterial.class);
    HashSet<Material> materials = new HashSet<>(Arrays.asList(material));
    Set<Material> actual = implementer.prune(materials, new HashMap());
    assertThat(actual.size(), is(0));
    verify(material, times(0)).getUrlArgument();
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 55 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class PluggableSCMPostCommitHookImplementerTest method shouldReturnEmptyListIfParamHasNoValueForSCMName.

@Test
public void shouldReturnEmptyListIfParamHasNoValueForSCMName() throws Exception {
    PluggableSCMMaterial material1 = mock(PluggableSCMMaterial.class);
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    Map params = new HashMap();
    params.put(PluggableSCMPostCommitHookImplementer.SCM_NAME, "");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.Test)

Aggregations

Material (com.thoughtworks.go.domain.materials.Material)95 Test (org.junit.Test)59 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)39 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)39 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)23 Modification (com.thoughtworks.go.domain.materials.Modification)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)16 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)14 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)14 Materials (com.thoughtworks.go.config.materials.Materials)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)9 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)8 Date (java.util.Date)8 HashSet (java.util.HashSet)8 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7