Search in sources :

Example 21 with HgMaterial

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 22 with HgMaterial

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));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 23 with HgMaterial

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));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 24 with HgMaterial

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));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 25 with HgMaterial

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));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)121 Test (org.junit.Test)107 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)34 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)29 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)23 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)15 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)10 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 Date (java.util.Date)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)9 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)8 Pagination (com.thoughtworks.go.server.util.Pagination)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)6 Modification (com.thoughtworks.go.domain.materials.Modification)6 File (java.io.File)6