private NSTimestamp randomTimestamp() { return new NSTimestamp().timestampByAddingGregorianUnits(0, 0, 0, -randomInt(24 * 1000), 0, 0); }
/** * Returns a new value by adding a delta to it. * In case of a {@link NSTimestamp}, the delta will be seconds, * in case of a {@link java.lang.Number Number}, the delta is added as a double. * Otherwise, a conversion to a double is attempted and the delta is added afterwards. */ protected Object newWithDelta(Object val, double delta) { double v; if (val instanceof NSTimestamp) { NSTimestamp vts = (NSTimestamp)val; NSTimestamp nvts = vts.timestampByAddingGregorianUnits(0, 0, 0, 0, 0, (int)delta); return nvts; } else if (val instanceof Number) { v = DRValueConverter.converter().doubleForValue(val) + delta; return (Double.valueOf(v)); } v = DRValueConverter.converter().doubleForValue(val) + delta; return Double.toString(v); }
public EOFetchSpecification fetchSpecificationForRecentBugs() { EOFetchSpecification fs = newFetchSpecification( andQualifier( new EOKeyValueQualifier(Key.DATE_MODIFIED, EOQualifier.QualifierOperatorGreaterThan, new NSTimestamp().timestampByAddingGregorianUnits(0, -1, 0, 0, 0, 0)), negateQualifier(qualifierForState(State.CLOSED)))); fs.setSortOrderings(new NSArray(new EOSortOrdering(Key.DATE_MODIFIED, EOSortOrdering.CompareDescending))); fs.setIsDeep(false); return fs; }
protected void resetSession(WOResponse response) { if(context().hasSession() || true) { session().terminate(); } String[] keys = cookieKeys(); for (int i = 0; i < keys.length; i++) { String key = keys[i]; WOCookie dummyCookie = new WOCookie(key, "dummy"); dummyCookie.setPath("/"); dummyCookie.setDomain(null); // Let the browser set the domain dummyCookie.setExpires(new NSTimestamp().timestampByAddingGregorianUnits(0, -2, 0, 0, 0, 0)); response.addCookie(dummyCookie); } }
private void addComments(Bug bug) { int maxComments = randomInt(20); int last = 0; for (int i = 0; i < maxComments; i++) { Comment comment = Comment.clazz.createAndInsertObject(ec); int hours = last + randomInt(48); comment.setDateSubmitted(bug.dateSubmitted().timestampByAddingGregorianUnits(0, 0, 0, hours, 0, 0)); comment.setOriginator(randomUser()); comment.setTextDescription(randomText(50)); last = hours; comment.setBug(bug); bug.addToComments(comment); comment.validateForSave(); } }
NSTimestamp dateDue = new NSTimestamp().timestampByAddingGregorianUnits(0, 5, 0, 0, 0, 0); for (int i = 8; i >= 0; i--) { Release release = releases.objectAtIndex(i); release.setDateDue(dateDue); dateDue = dateDue.timestampByAddingGregorianUnits(0, -(randomInt(2) + 1), 0, 0, 0, 0); bugs.addObject(bug); bug.setDateSubmitted(randomTimestamp()); bug.setDateModified(bug.dateSubmitted().timestampByAddingGregorianUnits(0, 0, 0, randomInt(24 * 1000), 0, 0)); bug.setComponent(randomComponent()); bug.setSubject(randomWords(50)); requirements.addObject(bug); bug.setDateSubmitted(randomTimestamp()); bug.setDateModified(bug.dateSubmitted().timestampByAddingGregorianUnits(0, 0, 0, randomInt(24 * 100), 0, 0)); bug.setComponent(randomComponent()); bug.setSubject(randomWords(50));