List of usage examples for java.util Queue peek
E peek();
From source file:pt.webdetails.cda.cache.scheduler.CacheActivator.java
public static void reschedule(Queue<CachedQuery> queue) { CachedQuery q = queue.peek(); Date dueAt = (q != null) ? q.getNextExecution() : null; IPentahoSession session = new StandaloneSession(JOB_GROUP); Scheduler sched = QuartzSystemListener.getSchedulerInstance(); SchedulerHelper.deleteJob(session, JOB_ACTION, JOB_GROUP); SchedulerHelper.createSimpleTriggerJob(session, "system", "cda/actions", JOB_ACTION, TRIGGER_NAME, JOB_GROUP, "", dueAt, null, 0, 0); }
From source file:test.jamocha.languages.clips.BindTest.java
@Test public void testTranslateRHSBind() throws ParseException { final Network network = new Network(); final ByteArrayOutputStream out = initializeAppender(network); run(network, "(unwatch all)\n"); {//from w ww .j a v a2s . co m final Pair<Queue<Object>, Queue<Warning>> returnValues = run(network, "(deftemplate f1 (slot s1 (type INTEGER)))\n" + "(defrule r1 (f1 (s1 ?x)) => (bind ?y (+ ?x 2)) (assert (f1 (s1 ?y))) ) \n"); assertThat(returnValues.getLeft(), empty()); assertThat(returnValues.getRight(), empty()); assertThat(out.toString(), isEmptyString()); out.reset(); } { final Pair<Queue<Object>, Queue<Warning>> returnValues = run(network, "(assert (f1 (s1 5)))"); final Queue<Object> left = returnValues.getLeft(); assertThat(left, hasSize(1)); assertThat(left.peek(), instanceOf(String.class)); assertThat(returnValues.getRight(), empty()); assertThat(out.toString(), isEmptyString()); out.reset(); } { final Pair<Queue<Object>, Queue<Warning>> returnValues = run(network, "(watch facts)"); assertThat(returnValues.getLeft(), empty()); assertThat(returnValues.getRight(), empty()); assertThat(out.toString(), isEmptyString()); out.reset(); } { final Pair<Queue<Object>, Queue<Warning>> returnValues = run(network, "(run 1)"); assertThat(returnValues.getLeft(), empty()); assertThat(returnValues.getRight(), empty()); final String output = out.toString(); assertThat(output, not(isEmptyString())); final String[] lines = output.split(LINE_SEPARATOR); assertThat(lines, arrayWithSize(1)); assertEquals("==> f-3\t(f1 (s1 7))", lines[0]); out.reset(); } }