Verify audit logs format `audit2019`
Issue-ID: VID-253
Change-Id: Ic62c455c101311dc3ac3022912390209e3fd86e7
Signed-off-by: Ittay Stern <ittay.stern@att.com>
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
index b7ff82a..928e193 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
@@ -20,6 +20,8 @@
package org.onap.vid.controller;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -63,7 +65,7 @@
this.logfilePathCreator = logfilePathCreator;
}
- @GetMapping(value = "/{loggerName:audit|error|metrics}")
+ @GetMapping(value = "/{loggerName:audit|audit2019|error|metrics}")
public String getLog(@PathVariable String loggerName, HttpServletRequest request,
@RequestParam(value="limit", defaultValue = "5000") Integer limit) throws IOException {
@@ -74,7 +76,7 @@
}
String logfilePath = logfilePathCreator.getLogfilePath(loggerName);
- try (final ReversedLinesFileReader reader = new ReversedLinesFileReader(new File(logfilePath))) {
+ try (final ReversedLinesFileReader reader = new ReversedLinesFileReader(new File(logfilePath), UTF_8)) {
Supplier<String> reverseLinesSupplier = () -> {
try {
return reader.readLine();
diff --git a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
index 3ec0c16..e01ffe8 100644
--- a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
@@ -1,9 +1,8 @@
package org.onap.vid.more;
import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.junit.Assert.assertThat;
import com.fasterxml.jackson.databind.JsonNode;
import java.net.URI;
@@ -41,6 +40,11 @@
validateLogsFormat("audit");
}
+ @Test
+ public void validateAudit2019LogsFormat() {
+ validateLogsFormat("audit2019", "audit-ELS-2019.11", 0);
+ }
+
@Test(enabled = false) // no total-score is returned for error-log
public void validateErrorLogsFormat() {
validateLogsFormat("error");
@@ -57,6 +61,10 @@
}
private void validateLogsFormat(String logName, String logType) {
+ validateLogsFormat(logName, logType, 0.95);
+ }
+
+ private void validateLogsFormat(String logName, String logType, double score) {
String logLines = getLogLines(logName);
logger.info("logLines are: "+logLines);
@@ -65,8 +73,8 @@
double fieldscore = response.path("summary").path("score").path("fieldscore").asDouble();
double overall = response.path("summary").path("score").path("overallscore").asDouble();
- assertThat(fieldscore, is(greaterThan(0.95)));
- assertThat(overall, is(greaterThan(0.95)));
+ assertThat(fieldscore, is(greaterThanOrEqualTo(score)));
+ assertThat(overall, is(greaterThanOrEqualTo(score)));
}