Exemplo n.º 1
0
 private void populateGenericValueFromComment(Comment updatedComment, GenericValue commentGV) {
   ApplicationUser updateAuthor = updatedComment.getUpdateAuthorApplicationUser();
   commentGV.setString("updateauthor", updateAuthor == null ? null : updateAuthor.getKey());
   commentGV.setString("body", updatedComment.getBody());
   commentGV.setString("level", updatedComment.getGroupLevel());
   commentGV.set("rolelevel", updatedComment.getRoleLevelId());
   commentGV.set(
       "updated", JiraDateUtils.copyOrCreateTimestampNullsafe(updatedComment.getUpdated()));
 }
  @Test
  public void testUpdateProjectCategory() throws GenericEntityException {
    projectCategory.set("name", "A New Name");
    projectCategory.set("description", "A New Description");
    testedObject.updateProjectCategory(projectCategory);

    final GenericValue retrievedProjectCat =
        testedObject.getProjectCategory(projectCategory.getLong("id"));
    assertEquals("A New Name", retrievedProjectCat.getString("name"));
    assertEquals("A New Description", retrievedProjectCat.getString("description"));
  }
  public void testUpdateScheme() throws CreateException, GenericEntityException {
    setupSchemes();

    issueScheme.set("name", "Test Update Scheme");
    issueSchemeManager.updateScheme(issueScheme);
    assertTrue(issueSchemeManager.getSchemes().size() == 1);
    assertNotNull(issueSchemeManager.getScheme("Test Update Scheme"));
  }
Exemplo n.º 4
0
 /**
  * We need to make sure that we account for failed upgrades - the QA-EACJ migration showed that
  * the table may linger but the sequence ids go
  *
  * @param entityName
  * @param nextId
  * @throws GenericEntityException
  */
 private void setNextId(String entityName, Long nextId) throws GenericEntityException {
   final GenericDelegator delegator = getDelegator();
   // First ensure we have an entry in SequenecValueItem table
   delegator.getNextSeqId(entityName);
   // Now set it to nextId
   GenericValue sequenceItem =
       EntityUtil.getOnly(
           delegator.findByAnd("SequenceValueItem", ImmutableMap.of("seqName", entityName)));
   if (sequenceItem != null) {
     sequenceItem.set("seqId", nextId);
     sequenceItem.store();
     delegator.refreshSequencer();
   }
 }
  @Test
  public void testDefaultAssigneeWithUnassigned()
      throws DefaultAssigneeException, GenericEntityException, OperationNotPermittedException,
          InvalidUserException, InvalidCredentialException {
    final User projectLead = userMockFactory.getProjectLead();
    final GenericValue projectWithDefaultAssigneeLead =
        projectMockFactory.getProjectWithDefaultAssigneeLead();
    final GenericValue projectWithDefaultUnassigned =
        projectMockFactory.getProjectWithDefaultUnassigned();

    // Should be false as unassigned is turned off and project lead cannot be assigned issues.
    _testNoDefaultAssignee(projectWithDefaultUnassigned, null);

    when(permissionManager.hasPermission(
            Permissions.ASSIGNABLE_USER, projectWithDefaultAssigneeLead, projectLead))
        .thenReturn(Boolean.TRUE);
    when(permissionManager.hasPermission(
            Permissions.ASSIGNABLE_USER, projectWithDefaultUnassigned, projectLead))
        .thenReturn(Boolean.TRUE);

    // Should be false as unassigned is turned off and the lead is null so it fails
    _testNoDefaultAssignee(projectWithDefaultUnassigned, null);

    projectWithDefaultUnassigned.set("lead", projectLead.getName());
    projectWithDefaultUnassigned.store();

    // Should be true as unassigned is turned off and project lead can be assigned issues,
    // so it defaults to project lead.
    assertTrue(testedObject.isDefaultAssignee(projectWithDefaultUnassigned, null));

    final User defaultAssignee =
        testedObject.getDefaultAssignee(projectWithDefaultUnassigned, null);
    assertEquals(projectLead, defaultAssignee);

    // Turn on unassigned
    ComponentAccessor.getApplicationProperties()
        .setOption(APKeys.JIRA_OPTION_ALLOWUNASSIGNED, true);

    // Reset permissions

    // Should be true as unassigned is turned on
    _testDefaultAssignee(projectWithDefaultUnassigned, null, null);
  }