use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnEmptyListIfParamIsMissingForRepoURL.
@Test
public void shouldReturnEmptyListIfParamIsMissingForRepoURL() 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));
Set<Material> actual = implementer.prune(materials, new HashMap());
assertThat(actual.size(), is(0));
verifyNoMoreInteractions(material1);
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class MercurialPostCommitHookImplementerTest method shouldPruneMercurialMaterialsWhichMatchIncomingURL.
@Test
public void shouldPruneMercurialMaterialsWhichMatchIncomingURL() throws Exception {
HgMaterial material1 = mock(HgMaterial.class);
when(material1.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
HgMaterial material2 = mock(HgMaterial.class);
when(material2.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
HgMaterial material3 = mock(HgMaterial.class);
when(material3.getUrlArgument()).thenReturn(new UrlArgument("ssh://repo1.something.local"));
GitMaterial material4 = mock(GitMaterial.class);
when(material4.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2, material3, material4));
Map params = new HashMap();
params.put(MercurialPostCommitHookImplementer.REPO_URL_PARAM_KEY, "http://repo1.something.local");
Set<Material> actual = implementer.prune(materials, params);
assertThat(actual.size(), is(2));
assertThat(actual, hasItem(material1));
assertThat(actual, hasItem(material2));
verify(material1).getUrlArgument();
verify(material2).getUrlArgument();
verify(material3).getUrlArgument();
verify(material4, times(0)).getUrlArgument();
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.
@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
final MaterialConfig svnMaterialConfig = new SvnMaterialConfig("http://svn_url_1", "username", "password", false);
svnMaterialConfig.setAutoUpdate(false);
final MaterialConfig svnMaterialConfigWithAutoUpdate = new SvnMaterialConfig("http://svn_url_2", "username", "password", false);
svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
final MaterialConfig hgMaterialConfig = new HgMaterialConfig("http://hg_url", null);
hgMaterialConfig.setAutoUpdate(false);
final MaterialConfig gitMaterialConfig = new GitMaterialConfig("http://git_url");
gitMaterialConfig.setAutoUpdate(false);
final MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
tfsMaterialConfig.setAutoUpdate(false);
final MaterialConfig p4MaterialConfig = new P4MaterialConfig("http://p4_url", "view", "username");
p4MaterialConfig.setAutoUpdate(false);
final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(6));
assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class MaterialConfigsTest method shouldSetTfsConfigAttributesForMaterial.
@Test
public void shouldSetTfsConfigAttributesForMaterial() {
MaterialConfigs materialConfigs = new MaterialConfigs();
Map<String, String> tfsAttrMap = new HashMap<>();
tfsAttrMap.put(TfsMaterialConfig.URL, "foo");
tfsAttrMap.put(TfsMaterialConfig.USERNAME, "bar");
tfsAttrMap.put(TfsMaterialConfig.PASSWORD, "baz");
tfsAttrMap.put(TfsMaterialConfig.PROJECT_PATH, "to_hell");
tfsAttrMap.put(TfsMaterialConfig.MATERIAL_NAME, "crapy_material");
tfsAttrMap.put(TfsMaterialConfig.DOMAIN, "CORPORATE");
Map<String, Object> attributeMap = new HashMap<>();
attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, TfsMaterialConfig.TYPE);
attributeMap.put(TfsMaterialConfig.TYPE, tfsAttrMap);
materialConfigs.setConfigAttributes(attributeMap);
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("foo"), "bar", "CORPORATE", "baz", "to_hell");
tfsMaterialConfig.setName(new CaseInsensitiveString("crapy_material"));
assertThat(materialConfigs.first(), is(tfsMaterialConfig));
assertThat(tfsMaterialConfig.getPassword(), is("baz"));
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class HgCommandTest method makeACommitToSecondBranch.
private void makeACommitToSecondBranch() {
HgCommand hg = new HgCommand(null, secondBranchWorkingCopy, "second", serverRepo.getAbsolutePath(), null);
hg.clone(outputStreamConsumer, new UrlArgument(serverRepo.getAbsolutePath()));
createNewFileAndPushUpstream(secondBranchWorkingCopy);
}
Aggregations