From 4ea1d222e8a0c2573dea11891269608c9431d5ac Mon Sep 17 00:00:00 2001 From: itaiag Date: Mon, 15 Jan 2018 22:54:50 +0200 Subject: [PATCH] Handling cases in which the date is missing --- .../src/main/java/il/co/topq/difido/DateTimeConverter.java | 6 ++++++ .../il/co/topq/report/business/elastic/ESController.java | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/difido-reports-common/src/main/java/il/co/topq/difido/DateTimeConverter.java b/difido-reports-common/src/main/java/il/co/topq/difido/DateTimeConverter.java index 5f37c0fe..f6c06ed2 100644 --- a/difido-reports-common/src/main/java/il/co/topq/difido/DateTimeConverter.java +++ b/difido-reports-common/src/main/java/il/co/topq/difido/DateTimeConverter.java @@ -25,6 +25,8 @@ public class DateTimeConverter { private static final DateTimeFormatter ELASTICSEARCH_FORMATTER_SUFFIX = DateTimeFormatter .ofPattern("yyyy/MM/dd HH:mm:ss:"); + private static final DateTimeFormatter REVERSE_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd"); + private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss:SS"); @@ -96,6 +98,10 @@ public String toElasticString() { public String toDateString() { return date.toInstant().atZone(ZoneId.systemDefault()).format(DATE_FORMATTER); } + + public String toReverseDateString() { + return date.toInstant().atZone(ZoneId.systemDefault()).format(REVERSE_DATE_FORMATTER); + } public String toTimeString() { return date.toInstant().atZone(ZoneId.systemDefault()).format(TIME_FORMATTER); diff --git a/server/difido-server/src/main/java/il/co/topq/report/business/elastic/ESController.java b/server/difido-server/src/main/java/il/co/topq/report/business/elastic/ESController.java index e23a122b..b31483ff 100644 --- a/server/difido-server/src/main/java/il/co/topq/report/business/elastic/ESController.java +++ b/server/difido-server/src/main/java/il/co/topq/report/business/elastic/ESController.java @@ -413,8 +413,10 @@ private List convertToElasticTests(ExecutionMetadata metadata private ElasticsearchTest testNodeToElasticTest(ExecutionMetadata metadata, MachineNode machineNode, TestNode testNode) { String timestamp = null; - if (testNode.getTimestamp() != null) { + if (testNode.getDate() != null && testNode.getTimestamp() != null) { timestamp = testNode.getDate() + " " + testNode.getTimestamp(); + } else if (null == testNode.getDate() && testNode.getTimestamp() !=null) { + timestamp = fromNowDateObject().toReverseDateString() + " " + testNode.getTimestamp(); } else { timestamp = fromNowDateObject().toElasticString(); }