Search in sources :

Example 16 with ProjectStatus

use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.

the class CcTrayJobStatusChangeHandlerTest method shouldUpdateBreakersAlongWithOtherFields.

@Test
public void shouldUpdateBreakersAlongWithOtherFields() throws Exception {
    String jobName = "job1";
    Set<String> breakers = new HashSet<>();
    breakers.add("abc");
    breakers.add("def");
    CcTrayJobStatusChangeHandler handler = new CcTrayJobStatusChangeHandler(cache);
    ProjectStatus newStatus = handler.statusFor(JobInstanceMother.completed(jobName), breakers);
    assertThat(newStatus.getBreakers(), is(breakers));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with ProjectStatus

use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.

the class CcTrayStageStatusChangeHandlerTest method shouldLeaveBuildDetailsOfStageSameAsTheDefault_WhenStageIsNotCompleted_AndThereIsNoExistingStageInCache.

@Test
public void shouldLeaveBuildDetailsOfStageSameAsTheDefault_WhenStageIsNotCompleted_AndThereIsNoExistingStageInCache() throws Exception {
    String projectName = "pipeline :: stage1";
    ProjectStatus.NullProjectStatus defaultStatus = new ProjectStatus.NullProjectStatus(projectName);
    Stage stage = StageMother.custom("stage1", JobInstanceMother.building("job1"));
    List<ProjectStatus> statuses = handler.statusesOfStageAndItsJobsFor(stage);
    ProjectStatus statusOfStage = statuses.get(0);
    assertThat(stage.getState().completed(), is(not(true)));
    assertThat(statusOfStage.getLastBuildStatus(), is(defaultStatus.getLastBuildStatus()));
    assertThat(statusOfStage.getLastBuildTime(), is(defaultStatus.getLastBuildTime()));
    assertThat(statusOfStage.getLastBuildLabel(), is(defaultStatus.getLastBuildLabel()));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 18 with ProjectStatus

use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.

the class CcTrayStageStatusChangeHandlerTest method shouldUpdateCacheWhenStageWhichHasChangedIsNotANullStage.

@Test
public void shouldUpdateCacheWhenStageWhichHasChangedIsNotANullStage() throws Exception {
    Stage completedStage = StageMother.createPassedStage("pipeline", 1, "stage1", 1, "job1", new Date());
    ProjectStatus jobStatus = new ProjectStatus("job1_name", "activity1", "lastBuildStatus1", "lastBuildLabel1", new Date(), "webUrl1");
    when(jobStatusChangeHandler.statusFor(completedStage.getJobInstances().first(), new HashSet<>())).thenReturn(jobStatus);
    handler.call(completedStage);
    verify(breakersCalculator).calculateFor(completedStage);
    verify(cache).putAll(statusesCaptor.capture());
    List<ProjectStatus> statusesWhichWereCached = statusesCaptor.getValue();
    assertThat(statusesWhichWereCached.size(), is(2));
    assertThat(statusesWhichWereCached.get(0).name(), is("pipeline :: stage1"));
    assertThat(statusesWhichWereCached.get(0).getLastBuildStatus(), is("Success"));
    assertThat(activityOf(statusesWhichWereCached.get(0)), is("Sleeping"));
    assertThat(statusesWhichWereCached.get(1), is(jobStatus));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 19 with ProjectStatus

use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.

the class CcTrayConfigChangeHandler method call.

public void call(PipelineConfig pipelineConfig, String pipelineGroup) {
    ArrayList<ProjectStatus> projectStatuses = new ArrayList<>();
    final Map<String, Viewers> groupsAndTheirViewers = ccTrayViewAuthority.groupsAndTheirViewers();
    Viewers usersWithViewPermissionsOfThisGroup = groupsAndTheirViewers.get(pipelineGroup);
    updateProjectStatusForPipeline(usersWithViewPermissionsOfThisGroup, pipelineConfig, projectStatuses);
    cache.putAll(projectStatuses);
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) ArrayList(java.util.ArrayList) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers)

Example 20 with ProjectStatus

use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.

the class CcTrayCacheTest method shouldBeAbleToReplaceMultipleItemsInCache.

@Test
public void shouldBeAbleToReplaceMultipleItemsInCache() throws Exception {
    ProjectStatus firstStatusOfItem1 = new ProjectStatus("item1", "Sleeping 1", "last-build-status 1", "last-build-label 1", new Date(), "web-url 1");
    ProjectStatus nextStatusOfItem1 = new ProjectStatus("item1", "Sleeping 2", "last-build-status 2", "last-build-label 2", new Date(), "web-url 2");
    ProjectStatus status2 = new ProjectStatus("item2", "Sleeping", "last-build-status", "last-build-label", new Date(), "web-url");
    ProjectStatus firstStatusOfItem3 = new ProjectStatus("item3", "Sleeping A", "last-build-status A", "last-build-label A", new Date(), "web-url A");
    ProjectStatus nextStatusOfItem3 = new ProjectStatus("item3", "Sleeping B", "last-build-status B", "last-build-label B", new Date(), "web-url B");
    cache.put(firstStatusOfItem1);
    cache.put(status2);
    cache.put(firstStatusOfItem3);
    cache.putAll(asList(nextStatusOfItem1, status2, nextStatusOfItem3));
    assertThat(cache.get("item1"), is(nextStatusOfItem1));
    assertThat(cache.get("item2"), is(status2));
    assertThat(cache.get("item3"), is(nextStatusOfItem3));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)43 Test (org.junit.Test)34 Date (java.util.Date)14 Stage (com.thoughtworks.go.domain.Stage)9 NullStage (com.thoughtworks.go.domain.NullStage)8 Permissions (com.thoughtworks.go.config.security.Permissions)4 Users (com.thoughtworks.go.config.security.users.Users)4 ArrayList (java.util.ArrayList)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)2 StageIdentity (com.thoughtworks.go.server.domain.StageIdentity)2 ArgumentCaptor (org.mockito.ArgumentCaptor)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineGroupVisitor (com.thoughtworks.go.domain.PipelineGroupVisitor)1 Viewers (com.thoughtworks.go.domain.cctray.viewers.Viewers)1 HashSet (java.util.HashSet)1