Search in sources :

Example 1 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class ConfigMaterialUpdaterTest method SetUp.

@Before
public void SetUp() {
    repoConfigDataSource = mock(GoRepoConfigDataSource.class);
    materialChecker = mock(MaterialChecker.class);
    materialRepository = mock(MaterialRepository.class);
    configCompleted = mock(ConfigMaterialUpdateCompletedTopic.class);
    topic = mock(MaterialUpdateCompletedTopic.class);
    materialService = mock(MaterialService.class);
    material = new SvnMaterial("url", "tom", "pass", false);
    when(materialRepository.folderFor(material)).thenReturn(folder);
    poller = mock(MaterialPoller.class);
    when(materialService.getPollerImplementation(any(Material.class))).thenReturn(poller);
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "1");
    mods = revisions(material, svnModification);
    when(materialRepository.findLatestModification(material)).thenReturn(mods);
    configUpdater = new ConfigMaterialUpdater(repoConfigDataSource, materialRepository, materialChecker, configCompleted, topic, materialService, new TestSubprocessExecutionContext());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Date(java.util.Date) GoRepoConfigDataSource(com.thoughtworks.go.config.GoRepoConfigDataSource) MaterialService(com.thoughtworks.go.server.service.MaterialService) MaterialPoller(com.thoughtworks.go.server.service.materials.MaterialPoller) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) Before(org.junit.Before)

Example 2 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class TfsMaterialTest method shouldCheckConnection.

@Test
void shouldCheckConnection() {
    TestSubprocessExecutionContext execCtx = new TestSubprocessExecutionContext();
    TfsCommand tfsCommand = mock(TfsCommand.class);
    doNothing().when(tfsCommand).checkConnection();
    TfsMaterial spy = spy(tfsMaterialFirstCollectionFirstProject);
    doReturn(tfsCommand).when(spy).tfs(execCtx);
    assertThat(spy.checkConnection(execCtx)).isEqualTo(valid());
    verify(tfsCommand, times(1)).checkConnection();
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) TfsCommand(com.thoughtworks.go.domain.materials.tfs.TfsCommand) Test(org.junit.jupiter.api.Test)

Example 3 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class P4MultipleMaterialsTest method shouldUpdateToItsDestFolder.

@Test
public void shouldUpdateToItsDestFolder() {
    P4Material p4Material = p4Fixture.material(VIEW_SRC, "dest1");
    MaterialRevision revision = new MaterialRevision(p4Material, p4Material.latestModification(clientFolder, new TestSubprocessExecutionContext()));
    revision.updateTo(clientFolder, inMemoryConsumer(), new TestSubprocessExecutionContext());
    assertThat(new File(clientFolder, "dest1/net").exists(), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) MaterialRevisionsMatchers.containsModifiedFile(com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class P4MultipleMaterialsTest method shouldFoundModificationsForEachMaterial.

@Test
public void shouldFoundModificationsForEachMaterial() throws Exception {
    P4Material p4Material1 = p4Fixture.material(VIEW_SRC, "src");
    P4Material p4Material2 = p4Fixture.material(VIEW_LIB, "lib");
    Materials materials = new Materials(p4Material1, p4Material2);
    p4TestRepo.checkInOneFile(p4Material1, "filename.txt");
    p4TestRepo.checkInOneFile(p4Material2, "filename2.txt");
    MaterialRevisions materialRevisions = materials.latestModification(clientFolder, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.getRevisions().size(), is(2));
    assertThat(materialRevisions, containsModifiedFile("src/filename.txt"));
    assertThat(materialRevisions, containsModifiedFile("lib/filename2.txt"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.jupiter.api.Test)

Example 5 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class P4MaterialTestBase method shouldCheckConnection.

@Test
void shouldCheckConnection() {
    P4Material p4Material = new P4Material("localhost:9876", "p4view");
    p4Material.setPassword("secret");
    p4Material.setUseTickets(false);
    ValidationBean validation = p4Material.checkConnection(new TestSubprocessExecutionContext());
    assertThat(validation.isValid()).isFalse();
    assertThat(validation.getError()).contains("Unable to connect to server localhost:9876");
    assertThat(validation.getError()).doesNotContain("secret");
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.jupiter.api.Test)

Aggregations

TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)31 Test (org.junit.jupiter.api.Test)21 File (java.io.File)13 Modification (com.thoughtworks.go.domain.materials.Modification)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)6 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)5 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)5 Test (org.junit.Test)5 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)4 Materials (com.thoughtworks.go.config.materials.Materials)4 TfsCommand (com.thoughtworks.go.domain.materials.tfs.TfsCommand)3 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2 Material (com.thoughtworks.go.domain.materials.Material)2 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)2 ValidationBean (com.thoughtworks.go.domain.materials.ValidationBean)2 MaterialRepository (com.thoughtworks.go.server.persistence.MaterialRepository)2 MaterialService (com.thoughtworks.go.server.service.MaterialService)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2