private RewardType fromGenericValue(GenericValue genval) {
    if (genval == null) {
      return null;
    }
    long id = (Long) genval.get(ID_FIELD);
    String name = (String) genval.get(NAME_FIELD);
    String namepl = (String) genval.get(NAMEPL_FIELD);
    String desc = (String) genval.get(DESC_FIELD);
    String iconURL = (String) genval.get(ICON_FIELD);

    return new RewardType(id, name, namepl, desc, iconURL);
  }
  protected void setUp() throws Exception {
    super.setUp();

    user = createMockUser("logged-in-user");
    secondaryUser = createMockUser("testuser");
    g = createMockGroup("jira-user");
    addUserToGroup(user, g);
    addUserToGroup(secondaryUser, g);
    JiraTestUtil.loginUser(user);
    ComponentAccessor.getApplicationProperties()
        .setOption(APKeys.JIRA_OPTION_ALLOWUNASSIGNED, true);
    ManagerFactory.getGlobalPermissionManager().addPermission(Permissions.ADMINISTER, null);

    SchemeManager permManager = ManagerFactory.getPermissionSchemeManager();
    GenericValue scheme = permManager.createDefaultScheme();
    PermissionManager pm = ManagerFactory.getPermissionManager();
    pm.addPermission(Permissions.CREATE_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.BROWSE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.RESOLVE_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.ASSIGN_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.CLOSE_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.WORK_ISSUE, scheme, "jira-user", "group");
    pm.addPermission(Permissions.ASSIGNABLE_USER, scheme, "jira-user", "group");

    // Build IssueConstants
    UpgradeTask_Build11 upgradeTask_build11 =
        new UpgradeTask_Build11(ComponentAccessor.getConstantsManager());
    upgradeTask_build11.doUpgrade(false);

    // Build the default statuses
    UpgradeTask_Build27 upgradeTask_build27 = new UpgradeTask_Build27();
    upgradeTask_build27.doUpgrade(false);

    // Create field screens
    UpgradeTask upgradeTask = (UpgradeTask) JiraUtils.loadComponent(UpgradeTask_Build83.class);
    upgradeTask.doUpgrade(false);

    // Build default IssueTypeScheme
    UpgradeTask upgradeTask101 = (UpgradeTask) JiraUtils.loadComponent(UpgradeTask_Build101.class);
    upgradeTask101.doUpgrade(false);

    JiraAuthenticationContext authenticationContext =
        ComponentAccessor.getJiraAuthenticationContext();
    // Log in user
    authenticationContext.setLoggedInUser(user);
    GenericValue project =
        UtilsForTests.getTestEntity(
            "Project",
            EasyMap.build(
                "key", "ABC", "name", "A Project", "lead", user.getName(), "counter", new Long(1)));
    ComponentAccessor.getIssueTypeScreenSchemeManager().associateWithDefaultScheme(project);
    ManagerFactory.getProjectManager().refresh();

    final PermissionSchemeManager permissionSchemeManager =
        ManagerFactory.getPermissionSchemeManager();
    permissionSchemeManager.addSchemeToProject(project, scheme);

    // Create a REAL issue (with valid transitions and everything) with key ABC-2
    final MutableIssue issue1 = ComponentAccessor.getIssueFactory().getIssue();
    issue1.setProject(project);
    issue1.setAssignee(user);
    GenericValue issueTypeGV = ComponentAccessor.getConstantsManager().getIssueType("1");
    issue1.setIssueType(issueTypeGV);
    ComponentAccessor.getIssueManager().createIssue(user, issue1);

    // Create a second REAL issue with key ABC-3
    final MutableIssue issue2 = ComponentAccessor.getIssueFactory().getIssue();
    issue2.setProject(project);
    issue2.setAssignee(secondaryUser);
    issue2.setIssueType(issueTypeGV);
    ComponentAccessor.getIssueManager().createIssue(secondaryUser, issue2);

    // Create a SearchRequest to return the two issues
    sr =
        UtilsForTests.getTestEntity(
            "SearchRequest",
            EasyMap.build(
                "id",
                new Long(10241),
                "name",
                "test",
                "author",
                "logged-in-user",
                "user",
                "logged-in-user",
                "group",
                "jira-user",
                "project",
                project.get("id"),
                "request",
                "project = " + project.get("id")));
  }