// JRA-13412 - make sure it throws an exception if the assignee is present
  public void testDoTagInvaldActionBecauseOfMissingScreen() throws Exception {
    final String fileAssignee =
        "transition-workflow.test.invalid.action.missing-screen-assignee.jelly";
    final String fileResolution =
        "transition-workflow.test.invalid.action.missing-screen-resolution.jelly";
    final String fileOK = "transition-workflow.test.valid.action.missing-screen.jelly";

    try {
      runScript(fileAssignee);
      fail("JellyTagException should have been thrown.");
    } catch (JellyServiceException e) {
      assertTrue(
          e.getMessage().indexOf(" Field 'assignee' can not be set on action with no screen") >= 0);
    }
    try {
      runScript(fileResolution);
      fail("JellyTagException should have been thrown.");
    } catch (JellyServiceException e) {
      assertTrue(
          e.getMessage().indexOf(" Field 'resolution' can not be set on action with no screen")
              >= 0);
    }

    // OK it shoul work if we transition to a workflow with no screens when we have no extra fields
    try {
      Document doc = runScript(fileOK);
      assertNotNull(doc);
    } catch (JellyServiceException e) {
      fail("JellyTagException should NOT have been thrown.");
    }
  }
  // Test that the tag handles the issue not existing
  public void testDoTagIssueDoesNotExist() throws Exception {
    final String scriptFilename = "transition-workflow.test.no-issue.jelly";

    try {
      Document document = runScript(scriptFilename);
      fail("JellyTagException should have been thrown.");
    } catch (JellyServiceException e) {
      assertTrue(e.getMessage().indexOf("Cannot retrieve issue with key 'ABC-1'") >= 0);
    }
  }
  // Test that the action does not exist
  public void testDoTagInvaldActionId() throws Exception {
    final String scriptFilename = "transition-workflow.test.invalid-action.jelly";

    try {
      Document document = runScript(scriptFilename);
      fail("JellyTagException should have been thrown.");
    } catch (JellyServiceException e) {
      assertTrue(e.getMessage().indexOf("Invalid action id '-7'.") >= 0);
    }
  }
  // Test that we found the transition but that it is not a valid transition for the issues current
  // state.
  public void testDoTagInvaldActionIdBecauseOfIssueStatus() throws Exception {
    final String scriptFilename =
        "transition-workflow.test.invalid.action.id.for.state-action.jelly";

    try {
      Document document = runScript(scriptFilename);
      fail("JellyTagException should have been thrown.");
    } catch (JellyServiceException e) {
      assertTrue(
          e.getMessage()
                  .indexOf(
                      "Found workflow transition with name/id '3' but that is not a valid workflow transition for the current state of issue 'ABC-2'")
              >= 0);
    }
  }
  public void testCreateWithErrors() throws Exception {
    final String message = "ERROR: createProjectRole";
    swapProjectRoleService(
        new MockProjectRoleService() {
          @Override
          public ProjectRole createProjectRole(
              User currentUser, ProjectRole projectRole, ErrorCollection errorCollection) {
            errorCollection.addErrorMessage(message);
            return new ProjectRoleImpl(new Long(1), "lion-tamer", "tames the lions");
          }
        });

    try {
      runScriptAndAssertTextResultEquals("some unknown value that we don't care about");
      fail();
    } catch (JellyServiceException e) {
      assertTrue(e.getMessage().indexOf(message) != -1);
    }
  }