Search in sources :

Example 16 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class StageFeedEntryTest method shouldNotAddDuplicateAuthorsCardsToAuthorsList.

@Test
public void shouldNotAddDuplicateAuthorsCardsToAuthorsList() {
    StageFeedEntry entry = new StageFeedEntry(1, 1, new StageIdentifier(), 1, new Date(), StageResult.Passed);
    entry.addAuthor(new Author("name", "email"));
    entry.addAuthor(new Author("name", "email"));
    entry.addAuthor(new Author("name1", "email1"));
    assertThat(entry.getAuthors().size(), is(2));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Author(com.thoughtworks.go.domain.feed.Author) Date(java.util.Date) Test(org.junit.Test)

Example 17 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class PipelineLockServiceTest method shouldNotAllowStageFromLockedPipelineToBeScheduled.

@Test
public void shouldNotAllowStageFromLockedPipelineToBeScheduled() throws Exception {
    Pipeline pipeline = PipelineMother.firstStageBuildingAndSecondStageScheduled("mingle", asList("dev", "ft"), asList("test"));
    when(pipelineDao.lockedPipeline("mingle")).thenReturn(new StageIdentifier(pipeline.getName(), 9999, "1.2.9999", "stage", "1"));
    when(goConfigService.isLockable(pipeline.getName())).thenReturn(true);
    pipelineLockService.lockIfNeeded(pipeline);
    assertThat(pipelineLockService.canScheduleStageInPipeline(pipeline.getIdentifier()), is(false));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 18 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class PipelineLockServiceTest method shouldAllowStageFromAnotherPipelineIfThePipelineIsNotLockabler.

@Test
public void shouldAllowStageFromAnotherPipelineIfThePipelineIsNotLockabler() throws Exception {
    Pipeline pipeline = PipelineMother.firstStageBuildingAndSecondStageScheduled("mingle", asList("dev", "ft"), asList("test"));
    when(pipelineDao.lockedPipeline("mingle")).thenReturn(new StageIdentifier(pipeline.getName(), 9999, "1.2.9999", "stage", "1"));
    when(goConfigService.isLockable(pipeline.getName())).thenReturn(false);
    pipelineLockService.lockIfNeeded(pipeline);
    assertThat(pipelineLockService.canScheduleStageInPipeline(pipeline.getIdentifier()), is(true));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 19 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class PipelineLockServiceTest method shouldKnowIfPipelineIsLocked.

@Test
public void shouldKnowIfPipelineIsLocked() throws Exception {
    when(pipelineDao.lockedPipeline("mingle")).thenReturn(new StageIdentifier("mingle", 1, "1", "stage", "1"));
    assertThat(pipelineLockService.isLocked("mingle"), is(true));
    assertThat(pipelineLockService.isLocked("twist"), is(false));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Test(org.junit.Test)

Example 20 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class PipelineUnlockApiServiceTest method unlockShouldSetResultToNotAcceptableWhenAPipelineInstanceIsCurrentlyRunning.

@Test
public void unlockShouldSetResultToNotAcceptableWhenAPipelineInstanceIsCurrentlyRunning() throws Exception {
    Mockito.when(securityService.hasOperatePermissionForPipeline(new CaseInsensitiveString("username"), "pipeline-name")).thenReturn(true);
    Mockito.when(goConfigService.hasPipelineNamed(new CaseInsensitiveString("pipeline-name"))).thenReturn(true);
    Mockito.when(goConfigService.isLockable("pipeline-name")).thenReturn(true);
    StageIdentifier identifier = new StageIdentifier("pipeline-name", 10, "10", "stage", "1");
    Mockito.when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(identifier);
    Mockito.when(currentActivityService.isAnyStageActive(identifier.pipelineIdentifier())).thenReturn(true);
    HttpOperationResult result = new HttpOperationResult();
    pipelineUnlockApiService.unlock("pipeline-name", new Username(new CaseInsensitiveString("username")), result);
    assertThat(result.httpCode(), is(406));
    assertThat(result.message(), is("locked pipeline instance is currently running (one of the stages is in progress)"));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)59 Test (org.junit.Test)31 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 Pipeline (com.thoughtworks.go.domain.Pipeline)12 Stage (com.thoughtworks.go.domain.Stage)12 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)6 StageTestRuns (com.thoughtworks.go.domain.testinfo.StageTestRuns)6 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)6 ArrayList (java.util.ArrayList)6 Modification (com.thoughtworks.go.domain.materials.Modification)5 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)5 Username (com.thoughtworks.go.server.domain.Username)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)3 FailingTestsInPipeline (com.thoughtworks.go.domain.testinfo.FailingTestsInPipeline)3 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)3 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)3 Graph (com.thoughtworks.studios.shine.semweb.Graph)3