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));
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class MaterialUpdateStatusNotifierTest method shouldNotifyListenerWhenItsMaterialIsUpdated.
@Test
public void shouldNotifyListenerWhenItsMaterialIsUpdated() throws Exception {
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("config"), new MaterialConfigs());
Material material = new HgMaterial("url", null);
pipelineConfig.addMaterialConfig(material.config());
MaterialUpdateStatusListener mockStatusListener = Mockito.mock(MaterialUpdateStatusListener.class);
when(mockStatusListener.isListeningFor(material)).thenReturn(true);
materialUpdateStatusNotifier.registerListenerFor(pipelineConfig, mockStatusListener);
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(material, 123));
Mockito.verify(mockStatusListener).onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material, 123));
}
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);
}
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);
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class PluggableSCMPostCommitHookImplementerTest method shouldReturnEmptyListIfNoMatchingMaterialFound.
@Test
public void shouldReturnEmptyListIfNoMatchingMaterialFound() throws Exception {
PluggableSCMMaterial material1 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-1", null, null));
PluggableSCMMaterial material2 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-2", null, null));
Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2));
Map params = new HashMap();
params.put(PluggableSCMPostCommitHookImplementer.SCM_NAME, "unknown-scm-name");
Set<Material> actual = implementer.prune(materials, params);
assertThat(actual.size(), is(0));
}
Aggregations