protected void setUp() throws Exception { super.setUp(); PermissionContextFactory ctxFactory = ComponentAccessor.getPermissionContextFactory(); DefaultSchemeFactory schemeFactory = new DefaultSchemeFactory(); OfBizDelegator ofBizDelegator = new DefaultOfBizDelegator(CoreFactory.getGenericDelegator()); AssociationManager associationManager = CoreFactory.getAssociationManager(); ManagerFactory.addService( IssueSecuritySchemeManager.class, new IssueSecuritySchemeManagerImpl( new DefaultProjectManager(), new PermissionTypeManager(), ctxFactory, schemeFactory, null, associationManager, ofBizDelegator, null)); issueSchemeManager = ManagerFactory.getIssueSecuritySchemeManager(); project = UtilsForTests.getTestEntity("Project", EasyMap.build("id", new Long(2), "lead", "paul")); project2 = UtilsForTests.getTestEntity("Project", new HashMap()); }
private Project addProject( final long id, final String key, final String name, final long counter) { final GenericValue result = UtilsForTests.getTestEntity( "Project", ImmutableMap.of("id", id, "key", key, "name", name, "counter", counter)); UtilsForTests.getTestEntity("ProjectKey", ImmutableMap.of("projectId", id, "projectKey", key)); return new ProjectMock(result); }
public void testGetQueryWorksCorrectly() throws Exception { SecurityType securityType = (SecurityType) ManagerFactory.getPermissionTypeManager().getSchemeType("reporter"); // Setup permissions so that a query is created GenericValue project = UtilsForTests.getTestEntity("Project", EasyMap.build("name", "Project")); PermissionSchemeManager permissionSchemeManager = ManagerFactory.getPermissionSchemeManager(); GenericValue scheme = permissionSchemeManager.createScheme("Scheme", "scheme"); permissionSchemeManager.addSchemeToProject(project, scheme); SchemeEntity schemeEntity = new SchemeEntity(securityType.getType(), null, new Long(Permissions.BROWSE)); permissionSchemeManager.createSchemeEntity(scheme, schemeEntity); Query query = securityType.getQuery(u, project, null); assertEquals( "(+" + DocumentConstants.PROJECT_ID + ":" + project.getLong("id") + " +" + DocumentConstants.ISSUE_AUTHOR + ":owen)", query.toString("")); }
protected void setUp() throws Exception { super.setUp(); CoreTransactionUtil.setUseTransactions(false); setUpMocks(); ctrlFieldManager.expectAndReturn(mockFieldManager.isOrderableField("customfield_1"), true); ctrlFieldManager.expectAndReturn(mockFieldManager.isOrderableField("customfield_2"), false); ctrlFieldManager.expectAndReturn(mockFieldManager.isOrderableField("customfield_3"), false); replayMocks(); UtilsForTests.getTestEntity( "FieldLayoutItem", EasyMap.build("id", new Long(1001), "fieldidentifier", "customfield_1")); UtilsForTests.getTestEntity( "FieldLayoutItem", EasyMap.build("id", new Long(1002), "fieldidentifier", "customfield_2")); UtilsForTests.getTestEntity( "FieldLayoutItem", EasyMap.build("id", new Long(1003), "fieldidentifier", "customfield_3")); flCheck = new FieldLayoutCheck(ofBizDelegator, 1); flCheck.setFieldManager(mockFieldManager); }
private Issue addIssue(final Project project, final long number) throws Exception { final Issue result = mock(Issue.class); when(result.getProjectObject()).thenReturn(project); when(result.getNumber()).thenReturn(number); UtilsForTests.getTestEntity( "Issue", ImmutableMap.of( "number", result.getNumber(), "project", result.getProjectObject().getId())); when(issueManager.isExistingIssueKey(IssueKey.format(project, result.getNumber()))) .thenReturn(Boolean.TRUE); return result; }
public GenericValue getComponentWithProjectDefaultUnassigned() { if (componentWithProjectDefaultUnassigned == null) { componentWithProjectDefaultUnassigned = UtilsForTests.getTestEntity( "Component", ImmutableMap.of( "name", "componentWithProjectDefaultUnassigned", "project", projectMockFactory.getProjectWithDefaultUnassigned().getLong("id"), "assigneetype", new Long(ComponentAssigneeTypes.PROJECT_DEFAULT))); } return componentWithProjectDefaultUnassigned; }
public GenericValue getProjectWithDefaultUnassigned() { if (projectWithDefaultUnassigned == null) { projectWithDefaultUnassigned = UtilsForTests.getTestEntity( "Project", ImmutableMap.of( "name", "projectWithDefaultUnassigned", "key", "DUL", "assigneetype", new Long(ProjectAssigneeTypes.UNASSIGNED))); } return projectWithDefaultUnassigned; }
public GenericValue getComponentWithComponentAssignee() { if (componentWithComponentAssignee == null) { componentWithComponentAssignee = UtilsForTests.getTestEntity( "Component", ImmutableMap.of( "name", "componentWithComponentAssignee", "project", projectMockFactory.getProjectWithDefaultUnassigned().getLong("id"), "lead", userMockFactory.getComponentLead().getName().toLowerCase(), "assigneetype", new Long(ComponentAssigneeTypes.COMPONENT_LEAD))); } return componentWithComponentAssignee; }
public GenericValue getProjectWithDefaultAssigneeLead() { if (projectWithDefaultAssigneeLead == null) { projectWithDefaultAssigneeLead = UtilsForTests.getTestEntity( "Project", ImmutableMap.of( "name", "projectWithAssigneeLead", "key", "DAL", "lead", userMockFactory.getProjectLead().getName(), "assigneetype", new Long(ProjectAssigneeTypes.PROJECT_LEAD))); } return projectWithDefaultAssigneeLead; }
@Override protected void setUp() throws Exception { super.setUp(); final FieldVisibilityManager visibilityBean = EasyMock.createMock(FieldVisibilityManager.class); EasyMock.expect( visibilityBean.isFieldHidden( (String) EasyMock.anyObject(), (Issue) EasyMock.anyObject())) .andReturn(false) .anyTimes(); EasyMock.replay(visibilityBean); ManagerFactory.addService(FieldVisibilityManager.class, visibilityBean); originalFactory = ComponentManager.getComponentInstanceOfType(FieldClausePermissionChecker.Factory.class); ManagerFactory.addService( FieldClausePermissionChecker.Factory.class, new MockFieldClausePermissionFactory()); bob = createMockUser("bob"); final Group group = addUserToNewGroup(bob, "group"); carl = createMockUser("carl"); final GenericValue project = UtilsForTests.getTestEntity("Project", EasyMap.build("key", "TST")); final PermissionSchemeManager permissionSchemeManager = ManagerFactory.getPermissionSchemeManager(); final GenericValue defaultScheme = permissionSchemeManager.createDefaultScheme(); final SchemeEntity schemeEntity = new SchemeEntity(GroupDropdown.DESC, null, Permissions.BROWSE); permissionSchemeManager.createSchemeEntity(defaultScheme, schemeEntity); permissionSchemeManager.addSchemeToProject(project, defaultScheme); UtilsForTests.getTestEntity("Resolution", EasyMap.build("id", resolutionId)); // Create two Issues with same comment but different level final GenericValue issue1 = UtilsForTests.getTestEntity( "Issue", EasyMap.build( "project", project.getLong("id"), "key", "TST-1", "resolution", resolutionId, "summary", SUMMARY_BODY)); UtilsForTests.getTestEntity( "Action", EasyMap.build( "issue", issue1.getLong("id"), "type", ActionConstants.TYPE_COMMENT, "body", COMMENT_BODY)); final GenericValue issue2 = UtilsForTests.getTestEntity( "Issue", EasyMap.build( "project", project.getLong("id"), "key", "TST-2", "resolution", resolutionId, "summary", SUMMARY_BODY)); UtilsForTests.getTestEntity( "Action", EasyMap.build( "issue", issue2.getLong("id"), "type", ActionConstants.TYPE_COMMENT, "body", COMMENT_BODY, "level", group.getName())); final GenericValue issue3 = UtilsForTests.getTestEntity( "Issue", EasyMap.build( "project", project.getLong("id"), "key", "TST-3", "resolution", resolutionId, "summary", ANOTHER_SUMMARY_BODY)); UtilsForTests.getTestEntity( "Action", EasyMap.build( "issue", issue3.getLong("id"), "type", ActionConstants.TYPE_COMMENT, "body", ANOTHER_COMMENT_BODY, "level", group.getName())); ManagerFactory.getIndexManager().reIndexAll(); }
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"))); }
protected void setUp() throws Exception { super.setUp(); u = UtilsForTests.getTestUser("owen"); }
private GenericValue addProjectCategory( final long id, final String name, final String description) { return UtilsForTests.getTestEntity( "ProjectCategory", ImmutableMap.of("id", id, "name", name, "description", description)); }