@Test public void testCreateTaskWithDisallowedCreationBasedOnContentByRule() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { workItemId = 1 } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('john')],businessAdministrators = [ new User('Administrator') ], }),"; str += "descriptions = [ new I18NText( 'en-UK', 'This is my description')], "; str += "subjects = [ new I18NText( 'en-UK', 'This is my subject')], "; str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })"; Task task = (Task) TaskFactory.evalTask(new StringReader(str)); Map<String, Object> params = new HashMap<String, Object>(); params.put("manager", "John"); try { taskService.addTask(task, params); fail("Task should not be created due to rule violation"); } catch (CannotAddTaskException e) { assertTrue(e.getMessage().indexOf("John (manager) does not work here any more") != -1); } }
@Test public void testCreateTaskWithDisallowedCreationByRule() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { workItemId = 1 } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('peter')],businessAdministrators = [ new User('Administrator') ], }),"; str += "descriptions = [ new I18NText( 'en-UK', 'This is my description')], "; str += "subjects = [ new I18NText( 'en-UK', 'This is my subject')], "; str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })"; Task task = (Task) TaskFactory.evalTask(new StringReader(str)); try { taskService.addTask(task, new HashMap<String, Object>()); fail("Task should not be created due to rule violation"); } catch (CannotAddTaskException e) { assertTrue(e.getMessage().indexOf("peter does not work here any more") != -1); } }
@Test public void testCreateTaskWithDisallowedCreationBasedOnContentByRuleWithContentData() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { workItemId = 1 } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('john')],businessAdministrators = [ new User('Administrator') ], }),"; str += "descriptions = [ new I18NText( 'en-UK', 'This is my description')], "; str += "subjects = [ new I18NText( 'en-UK', 'This is my subject')], "; str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })"; Task task = (Task) TaskFactory.evalTask(new StringReader(str)); Map<String, Object> params = new HashMap<String, Object>(); params.put("manager", "John"); ContentData data = ContentMarshallerHelper.marshal(task, params, null); try { taskService.addTask(task, data); fail("Task should not be created due to rule violation"); } catch (CannotAddTaskException e) { assertTrue(e.getMessage().indexOf("John (manager) does not work here any more") != -1); } }