Repository: authorjapps/zerocode
Pull request #27 (2018-02-05 20:47:38)

Zcode sonatype release branch


Patch:
diff --git a/pom.xml b/pom.xml
index b4dbb22d..cd129b8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
 
     <artifactId>zerocode-rest-bdd</artifactId>
     <groupId>org.jsmart</groupId>
-    <version>1.1.23-SNAPSHOT</version>
+    <version>1.1.24-SNAPSHOT</version>
 
     <packaging>jar</packaging>
     <name>ZeroCode REST BDD</name>
diff --git a/src/main/java/org/jsmart/zerocode/core/logbuilder/LogCorrelationshipPrinter.java b/src/main/java/org/jsmart/zerocode/core/logbuilder/LogCorrelationshipPrinter.java
index 0f62730a..722a9695 100644
--- a/src/main/java/org/jsmart/zerocode/core/logbuilder/LogCorrelationshipPrinter.java
+++ b/src/main/java/org/jsmart/zerocode/core/logbuilder/LogCorrelationshipPrinter.java
@@ -1,7 +1,7 @@
 package org.jsmart.zerocode.core.logbuilder;
 
-import org.jsmart.zerocode.core.domain.reports.ZeroCodeReportStep;
 import org.jsmart.zerocode.core.domain.builders.ZeroCodeReportStepBuilder;
+import org.jsmart.zerocode.core.domain.reports.ZeroCodeReportStep;
 import org.slf4j.Logger;
 
 import java.time.Duration;
@@ -96,16 +96,9 @@ public class LogCorrelationshipPrinter {
     }
 
     public static double durationMilliSecBetween(LocalDateTime requestTimeStamp, LocalDateTime responseTimeStamp) {
-        return Duration.between(
-                requestTimeStamp,
-                responseTimeStamp)
-
-                /*
-                 * 1000000D: Without D it does a integer division and the precision is lost
-                 * Note: Java does not have a get(millisec-tem[poral) as of now, only nano
-                 * or sec precision is supported
-                 */
-                .getNano()/1000000D;
+
+        Duration dur = Duration.between(requestTimeStamp, responseTimeStamp);
+        return dur.toMillis();
     }
 
     public static String createRelationshipId() {


Test patch:
diff --git a/src/test/java/org/jsmart/zerocode/core/logbuilder/LogCorrelationshipPrinterTest.java b/src/test/java/org/jsmart/zerocode/core/logbuilder/LogCorrelationshipPrinterTest.java
new file mode 100644
index 00000000..05ecef5f
--- /dev/null
+++ b/src/test/java/org/jsmart/zerocode/core/logbuilder/LogCorrelationshipPrinterTest.java
@@ -0,0 +1,42 @@
+package org.jsmart.zerocode.core.logbuilder;
+
+import org.junit.Test;
+
+import java.time.LocalDateTime;
+
+import static java.time.LocalDateTime.parse;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.jsmart.zerocode.core.logbuilder.LogCorrelationshipPrinter.durationMilliSecBetween;
+
+public class LogCorrelationshipPrinterTest {
+
+    @Test
+    public void testResponseDelayInMilliSec() throws Exception {
+
+        LocalDateTime startTime;
+        LocalDateTime endTime;
+        double delayInMilliSec;
+
+        startTime = parse("2018-02-05T19:46:32.001");
+        endTime = parse("2018-02-05T19:46:32.101");
+        delayInMilliSec = durationMilliSecBetween(startTime, endTime);
+        assertThat(delayInMilliSec, is(100D));
+
+        startTime = parse("2018-02-05T19:46:31.631");
+        endTime = parse("2018-02-05T19:46:32.731");
+        delayInMilliSec = durationMilliSecBetween(startTime, endTime);
+        assertThat(delayInMilliSec, is(1100D));
+
+        startTime = parse("2018-02-05T19:45:31.631");
+        endTime = parse("2018-02-05T19:46:32.731");
+        delayInMilliSec = durationMilliSecBetween(startTime, endTime);
+        assertThat(delayInMilliSec, is(61100D));
+
+        startTime = parse("2018-02-05T18:46:31.631");
+        endTime = parse("2018-02-05T19:46:32.731");
+        delayInMilliSec = durationMilliSecBetween(startTime, endTime);
+        assertThat(delayInMilliSec, is(3601100D));
+
+    }
+}
\ No newline at end of file