public void testHeadingMarkupForAssigness() {

    String s =
        ObjectToFieldValueMapper.transform("assignees", user, FULL_URL, transformer).getHtml();

    assertEquals("<a href='" + FULL_URL + "'>Foo Guy</a>", s);
  }
  public void testHeadingMarkupForResolutionGV() {

    final IssueConstant issueConstant = createMock(IssueConstant.class);

    expect(issueConstant.getNameTranslation()).andStubReturn("theNameTranslated");
    expect(issueConstant.getDescTranslation()).andStubReturn("theDescTranslated");
    expect(issueConstant.getIconUrl()).andStubReturn("http://jira/icon.gif");

    replay(issueConstant);

    expect(constantsManager.getIssueConstant((GenericValue) anyObject())).andReturn(issueConstant);

    replay(constantsManager);

    String s =
        ObjectToFieldValueMapper.transform(
                "resolution", new MockGenericValue("foo"), FULL_URL, transformer)
            .getHtml();

    assertEquals(
        "<img src=\"http://jira/icon.gif\" height=\"16\" width=\"16\" alt=\"theNameTranslated\" title=\"theNameTranslated - theDescTranslated\"/><a href='"
            + FULL_URL
            + "' title='theDescTranslated'>theNameTranslated</a>",
        s);
  }
 public void testHeadingMarkupForProjectGV() {
   Map theMap = new HashMap();
   theMap.put("name", "theProject");
   GenericValue value = new MockGenericValue("dubya", theMap);
   String s =
       ObjectToFieldValueMapper.transform("project", value, FULL_URL, transformer).getHtml();
   assertEquals("<a href='" + FULL_URL + "'>theProject</a>", s);
 }
  public void testHeadingMarkupForNoAssignee() {
    expect(i18n.getText("gadget.filterstats.assignee.unassigned")).andReturn("nouser");

    replay(i18n);

    String s =
        ObjectToFieldValueMapper.transform("assignees", null, FULL_URL, transformer).getHtml();

    assertEquals("<a href='" + FULL_URL + "'>nouser</a>", s);
  }
  public void testHeadingMarkupForNoValueCustomFields() {
    expect(i18n.getText("common.words.none")).andReturn("none");

    replay(i18n);

    final StatsMarkup statsMarkup =
        ObjectToFieldValueMapper.transform("customfield_nick", null, FULL_URL, transformer);

    assertEquals("<a href='" + FULL_URL + "'>none</a>", statsMarkup.getHtml());
  }
  public void testHeadingMarkupForNoComponent() {
    expect(i18n.getText("gadget.filterstats.component.nocomponent")).andReturn("nocomps");

    replay(i18n);

    String s =
        ObjectToFieldValueMapper.transform("components", null, FULL_URL, transformer).getHtml();

    assertEquals("<a href='" + FULL_URL + "'>nocomps</a>", s);
  }
  public void testHeadingMarkupForNoPriority() {
    expect(i18n.getText("gadget.filterstats.priority.nopriority")).andReturn("nopriority");

    replay(i18n);

    String s =
        ObjectToFieldValueMapper.transform("priorities", null, FULL_URL, transformer).getHtml();

    assertEquals("<a href='" + FULL_URL + "'>nopriority</a>", s);
  }
  public void testHeadingMarkupForNoResolution() {
    expect(i18n.getText("common.resolution.unresolved")).andReturn("nouser");

    replay(i18n);

    String s =
        ObjectToFieldValueMapper.transform("resolution", null, FULL_URL, transformer).getHtml();

    assertEquals("<a href='" + FULL_URL + "'>nouser</a>", s);
  }
  public void testHeadingMarkupForComponents() {
    ProjectComponent comp = new ProjectComponentImpl("theComponent", "theComponentDesc", null, 1);

    final StatsMarkup statsMarkup =
        ObjectToFieldValueMapper.transform("components", comp, FULL_URL, transformer);

    String s = statsMarkup.getHtml();
    assertEquals("<a href='" + FULL_URL + "' title='theComponentDesc'>theComponent</a>", s);
    assertTrue(statsMarkup.getClasses().contains("default_image"));
    assertTrue(statsMarkup.getClasses().contains("default_image_component"));
  }
  public void testHeadingMarkupForNoFixFor() {
    Version version = null;
    expect(i18n.getText("gadget.filterstats.fixfor.unscheduled")).andReturn("none");

    replay(i18n);

    final StatsMarkup statsMarkup =
        ObjectToFieldValueMapper.transform("fixfor", version, FULL_URL, transformer);

    String s = statsMarkup.getHtml();
    assertEquals("<a href='" + FULL_URL + "'>none</a>", s);
  }
  public void testHeadingMarkupForAllFixForArchivedAndReleased() {
    Version version = makeVersion(true, true, "archivedAndReleased", "archivedAndReleasedDesc");

    final StatsMarkup statsMarkup =
        ObjectToFieldValueMapper.transform("allFixfor", version, FULL_URL, transformer);

    String s = statsMarkup.getHtml();
    assertEquals(
        "<a href='" + FULL_URL + "' title='archivedAndReleasedDesc'>archivedAndReleased</a>", s);
    assertTrue(statsMarkup.getClasses().contains("default_image"));
    assertTrue(statsMarkup.getClasses().contains("released_archived_version"));
  }
  public void testHeadingMarkupForComponentsGV() {
    Map theMap = new HashMap();
    theMap.put("name", "theComponent");
    GenericValue value = new MockGenericValue("dubya", theMap);

    final StatsMarkup statsMarkup =
        ObjectToFieldValueMapper.transform("components", value, FULL_URL, transformer);

    String s = statsMarkup.getHtml();
    assertEquals("<a href='" + FULL_URL + "'>theComponent</a>", s);
    assertTrue(statsMarkup.getClasses().contains("default_image"));
    assertTrue(statsMarkup.getClasses().contains("default_image_component"));
  }
  public void testHeadingMarkupForVersionNotArchivedAndNotReleased() {
    Version version =
        makeVersion(false, false, "notArchivedAndNotReleased", "notArchivedAndNotReleasedDesc");

    final StatsMarkup statsMarkup =
        ObjectToFieldValueMapper.transform("version", version, FULL_URL, transformer);

    String s = statsMarkup.getHtml();
    assertEquals(
        "<a href='"
            + FULL_URL
            + "' title='notArchivedAndNotReleasedDesc'>notArchivedAndNotReleased</a>",
        s);
    assertTrue(statsMarkup.getClasses().contains("default_image"));
    assertTrue(statsMarkup.getClasses().contains("unreleased_unarchived_version"));
  }
  public void testHeadingMarkupForPriorities() {
    final IssueConstant issueConstant = createMock(IssueConstant.class);

    expect(issueConstant.getNameTranslation()).andStubReturn("theNameTranslated");
    expect(issueConstant.getDescTranslation()).andStubReturn("theDescTranslated");
    expect(issueConstant.getIconUrl()).andStubReturn("http://jira/icon.gif");

    replay(issueConstant);
    String s =
        ObjectToFieldValueMapper.transform("priorities", issueConstant, FULL_URL, transformer)
            .getHtml();

    assertEquals(
        "<img src=\"http://jira/icon.gif\" height=\"16\" width=\"16\" alt=\"theNameTranslated\" title=\"theNameTranslated - theDescTranslated\"/><a href='"
            + FULL_URL
            + "' title='theDescTranslated'>theNameTranslated</a>",
        s);
  }
  public void testHeadingMarkupForCustomFields() {

    CustomField cf = createMock(CustomField.class);
    CustomFieldSearcher cfs = createMock(CustomFieldSearcher.class);
    CustomFieldSearcherModuleDescriptor cfmd =
        createMock(CustomFieldSearcherModuleDescriptor.class);

    expect(cfm.getCustomFieldObject("customfield_nick")).andReturn(cf);
    replay(cfm);

    expect(cf.getCustomFieldSearcher()).andReturn(cfs);
    replay(cf);

    expect(cfs.getDescriptor()).andReturn(cfmd);
    replay(cfs);

    expect(cfmd.getStatHtml(cf, "nick", FULL_URL)).andReturn("CustomField Markup");
    replay(cfmd);

    final StatsMarkup statsMarkup =
        ObjectToFieldValueMapper.transform("customfield_nick", "nick", FULL_URL, transformer);

    assertEquals("CustomField Markup", statsMarkup.getHtml());
  }