public void testValidateNullProject() { Project project = createNiceMock(Project.class); expect(ctx.getLoggedInUser()).andReturn(mockUser); expect(proj.getProjectObj(666L)).andReturn(project); EasyMock.replay(ctx, prms, proj); ProjectsAndCategoriesHelper helper = new DefaultProjectsAndCategoriesHelper(proj, prms, ctx); List<ValidationError> errors = new ArrayList<ValidationError>(); helper.validate(null, errors, "somefield"); assertErrors(errors, "gadget.common.projects.and.categories.none.selected"); }
public void testValidate() { Project project = createNiceMock(Project.class); expect(ctx.getLoggedInUser()).andReturn(mockUser); expect(proj.getProjectObj(666L)).andReturn(project); EasyMock.replay(ctx, prms, proj); ProjectsAndCategoriesHelper helper = new DefaultProjectsAndCategoriesHelper(proj, prms, ctx); List<ValidationError> errors = new ArrayList<ValidationError>(); helper.validate("666", errors, "somefield"); assertEquals(0, errors.size()); }
public void testGetProjectIds() { expect(ctx.getLoggedInUser()).andReturn(mockUser); Project project = createNiceMock(Project.class); expect(project.getId()).andReturn(666L); Project project2 = createNiceMock(Project.class); expect(project2.getId()).andReturn(323L); expect(proj.getProjectObj(666L)).andReturn(project); expect(proj.getProjectObj(323L)).andReturn(project2); expect(prms.hasPermission(Permissions.BROWSE, project, mockUser)).andReturn(true); expect(prms.hasPermission(Permissions.BROWSE, project2, mockUser)).andReturn(true); expect(proj.getProjectObjectsFromProjectCategory(555L)).andReturn(Arrays.asList(project2)); EasyMock.replay(ctx, prms, proj, project, project2); ProjectsAndCategoriesHelper helper = new DefaultProjectsAndCategoriesHelper(proj, prms, ctx); Set<Long> ids = helper.getProjectIds("666|cat555"); assertNotNull(ids); assertEquals(1, ids.size()); }