Search in sources :

Example 21 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldUnderstandIfEmptyPipelineHasNewModifications.

@Test
public void shouldUnderstandIfEmptyPipelineHasNewModifications() throws Exception {
    saveRev(new MaterialRevision(pipelineOne.getMaterial(), new Modification(new Date(), "2", "MOCK_LABEL-12", null)));
    configHelper.setViewPermissionForGroup("group1", "anyone");
    PipelineInstanceModels models = pipelineHistoryService.findPipelineInstances(pipelineOne.pipelineName, "latest", 3, "anyone");
    PipelineInstanceModel emptyModel = models.get(0);
    assertThat(emptyModel.hasNewRevisions(), is(true));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 22 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method findPipelineInstanceShouldNotFindPipelineInstancesNotViewableByUser.

@Test
public void findPipelineInstanceShouldNotFindPipelineInstancesNotViewableByUser() {
    Pipeline pipeline = pipelineOne.createdPipelineWithAllStagesPassed();
    String groupName = configHelper.currentConfig().getGroups().findGroupNameByPipeline(new CaseInsensitiveString(pipeline.getName()));
    configHelper.setViewPermissionForGroup(groupName, "admin");
    HttpOperationResult result = new HttpOperationResult();
    PipelineInstanceModel pipelineInstance = pipelineHistoryService.findPipelineInstance(pipeline.getName(), pipeline.getCounter(), new Username(new CaseInsensitiveString("foo")), result);
    assertThat(pipelineInstance, is(nullValue()));
    assertThat(result.httpCode(), is(401));
    assertThat(result.message(), is("Not authorized to view pipeline"));
    pipelineInstance = pipelineHistoryService.findPipelineInstance(pipeline.getName(), pipeline.getCounter(), new Username(new CaseInsensitiveString("admin")), new HttpOperationResult());
    assertThat(pipelineInstance, is(not(nullValue())));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 23 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method updateComment_shouldUpdateTheCommentInTheDatabase.

@Test
public void updateComment_shouldUpdateTheCommentInTheDatabase() throws Exception {
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline_name", "stage", "job");
    goConfigService.addPipeline(pipelineConfig, "pipeline-group");
    configHelper.addAuthorizedUserForPipelineGroup("valid-user");
    configHelper.setAdminPermissionForGroup("pipeline-group", "valid-user");
    dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    pipelineHistoryService.updateComment("pipeline_name", 1, "test comment", new Username(new CaseInsensitiveString("valid-user")), result);
    PipelineInstanceModel pim = dbHelper.getPipelineDao().findPipelineHistoryByNameAndCounter("pipeline_name", 1);
    assertThat(pim.getComment(), is("test comment"));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 24 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldHaveAPipelineInstanceForAPipelineThatIsPreparingToSchedule.

@Test
public void shouldHaveAPipelineInstanceForAPipelineThatIsPreparingToSchedule() {
    configHelper.addPipeline("pipeline-name", "stage-1");
    triggerMonitor.markPipelineAsAlreadyTriggered("pipeline-name");
    PipelineInstanceModel instance = pipelineHistoryService.latest("pipeline-name", new Username(new CaseInsensitiveString("admin")));
    assertThat(instance.getName(), is("pipeline-name"));
    assertThat(instance.getStageHistory().size(), is(1));
    assertThat(instance.getStageHistory().get(0).isScheduled(), is(false));
    assertThat(instance.isPreparingToSchedule(), is(true));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 25 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method updateComment_shouldNotUpdateTheCommentInTheDatabaseIfTheUserIsUnauthorized.

@Test
public void updateComment_shouldNotUpdateTheCommentInTheDatabaseIfTheUserIsUnauthorized() throws Exception {
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline_name", "stage", "job");
    goConfigService.addPipeline(pipelineConfig, "pipeline-group");
    configHelper.addAuthorizedUserForPipelineGroup("valid-user");
    dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    pipelineHistoryService.updateComment("pipeline_name", 1, "test comment", new Username(new CaseInsensitiveString("invalid-user")), result);
    PipelineInstanceModel pim = dbHelper.getPipelineDao().findPipelineHistoryByNameAndCounter("pipeline_name", 1);
    assertThat(pim.getComment(), is(nullValue()));
    assertThat(result.httpCode(), is(401));
    assertThat(result.message(localizer), is("You do not have operate permissions for pipeline 'pipeline_name'."));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Aggregations

PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)69 Test (org.junit.Test)46 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)20 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)15 Username (com.thoughtworks.go.server.domain.Username)15 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)10 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)8 Modification (com.thoughtworks.go.domain.materials.Modification)7 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)7 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)6 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)4 Material (com.thoughtworks.go.domain.materials.Material)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 Date (java.util.Date)4 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3