use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MaterialUpdateStatusNotifierTest method shouldNotifyListenerWhenItsMaterialIsUpdatedEvenIfAnotherListenerThrowsAnException.
@Test
public void shouldNotifyListenerWhenItsMaterialIsUpdatedEvenIfAnotherListenerThrowsAnException() throws Exception {
Material sharedMaterial = new HgMaterial("url", null);
PipelineConfig pipelineConfig1 = new PipelineConfig(new CaseInsensitiveString("config"), new MaterialConfigs());
pipelineConfig1.addMaterialConfig(sharedMaterial.config());
PipelineConfig pipelineConfig2 = new PipelineConfig(new CaseInsensitiveString("another-config"), new MaterialConfigs());
pipelineConfig2.addMaterialConfig(sharedMaterial.config());
MaterialUpdateStatusListener badListener = Mockito.mock(MaterialUpdateStatusListener.class);
Mockito.doThrow(new RuntimeException("foo")).when(badListener).onMaterialUpdate(new MaterialUpdateSuccessfulMessage(sharedMaterial, 123));
MaterialUpdateStatusListener goodListener = Mockito.mock(MaterialUpdateStatusListener.class);
when(badListener.isListeningFor(sharedMaterial)).thenReturn(true);
when(goodListener.isListeningFor(sharedMaterial)).thenReturn(true);
materialUpdateStatusNotifier.registerListenerFor(pipelineConfig1, badListener);
materialUpdateStatusNotifier.registerListenerFor(pipelineConfig2, goodListener);
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(sharedMaterial, 123));
Mockito.verify(badListener).onMaterialUpdate(new MaterialUpdateSuccessfulMessage(sharedMaterial, 123));
Mockito.verify(goodListener).onMaterialUpdate(new MaterialUpdateSuccessfulMessage(sharedMaterial, 123));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MercurialPostCommitHookImplementerTest method shouldReturnTrueWhenBasicAuthWithOnlyUsernameIsProvidedInURL.
@Test
public void shouldReturnTrueWhenBasicAuthWithOnlyUsernameIsProvidedInURL() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url", new HgMaterial("http://user@repo-url", "dest"));
assertThat(isEqual, is(true));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MercurialPostCommitHookImplementerTest method shouldMatchFileBasedAccessWithoutAuth.
@Test
public void shouldMatchFileBasedAccessWithoutAuth() throws Exception {
boolean isEqual = implementer.isUrlEqual("/tmp/foo/repo-git", new HgMaterial("/tmp/foo/repo-git", "dest"));
assertThat(isEqual, is(true));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MercurialPostCommitHookImplementerTest method shouldReturnFalseForEmptyURLFieldWithAuth.
@Test
public void shouldReturnFalseForEmptyURLFieldWithAuth() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://repo-url", new HgMaterial("http://user:password@", "dest"));
assertThat(isEqual, is(false));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MercurialPostCommitHookImplementerTest method shouldReturnTrueWhenIncomingUrlDoesNotHaveAuthDetails.
@Test
public void shouldReturnTrueWhenIncomingUrlDoesNotHaveAuthDetails() throws Exception {
boolean isEqual = implementer.isUrlEqual("http://foo.bar/#foo", new HgMaterial("http://user:password@foo.bar/#foo", "dest"));
assertThat(isEqual, is(true));
}
Aggregations