List of usage examples for java.util Calendar MILLISECOND
int MILLISECOND
To view the source code for java.util Calendar MILLISECOND.
Click Source Link
get
and set
indicating the millisecond within the second. From source file:com.marklogic.client.test.EvalTest.java
@BeforeClass public static void beforeClass() { Common.connectAdmin();/* w w w . j a v a2s . c o m*/ libMgr = Common.client.newServerConfigManager().newExtensionLibrariesManager(); Common.connectEval(); septFirst.set(2014, Calendar.SEPTEMBER, 1, 0, 0, 0); septFirst.set(Calendar.MILLISECOND, 0); //System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug"); }
From source file:com.silverpeas.calendar.DateTime.java
/** * Creates a new date time from the specified parts of the time specification year month day hour * minute second millisecond. The hour, minute, second and millisecond parts are optional; if not * passed, they are set at 0. For example, the following patterns are valid: * <ul>//from www .j a v a 2 s.co m * <li>at(2011, 5, 23, 10, 57, 23, 12) meaning in ISO 86601 2011-05-23T10:57:23.012</li> * <li>at(2011, 5, 23, 10, 57, 23) meaning in ISO 86601 2011-05-23T10:57:23.00</li> * <li>at(2011, 5, 23, 10, 57) meaning in ISO 86601 2011-05-23T10:57:00.00</li> * <li>at(2011, 5, 23, 10) meaning in ISO 86601 2011-05-23T10:00:00.00</li> * <li>at(2011, 5, 23) meaning in ISO 86601 2011-05-23T00:00:00.00</li> * </ul> * @param timeParts the different parts of the date time to set in the following order: year, * month, day, hour, minute, second, millisecond. The year, month, and day are mandatory whereas * other time parts are optional. If one optional part isn't passed, then it is set to 0. * @return a date time matching the specified date and time specification. */ public static DateTime dateTimeAt(int... timeParts) { if (timeParts.length < 3) { throw new IllegalArgumentException("The year, month and day must be set"); } Calendar calendar = Calendar.getInstance(); calendar.set(timeParts[0], timeParts[1], timeParts[2], 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); if (timeParts.length >= 4) { calendar.set(Calendar.HOUR_OF_DAY, timeParts[3]); if (timeParts.length >= 5) { calendar.set(Calendar.MINUTE, timeParts[4]); if (timeParts.length >= 6) { calendar.set(Calendar.SECOND, timeParts[5]); if (timeParts.length >= 7) { calendar.set(Calendar.MILLISECOND, timeParts[6]); } } } } return new DateTime(calendar.getTime()); }
From source file:com.adobe.acs.commons.http.headers.impl.WeeklyExpiresHeaderFilterTest.java
@Test public void testAdjustExpiresPastWeekday() throws Exception { Calendar actual = Calendar.getInstance(); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); Calendar expected = Calendar.getInstance(); expected.setTime(actual.getTime());//from w ww . ja va 2 s. c om expected.add(Calendar.DAY_OF_WEEK, -3); expected.add(Calendar.DAY_OF_WEEK, 7); int dayOfWeek = expected.get(Calendar.DAY_OF_WEEK); properties.put(WeeklyExpiresHeaderFilter.PROP_EXPIRES_DAY_OF_WEEK, dayOfWeek); filter.doActivate(componentContext); filter.adjustExpires(actual); assertTrue(DateUtils.isSameInstant(expected, actual)); assertEquals(dayOfWeek, actual.get(Calendar.DAY_OF_WEEK)); }
From source file:com.adobe.acs.commons.http.headers.impl.MonthlyExpiresHeaderFilterTest.java
@Test public void testAdjustExpiresPastDay() throws Exception { Calendar actual = Calendar.getInstance(); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); Calendar expected = Calendar.getInstance(); expected.setTime(actual.getTime());/* w w w. j a v a2s. co m*/ expected.add(Calendar.DAY_OF_MONTH, -3); expected.add(Calendar.MONTH, 1); actual.set(Calendar.DAY_OF_MONTH, 15); final int month = expected.get(Calendar.MONTH); properties.put(MonthlyExpiresHeaderFilter.PROP_EXPIRES_DAY_OF_MONTH, expected.get(Calendar.DAY_OF_MONTH)); filter.doActivate(componentContext); filter.adjustExpires(actual); assertTrue(DateUtils.isSameInstant(expected, actual)); assertEquals(month, actual.get(Calendar.MONTH)); }
From source file:org.flowable.rest.service.api.runtime.TaskQueryResourceTest.java
/** * Test querying tasks. GET runtime/tasks *///from w w w .jav a2 s. c o m @Deployment public void testQueryTasks() throws Exception { try { Calendar adhocTaskCreate = Calendar.getInstance(); adhocTaskCreate.set(Calendar.MILLISECOND, 0); Calendar processTaskCreate = Calendar.getInstance(); processTaskCreate.add(Calendar.HOUR, 2); processTaskCreate.set(Calendar.MILLISECOND, 0); Calendar inBetweenTaskCreation = Calendar.getInstance(); inBetweenTaskCreation.add(Calendar.HOUR, 1); processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime()); Task adhocTask = taskService.newTask(); adhocTask.setAssignee("gonzo"); adhocTask.setOwner("owner"); adhocTask.setDelegationState(DelegationState.PENDING); adhocTask.setDescription("Description one"); adhocTask.setName("Name one"); adhocTask.setDueDate(adhocTaskCreate.getTime()); adhocTask.setPriority(100); adhocTask.setFormKey("myForm.json"); adhocTask.setCategory("some-category"); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT); processEngineConfiguration.getClock().setCurrentTime(processTaskCreate.getTime()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey"); Task processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()) .singleResult(); processTask.setParentTaskId(adhocTask.getId()); processTask.setPriority(50); processTask.setDueDate(processTaskCreate.getTime()); taskService.saveTask(processTask); // Check filter-less to fetch all tasks String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY); ObjectNode requestNode = objectMapper.createObjectNode(); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId(), adhocTask.getId()); // Name filtering requestNode.removeAll(); requestNode.put("name", "Name one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Name like filtering requestNode.removeAll(); requestNode.put("nameLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description filtering requestNode.removeAll(); requestNode.put("description", "Description one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description like filtering requestNode.removeAll(); requestNode.put("descriptionLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Priority filtering requestNode.removeAll(); requestNode.put("priority", 100); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Mininmum Priority filtering requestNode.removeAll(); requestNode.put("minimumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Maximum Priority filtering requestNode.removeAll(); requestNode.put("maximumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Owner filtering requestNode.removeAll(); requestNode.put("owner", "owner"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee filtering requestNode.removeAll(); requestNode.put("assignee", "gonzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Owner like filtering requestNode.removeAll(); requestNode.put("ownerLike", "owne%"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee like filtering requestNode.removeAll(); requestNode.put("assigneeLike", "%onzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Unassigned filtering requestNode.removeAll(); requestNode.put("unassigned", true); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Delegation state filtering requestNode.removeAll(); requestNode.put("delegationState", "pending"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Candidate user filtering requestNode.removeAll(); requestNode.put("candidateUser", "kermit"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group filtering requestNode.removeAll(); requestNode.put("candidateGroup", "sales"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group In filtering requestNode.removeAll(); ArrayNode arrayNode = requestNode.arrayNode(); arrayNode.add("sales"); arrayNode.add("someOtherGroup"); requestNode.set("candidateGroupIn", arrayNode); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Involved user filtering requestNode.removeAll(); requestNode.put("involvedUser", "misspiggy"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Process instance filtering requestNode.removeAll(); requestNode.put("processInstanceId", processInstance.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Execution filtering requestNode.removeAll(); Execution taskExecution = runtimeService.createExecutionQuery().activityId("processTask") .singleResult(); requestNode.put("executionId", taskExecution.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKey", "myBusinessKey"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey like filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKeyLike", "myBusiness%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key requestNode.removeAll(); requestNode.put("processDefinitionKey", "oneTaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key like requestNode.removeAll(); requestNode.put("processDefinitionKeyLike", "%TaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name requestNode.removeAll(); requestNode.put("processDefinitionName", "The One Task Process"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name like requestNode.removeAll(); requestNode.put("processDefinitionNameLike", "The One %"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CreatedOn filtering requestNode.removeAll(); requestNode.put("createdOn", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // CreatedAfter filtering requestNode.removeAll(); requestNode.put("createdAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CreatedBefore filtering requestNode.removeAll(); requestNode.put("createdBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Subtask exclusion requestNode.removeAll(); requestNode.put("excludeSubTasks", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Task definition key filtering requestNode.removeAll(); requestNode.put("taskDefinitionKey", "processTask"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Task definition key like filtering requestNode.removeAll(); requestNode.put("taskDefinitionKeyLike", "process%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Duedate filtering requestNode.removeAll(); requestNode.put("dueDate", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Due after filtering requestNode.removeAll(); requestNode.put("dueAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Due before filtering requestNode.removeAll(); requestNode.put("dueBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Suspend process-instance to have a suspended task runtimeService.suspendProcessInstanceById(processInstance.getId()); // Suspended filtering requestNode.removeAll(); requestNode.put("active", false); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Active filtering requestNode.removeAll(); requestNode.put("active", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering by category requestNode.removeAll(); requestNode.put("category", "some-category"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering without duedate requestNode.removeAll(); requestNode.put("withoutDueDate", true); // No response should be returned, no tasks without a duedate yet assertResultsPresentInPostDataResponse(url, requestNode); processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); processTask.setDueDate(null); taskService.saveTask(processTask); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); } finally { // Clean adhoc-tasks even if test fails List<Task> tasks = taskService.createTaskQuery().list(); for (Task task : tasks) { if (task.getExecutionId() == null) { taskService.deleteTask(task.getId(), true); } } } }
From source file:org.openehealth.coala.converter.PXSDateConverterTest.java
/** * @throws java.lang.Exception//from ww w.j a v a2 s. c o m */ @Before public void setUp() throws Exception { ResourceBundle properties = ResourceBundle.getBundle("coala-document"); longPattern = properties.getString("coala.consent.longdatepattern"); shortPattern = properties.getString("coala.consent.shortdatepattern"); GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR, 3); cal.set(Calendar.MINUTE, 36); cal.set(Calendar.SECOND, 50); cal.set(Calendar.MILLISECOND, 0); referenceDateLong = cal.getTime(); cal = new GregorianCalendar(); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); referenceDateShort = cal.getTime(); }
From source file:net.sf.sze.service.impl.common.SchulKalenderServiceImpl.java
/** * {@inheritDoc}//from ww w . j a va2s.co m */ @Override public Calendar getLeavedSchoolDate(final Calendar currentDate) { final Calendar result = Calendar.getInstance(); if (currentDate.get(Calendar.MONTH) >= Calendar.APRIL && currentDate.get(Calendar.MONTH) < Calendar.OCTOBER) { result.set(currentDate.get(Calendar.YEAR), Calendar.FEBRUARY, 1, 0, 0, 0); } else if (currentDate.get(Calendar.MONTH) < Calendar.APRIL) { result.set(currentDate.get(Calendar.YEAR) - 1, Calendar.AUGUST, 1, 0, 0, 0); } else { result.set(currentDate.get(Calendar.YEAR), Calendar.AUGUST, 1, 0, 0, 0); } result.set(Calendar.MILLISECOND, 0); return result; }
From source file:de.codesourcery.planning.swing.DateAxis.java
public BoundingBox render(ITimelineCallback callback, boolean layoutOnly) { final Calendar cal = Calendar.getInstance(); cal.setTime(startDate);//w ww .ja va 2 s .c om cal.set(Calendar.MILLISECOND, 0); Date currentDate = cal.getTime(); final Date endDate = duration.addTo(startDate); BoundingBox lastLabel = null; final int labelSpacing = 10; final Graphics2D graphics = callback.getGraphics(); final int fontHeight = graphics.getFontMetrics().getHeight(); final double scalingFactor = getXScalingFactor(callback.getBoundingBox()); final BoundingBox box = callback.getBoundingBox(); double x = callback.getBoundingBox().getX(); final int tickToLabelSpacing = 2; final int tickLength = fontHeight; final int axisHeight = fontHeight + tickLength + tickToLabelSpacing; final double xIncrement = Math.floor(tickDuration.toSeconds() * scalingFactor); final Color oldColor = graphics.getColor(); // while (currentDate.compareTo(endDate) <= 0) { final int currentX = (int) Math.floor(x); if (lastLabel == null || lastLabel.getMaxX() < x) { final String labelText = callback.getLabelProvider().getTimelineLabel(currentDate); if (!StringUtils.isBlank(labelText)) { final Rectangle2D stringBounds = callback.getStringBounds(labelText); if (!layoutOnly) { graphics.setColor(Color.BLACK); // draw tick final Stroke oldStroke = graphics.getStroke(); graphics.setStroke(new BasicStroke(2.0f)); graphics.drawLine(currentX, box.getY() + axisHeight, currentX, box.getY() + fontHeight + tickToLabelSpacing); graphics.setStroke(oldStroke); // draw label callback.drawString(Color.BLACK, currentX, box.getY(), labelText); } final BoundingBox labelBox = new BoundingBox(currentX, box.getY(), currentX + (int) stringBounds.getWidth() + labelSpacing, box.getY() + (int) stringBounds.getHeight()); if (lastLabel == null) { lastLabel = labelBox; } else { lastLabel.add(labelBox); } } } else { // draw short tick if (!layoutOnly) { final int halfTickHeight = (int) Math.floor(tickLength / 2.0d); graphics.drawLine(currentX, box.getY() + axisHeight, currentX, box.getY() + axisHeight - halfTickHeight); } } // draw part of axis if (!layoutOnly) { graphics.drawLine((int) x, box.getY() + axisHeight, (int) (x + xIncrement), box.getY() + axisHeight); } x += xIncrement; currentDate = tickDuration.addTo(currentDate); } callback.getGraphics().setColor(oldColor); final BoundingBox result = lastLabel != null ? lastLabel : new BoundingBox(0, 0, 0, 0); result.incHeight(axisHeight); return result; }
From source file:org.activiti.rest.service.api.runtime.TaskQueryResourceTest.java
/** * Test querying tasks. GET runtime/tasks */// w w w .j a v a 2s . co m @Deployment public void testQueryTasks() throws Exception { try { Calendar adhocTaskCreate = Calendar.getInstance(); adhocTaskCreate.set(Calendar.MILLISECOND, 0); Calendar processTaskCreate = Calendar.getInstance(); processTaskCreate.add(Calendar.HOUR, 2); processTaskCreate.set(Calendar.MILLISECOND, 0); Calendar inBetweenTaskCreation = Calendar.getInstance(); inBetweenTaskCreation.add(Calendar.HOUR, 1); processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime()); Task adhocTask = taskService.newTask(); adhocTask.setAssignee("gonzo"); adhocTask.setOwner("owner"); adhocTask.setDelegationState(DelegationState.PENDING); adhocTask.setDescription("Description one"); adhocTask.setName("Name one"); adhocTask.setDueDate(adhocTaskCreate.getTime()); adhocTask.setPriority(100); adhocTask.setFormKey("myForm.json"); adhocTask.setCategory("some-category"); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT); processEngineConfiguration.getClock().setCurrentTime(processTaskCreate.getTime()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey"); Task processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()) .singleResult(); processTask.setParentTaskId(adhocTask.getId()); processTask.setPriority(50); processTask.setDueDate(processTaskCreate.getTime()); taskService.saveTask(processTask); // Check filter-less to fetch all tasks String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY); ObjectNode requestNode = objectMapper.createObjectNode(); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId(), adhocTask.getId()); // Name filtering requestNode.removeAll(); requestNode.put("name", "Name one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Name like filtering requestNode.removeAll(); requestNode.put("nameLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description filtering requestNode.removeAll(); requestNode.put("description", "Description one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description like filtering requestNode.removeAll(); requestNode.put("descriptionLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Priority filtering requestNode.removeAll(); requestNode.put("priority", 100); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Mininmum Priority filtering requestNode.removeAll(); requestNode.put("minimumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Maximum Priority filtering requestNode.removeAll(); requestNode.put("maximumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Owner filtering requestNode.removeAll(); requestNode.put("owner", "owner"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee filtering requestNode.removeAll(); requestNode.put("assignee", "gonzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Owner like filtering requestNode.removeAll(); requestNode.put("ownerLike", "owne%"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee like filtering requestNode.removeAll(); requestNode.put("assigneeLike", "%onzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Unassigned filtering requestNode.removeAll(); requestNode.put("unassigned", true); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Delegation state filtering requestNode.removeAll(); requestNode.put("delegationState", "pending"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Candidate user filtering requestNode.removeAll(); requestNode.put("candidateUser", "kermit"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group filtering requestNode.removeAll(); requestNode.put("candidateGroup", "sales"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group In filtering requestNode.removeAll(); ArrayNode arrayNode = requestNode.arrayNode(); arrayNode.add("sales"); arrayNode.add("someOtherGroup"); requestNode.put("candidateGroupIn", arrayNode); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Involved user filtering requestNode.removeAll(); requestNode.put("involvedUser", "misspiggy"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Process instance filtering requestNode.removeAll(); requestNode.put("processInstanceId", processInstance.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance id in filtering requestNode.removeAll(); arrayNode = requestNode.arrayNode(); arrayNode.add(processInstance.getId()); requestNode.put("processInstanceIdIn", arrayNode); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Execution filtering requestNode.removeAll(); Execution taskExecution = runtimeService.createExecutionQuery().activityId("processTask") .singleResult(); requestNode.put("executionId", taskExecution.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKey", "myBusinessKey"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey like filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKeyLike", "myBusiness%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key requestNode.removeAll(); requestNode.put("processDefinitionKey", "oneTaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key like requestNode.removeAll(); requestNode.put("processDefinitionKeyLike", "%TaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name requestNode.removeAll(); requestNode.put("processDefinitionName", "The One Task Process"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name like requestNode.removeAll(); requestNode.put("processDefinitionNameLike", "The One %"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CeatedOn filtering requestNode.removeAll(); requestNode.put("createdOn", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // CreatedAfter filtering requestNode.removeAll(); requestNode.put("createdAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CreatedBefore filtering requestNode.removeAll(); requestNode.put("createdBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Subtask exclusion requestNode.removeAll(); requestNode.put("excludeSubTasks", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Task definition key filtering requestNode.removeAll(); requestNode.put("taskDefinitionKey", "processTask"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Task definition key like filtering requestNode.removeAll(); requestNode.put("taskDefinitionKeyLike", "process%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Duedate filtering requestNode.removeAll(); requestNode.put("dueDate", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Due after filtering requestNode.removeAll(); requestNode.put("dueAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Due before filtering requestNode.removeAll(); requestNode.put("dueBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Suspend process-instance to have a supended task runtimeService.suspendProcessInstanceById(processInstance.getId()); // Suspended filering requestNode.removeAll(); requestNode.put("active", false); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Active filtering requestNode.removeAll(); requestNode.put("active", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering by category requestNode.removeAll(); requestNode.put("category", "some-category"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering without duedate requestNode.removeAll(); requestNode.put("withoutDueDate", true); // No response should be returned, no tasks without a duedate yet assertResultsPresentInPostDataResponse(url, requestNode); processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); processTask.setDueDate(null); taskService.saveTask(processTask); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); } finally { // Clean adhoc-tasks even if test fails List<Task> tasks = taskService.createTaskQuery().list(); for (Task task : tasks) { if (task.getExecutionId() == null) { taskService.deleteTask(task.getId(), true); } } } }
From source file:Main.java
private static void ceil(Calendar cal, int field) { cal.add(field, 1); cal.add(Calendar.MILLISECOND, -1); }