use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnFalseForEmptyURLFieldWithAuth.
@Test
public void shouldReturnFalseForEmptyURLFieldWithAuth() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url.git", new GitMaterial("http://user:password@"));
assertThat(isEqual, is(false));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnListOfMaterialMatchingThePayloadURL.
@Test
public void shouldReturnListOfMaterialMatchingThePayloadURL() throws Exception {
GitMaterial material1 = mock(GitMaterial.class);
when(material1.getUrlArgument()).thenReturn(new UrlArgument("https://other_repo.local.git"));
GitMaterial material2 = mock(GitMaterial.class);
when(material2.getUrlArgument()).thenReturn(new UrlArgument("https://other_repo.local.git"));
GitMaterial material3 = mock(GitMaterial.class);
when(material3.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
GitMaterial material4 = mock(GitMaterial.class);
when(material4.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2, material3, material4));
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(2));
assertThat(actual, hasItem(material3));
assertThat(actual, hasItem(material4));
verify(material1).getUrlArgument();
verify(material2).getUrlArgument();
verify(material3).getUrlArgument();
verify(material4).getUrlArgument();
}
use of com.thoughtworks.go.config.materials.git.GitMaterial 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.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialExpansionServiceTest method shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling.
@Test
public void shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule("submodule-1", "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
when(materialConfigConverter.toMaterials(new MaterialConfigs(gitMaterial.config()))).thenReturn(new Materials(gitMaterial));
Materials materials = new Materials();
materialExpansionService.expandForScheduling(gitMaterial, materials);
assertThat(materials.size(), is(1));
assertThat(materials.get(0), is(gitMaterial));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class SvnPostCommitHookImplementerTest method shouldPruneListToGiveOutOnlySvnMaterials.
@Test
public void shouldPruneListToGiveOutOnlySvnMaterials() {
final Material svnMaterial1 = mock(SvnMaterial.class);
final Material svnMaterial2 = mock(SvnMaterial.class);
final Material svnMaterial3 = mock(SvnMaterial.class);
final Material hgMaterial = mock(HgMaterial.class);
final Material gitMaterial = mock(GitMaterial.class);
final Material p4Material = mock(P4Material.class);
final Material tfsMaterial = mock(TfsMaterial.class);
final Material dependencyMaterial = mock(DependencyMaterial.class);
final HashSet<Material> allMaterials = new HashSet<>(Arrays.asList(svnMaterial1, svnMaterial2, svnMaterial3, gitMaterial, hgMaterial, p4Material, tfsMaterial, dependencyMaterial));
final SvnPostCommitHookImplementer spy = spy(implementer);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return Boolean.TRUE;
}
}).when(spy).isQualified(anyString(), any(SvnMaterial.class), any(HashMap.class));
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return new HashMap();
}
}).when(spy).createUrlToRemoteUUIDMap(allMaterials);
final HashMap params = new HashMap();
params.put(SvnPostCommitHookImplementer.UUID, "some uuid");
final Set<Material> prunedList = spy.prune(allMaterials, params);
assertThat(prunedList.size(), is(3));
assertThat(prunedList, hasItems(svnMaterial1, svnMaterial2, svnMaterial3));
}
Aggregations