use of com.google.api.services.tasks.model.TaskList in project jbpm-work-items by kiegroup.
the class AddTaskWorkitemHandler method executeWorkItem.
public void executeWorkItem(WorkItem workItem, WorkItemManager workItemManager) {
String taskName = (String) workItem.getParameter("TaskName");
String taskKind = (String) workItem.getParameter("TaskKind");
if (taskName == null) {
logger.error("Missing task name input.");
throw new IllegalArgumentException("Missing task name input.");
}
try {
Tasks service = auth.getTasksService(appName, clientSecret);
TaskList taskList = new TaskList();
taskList.setTitle(taskName);
taskList.setId(taskName);
taskList.setKind(taskKind);
taskList.setUpdated(new DateTime(new Date()));
service.tasklists().insert(taskList).execute();
workItemManager.completeWorkItem(workItem.getId(), null);
} catch (Exception e) {
handleException(e);
}
}
use of com.google.api.services.tasks.model.TaskList in project jbpm-work-items by kiegroup.
the class GoogleTasksWorkitemHandlerTest method setUp.
@Before
public void setUp() {
try {
List<TaskList> testTaskList = new java.util.ArrayList<>();
TaskList listOne = new TaskList();
listOne.setTitle("buy groceries");
listOne.setKind("home task");
TaskList listTwo = new TaskList();
listTwo.setTitle("pickup kid from school");
listTwo.setKind("home task");
testTaskList.add(listOne);
testTaskList.add(listTwo);
TaskLists taskListsModel = new TaskLists();
taskListsModel.setItems(testTaskList);
when(auth.getTasksService(anyString(), anyString())).thenReturn(tasksService);
when(tasksService.tasklists()).thenReturn(taskLists);
when(taskLists.list()).thenReturn(taskListsList);
when(taskLists.insert(any(TaskList.class))).thenReturn(taskListsInsert);
when(taskListsList.setMaxResults(anyLong())).thenReturn(taskListsList);
when(taskListsList.execute()).thenReturn(taskListsModel);
when(taskListsInsert.execute()).thenReturn(listOne);
} catch (Exception e) {
fail(e.getMessage());
}
}
Aggregations