incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.@apache.org
Subject svn commit: r982497 - /incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/runtime/TaskEvaluatorTest.java
Date Thu, 05 Aug 2010 08:08:30 GMT
Author: rr
Date: Thu Aug  5 08:08:30 2010
New Revision: 982497

URL: http://svn.apache.org/viewvc?rev=982497&view=rev
Log:
HISE-62: 'Until' deadline throws NPE (fix thanks to Maciej Próchniak)

Added:
    incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/runtime/TaskEvaluatorTest.java

Added: incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/runtime/TaskEvaluatorTest.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/runtime/TaskEvaluatorTest.java?rev=982497&view=auto
==============================================================================
--- incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/runtime/TaskEvaluatorTest.java
(added)
+++ incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/runtime/TaskEvaluatorTest.java
Thu Aug  5 08:08:30 2010
@@ -0,0 +1,57 @@
+/*
+ * Copyright by Touk (c) 2010
+*/
+package org.apache.hise.runtime;
+
+import org.apache.hise.lang.xsd.htd.TDeadline;
+import org.apache.hise.lang.xsd.htd.TDeadlineExpr;
+import org.apache.hise.lang.xsd.htd.TDurationExpr;
+import org.junit.Test;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static junit.framework.Assert.assertEquals;
+
+public class TaskEvaluatorTest {
+
+    @Test
+    public void shouldEvaluateForDeadline() throws Exception {
+        //given
+        TDeadline tDeadline = new TDeadline().withFor(new TDurationExpr().withContent("'P1D'"));
+        Task t = createMockTask();
+        t.setCurrentEventDateTime(new Date(0));
+
+        //when
+        Date evaluated = new TaskEvaluator(t).evaluateDeadline(tDeadline);
+
+        //then
+        assertDateEquals(evaluated, "1970-01-02");
+
+    }
+
+    @Test
+    public void shouldEvaluateUntilDeadline() throws Exception {
+
+        //given
+        TDeadline tDeadline = new TDeadline().withUntil(new TDeadlineExpr().withContent("2010-11-11"));
+
+        //when
+        Date evaluated = new TaskEvaluator(createMockTask()).evaluateDeadline(tDeadline);
+
+        //then
+        assertDateEquals(evaluated, "2010-11-11");
+    }
+
+    private void assertDateEquals(Date date, String dateString) {
+        assertEquals(new SimpleDateFormat("yyyy-MM-dd").format(date), dateString);
+    }
+
+    private Task createMockTask() {
+        Task task = new Task();
+        org.apache.hise.dao.Task taskDto = new org.apache.hise.dao.Task();
+        task.setTaskDto(taskDto);
+        return task;
+    }
+
+}



Mime
View raw message