Search in sources :

Example 76 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class EnvironmentServiceTest method shouldReturnPipelineHistoryForPipelinesInAnEnvironment.

@Test
public void shouldReturnPipelineHistoryForPipelinesInAnEnvironment() throws Exception {
    Username username = new Username(new CaseInsensitiveString("Foo"));
    when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(Arrays.asList(new CaseInsensitiveString("uat-pipeline"), new CaseInsensitiveString("staging-pipeline")));
    PipelineInstanceModel uatInstance = stubPipelineHistoryServiceToReturnPipelines("uat-pipeline");
    PipelineInstanceModel stagingInstance = stubPipelineHistoryServiceToReturnPipelines("staging-pipeline");
    ArrayList<Environment> environments = new ArrayList<>();
    environmentService.addEnvironmentFor(new CaseInsensitiveString("uat"), username, environments);
    assertThat(environments.size(), is(1));
    Environment environment = environments.get(0);
    assertThat(environment.getName(), is("uat"));
    List<PipelineModel> models = environment.getPipelineModels();
    assertThat(models.size(), is(2));
    PipelineModel model1 = new PipelineModel(uatInstance.getName(), true, true, PipelinePauseInfo.notPaused());
    model1.addPipelineInstance(uatInstance);
    assertThat(models, hasItem(model1));
    PipelineModel model2 = new PipelineModel(stagingInstance.getName(), true, true, PipelinePauseInfo.notPaused());
    model2.addPipelineInstance(stagingInstance);
    assertThat(models, hasItem(model2));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) ArrayList(java.util.ArrayList) Environment(com.thoughtworks.go.presentation.pipelinehistory.Environment) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 77 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class FailureServiceTest method setUp.

@Before
public void setUp() {
    shineDao = mock(ShineDao.class);
    securityService = mock(SecurityService.class);
    stageFinder = mock(StageFinder.class);
    failureService = new FailureService(securityService, shineDao, stageFinder);
    username = new Username(new CaseInsensitiveString("foo"));
    jobIdentifier = new JobIdentifier(new StageIdentifier("pipeline", 10, "stage", "5"), "job");
    result = new HttpLocalizedOperationResult();
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ShineDao(com.thoughtworks.go.server.dao.sparql.ShineDao) Username(com.thoughtworks.go.server.domain.Username) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) StageFinder(com.thoughtworks.go.domain.StageFinder) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Example 78 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PipelineStagesFeedServiceTest method setUp.

@Before
public void setUp() throws Exception {
    user = new Username(new CaseInsensitiveString("barrow"));
    expected = new FeedEntries();
    stageService = mock(StageService.class);
    securityService = mock(SecurityService.class);
    operationResult = new HttpLocalizedOperationResult();
    pipelineStagesFeedResolver = new PipelineStagesFeedService(stageService, securityService).feedResolverFor("cruise");
}
Also used : FeedEntries(com.thoughtworks.go.domain.feed.FeedEntries) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Example 79 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PipelineUnlockApiServiceTest method unlockShouldSetResultToNotAcceptableWhenAPipelineInstanceIsCurrentlyRunning.

@Test
public void unlockShouldSetResultToNotAcceptableWhenAPipelineInstanceIsCurrentlyRunning() throws Exception {
    when(securityService.hasOperatePermissionForPipeline(new CaseInsensitiveString("username"), "pipeline-name")).thenReturn(true);
    when(goConfigService.hasPipelineNamed(new CaseInsensitiveString("pipeline-name"))).thenReturn(true);
    when(goConfigService.isLockable("pipeline-name")).thenReturn(true);
    StageIdentifier identifier = new StageIdentifier("pipeline-name", 10, "10", "stage", "1");
    when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(identifier);
    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(409));
    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)

Example 80 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PipelineUnlockApiServiceTest method unlockShouldSetResultToNotAcceptableWhenNoPipelineInstanceIsCurrentlyLocked.

@Test
public void unlockShouldSetResultToNotAcceptableWhenNoPipelineInstanceIsCurrentlyLocked() 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);
    Mockito.when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(null);
    HttpOperationResult result = new HttpOperationResult();
    pipelineUnlockApiService.unlock("pipeline-name", new Username(new CaseInsensitiveString("username")), result);
    assertThat(result.httpCode(), is(409));
    assertThat(result.message(), is("Lock exists within the pipeline configuration but no pipeline instance is currently in progress"));
}
Also used : 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

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)392 Test (org.junit.Test)277 Username (com.thoughtworks.go.server.domain.Username)80 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)65 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)57 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)50 Modification (com.thoughtworks.go.domain.materials.Modification)44 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Before (org.junit.Before)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 HashMap (java.util.HashMap)26 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ArrayList (java.util.ArrayList)19 Pipeline (com.thoughtworks.go.domain.Pipeline)18