Search in sources :

Example 1 with PipelineModel

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

the class EnvironmentServiceTest method stubPipelineHistoryServiceToReturnPipelines.

private PipelineInstanceModel stubPipelineHistoryServiceToReturnPipelines(final String pipelineName) {
    PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createPipeline(pipelineName, -1, "1", BuildCause.createManualForced(), new StageInstanceModels());
    PipelineModel pipelineModel = new PipelineModel(pipelineInstanceModel.getName(), true, true, PipelinePauseInfo.notPaused());
    pipelineModel.addPipelineInstance(pipelineInstanceModel);
    when(pipelineHistoryService.latestPipelineModel(new Username(new CaseInsensitiveString("Foo")), pipelineName)).thenReturn(pipelineModel);
    return pipelineInstanceModel;
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)

Example 2 with PipelineModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel 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 3 with PipelineModel

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

the class EnvironmentService method addEnvironmentFor.

void addEnvironmentFor(CaseInsensitiveString environmentName, Username username, ArrayList<Environment> environments) throws NoSuchEnvironmentException {
    List<CaseInsensitiveString> pipelines = environmentConfigService.pipelinesFor(environmentName);
    if (pipelines.isEmpty()) {
        environments.add(new Environment(CaseInsensitiveString.str(environmentName), new ArrayList<>()));
        return;
    }
    List<PipelineModel> pipelineInstanceModels = getPipelinesInstanceForEnvironment(pipelines, username);
    if (!pipelineInstanceModels.isEmpty()) {
        environments.add(new Environment(CaseInsensitiveString.str(environmentName), pipelineInstanceModels));
    }
}
Also used : ArrayList(java.util.ArrayList) Environment(com.thoughtworks.go.presentation.pipelinehistory.Environment) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)

Example 4 with PipelineModel

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

the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewIncludingUserAdminStatus.

@Test
public void shouldGenerateKeyForPipelineModelViewIncludingUserAdminStatus() {
    PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).updateAdministrability(true);
    StageInstanceModels stages = new StageInstanceModels();
    stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
    stages.add(new NullStageHistoryItem("stage2", true));
    PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), stages);
    pipelineInstance.setId(12);
    pipelineInstance.setCanUnlock(false);
    pipelineInstance.setIsLockable(true);
    pipelineInstance.setCurrentlyLocked(true);
    model.addPipelineInstance(pipelineInstance);
    assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{true|true|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true"));
    model.updateAdministrability(false);
    assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{true|true|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false"));
}
Also used : NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 5 with PipelineModel

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

the class ViewCacheKeyTest method shouldGenerateKeyForEnvironmentPipelineFragment.

@Test
public void shouldGenerateKeyForEnvironmentPipelineFragment() {
    MaterialRevisions materialRevisions = ModificationsMother.createHgMaterialRevisions();
    Modification latestModification = materialRevisions.getMaterialRevision(0).getModifications().remove(0);
    PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).updateAdministrability(true);
    StageInstanceModels stages = new StageInstanceModels();
    stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
    stages.add(new NullStageHistoryItem("stage2", true));
    PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createWithModifications(materialRevisions, "someone"), stages);
    pipelineInstance.setMaterialConfigs(materialRevisions.getMaterials().convertToConfigs());
    pipelineInstance.setLatestRevisions(new MaterialRevisions(new MaterialRevision(materialRevisions.getMaterialRevision(0).getMaterial(), latestModification)));
    pipelineInstance.setId(12);
    model.addPipelineInstance(pipelineInstance);
    assertThat(model.hasNewRevisions(), is(true));
    assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true|true"));
    model.updateAdministrability(false);
    assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false|true"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Aggregations

PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)18 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)8 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)7 Test (org.junit.Test)7 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)5 Test (org.junit.jupiter.api.Test)5 Permissions (com.thoughtworks.go.config.security.Permissions)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 PipelinePauseInfo (com.thoughtworks.go.domain.PipelinePauseInfo)2 Environment (com.thoughtworks.go.presentation.pipelinehistory.Environment)2 Username (com.thoughtworks.go.server.domain.Username)2 ArrayList (java.util.ArrayList)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 TrackingTool (com.thoughtworks.go.config.TrackingTool)1 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 Modification (com.thoughtworks.go.domain.materials.Modification)1