public void attempts() {
    try {
      requireJob();
    }
    catch (Exception e) {
      renderText(e.getMessage());
      return;
    }
    if (app.getJob() != null) {
      try {
        String taskType = $(TASK_TYPE);
        if (taskType.isEmpty()) {
          throw new RuntimeException("missing task-type.");
        }
        String attemptState = $(ATTEMPT_STATE);
        if (attemptState.isEmpty()) {
          throw new RuntimeException("missing attempt-state.");
        }
        setTitle(join(attemptState, " ",
            MRApps.taskType(taskType).toString(), " attempts in ", $(JOB_ID)));

        render(attemptsPage());
      } catch (Exception e) {
        LOG.error("Failed to render attempts page with task type : "
            + $(TASK_TYPE) + " for job id : " + $(JOB_ID), e);
        badRequest(e.getMessage());
      }
    }
  }
@Test
  public void testAttempts() {

    appController.getProperty().remove(AMParams.TASK_TYPE);

    when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
        .thenReturn(false);

    appController.attempts();
    verify(appController.response()).setContentType(MimeType.TEXT);
    assertEquals(
        "Access denied: User user does not have permission to view job job_01_01",
        appController.getData());

    when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
        .thenReturn(true);

    appController.getProperty().remove(AMParams.TASK_ID);
    appController.attempts();
    assertEquals(
        "Access denied: User user does not have permission to view job job_01_01",
        appController.getData());

    appController.getProperty().put(AMParams.TASK_ID, taskId);
    appController.attempts();
    assertEquals("Bad request: missing task-type.", appController.getProperty()
        .get("title"));
    appController.getProperty().put(AMParams.TASK_TYPE, "m");

    appController.attempts();
    assertEquals("Bad request: missing attempt-state.", appController
        .getProperty().get("title"));
    appController.getProperty().put(AMParams.ATTEMPT_STATE, "State");

    appController.attempts();

    assertEquals(AttemptsPage.class, appController.getClazz());

    appController.getProperty().remove(AMParams.ATTEMPT_STATE);
  }