@Test
  public void canForceShouldBeFalseForUnauthorizedAccess() throws Exception {
    configHelper.addSecurityWithAdminConfig();
    fixture.configStageAsManualApprovalWithApprovedUsers(fixture.devStage, "user");

    fixture.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();

    JsonMap jsonMap = requestPipelineHistoryPage();
    assertThat(getItemInJson(jsonMap, "canForce"), is("false"));
  }
 @Test
 public void shouldHaveGroupsInJson() throws Exception {
   fixture.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
   JsonMap jsonMap = requestPipelineHistoryPage();
   JsonList groups = jsonMap.getJsonList("groups");
   assertThat(groups.size(), is(1));
 }
 @After
 public void teardown() throws Exception {
   dbHelper.onTearDown();
   fixture.onTearDown();
   configHelper.onTearDown();
   resetSecurityContext();
 }
 @Test
 public void hasModificationShouldBeTrueIfThereIsBuildCauseInBuffer() throws Exception {
   fixture.createNewCheckin();
   scheduleHelper.autoSchedulePipelinesWithRealMaterials(fixture.pipelineName);
   JsonMap jsonMap = requestPipelineHistoryPage();
   assertThat(getItemInJson(jsonMap, "showForceBuildButton"), is("true"));
 }
 @Test
 public void shouldCreateGroupIfPipelineHasModificationEvenNoPipelineHistory() throws Exception {
   fixture.createNewCheckin();
   scheduleHelper.autoSchedulePipelinesWithRealMaterials(fixture.pipelineName);
   JsonMap jsonMap = requestPipelineHistoryPage();
   JsonList groups = jsonMap.getJsonList("groups");
   assertThat("Should create group for the coming pipeline", groups.size(), is(1));
 }
  @Test
  public void canForceShouldBeTrueForAuthorizedUser() throws Exception {
    configHelper.addSecurityWithAdminConfig();
    fixture.configStageAsManualApprovalWithApprovedUsers(fixture.devStage, "userA");

    login("userA", "");
    JsonMap jsonMap = requestPipelineHistoryPage();
    assertThat(getItemInJson(jsonMap, "canForce"), is("true"));
  }
  @Before
  public void setUp() throws Exception {
    fixture = new PipelineWithMultipleStages(3, materialRepository, transactionTemplate);
    configHelper.usingCruiseConfigDao(goConfigFileDao);
    configHelper.onSetUp();

    dbHelper.onSetUp();
    fixture.usingConfigHelper(configHelper).usingDbHelper(dbHelper).onSetUp();
    goConfigService.forceNotifyListeners();
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
  }