aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/masspnfsim/pnf-sim-lightweight
diff options
context:
space:
mode:
authorEli Halych <illia.halych@t-mobile.pl>2020-12-07 13:13:53 +0000
committerEli Halych <illia.halych@t-mobile.pl>2020-12-07 13:40:12 +0000
commit2c4c61213c9f2f8fba83a2244fa7afe0a6feb481 (patch)
treebc0b31d1ec616f68ab6481dfbfc9017439d948cf /test/mocks/masspnfsim/pnf-sim-lightweight
parenta579a48948f0b61bb9d98e1591d1fe727a550dbb (diff)
Allow customization of commonEventHeadres before request is sent
Details: - Python handler is allowed to take --data argument with fields to be overriden. - In python handler the original dictionary from config.json is merged with custom sourceName and reportingEntityName if provided. - Java source code generates default sourceName and reportingEntityName as part of default data in the form of "default-XXX", where XXX is YEAR, MONTH and DAY as integers. - If such default data is received in the request body, don't override them with default values. - BUG FIXED: the previous solution used abstract path that could be "/" that resulted in empty strings for sourceName and reportingEntityName. Issue-ID: INT-1800 Signed-off-by: Eli Halych <illia.halych@t-mobile.pl> Change-Id: Ic88c5606a44abac64f842f28621332f3f86b83c6
Diffstat (limited to 'test/mocks/masspnfsim/pnf-sim-lightweight')
-rw-r--r--test/mocks/masspnfsim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/mocks/masspnfsim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java b/test/mocks/masspnfsim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
index ded991044..7c12983f0 100644
--- a/test/mocks/masspnfsim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
+++ b/test/mocks/masspnfsim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
@@ -50,6 +50,7 @@ import static org.onap.pnfsimulator.message.MessageConstants.VERSION;
import static org.onap.pnfsimulator.message.MessageConstants.VERSION_NUMBER;
import static org.onap.pnfsimulator.message.MessageConstants.VES_EVENT_LISTENER_VERSION;
import static org.onap.pnfsimulator.message.MessageConstants.VES_EVENT_LISTENER_VERSION_NUMBER;
+import java.util.Calendar;
import java.io.File;
import java.util.List;
import java.util.TimeZone;
@@ -61,6 +62,7 @@ final class JSONObjectFactory {
static JSONObject generateConstantCommonEventHeader() {
JSONObject commonEventHeader = new JSONObject();
long timestamp = System.currentTimeMillis();
+ String nodeName = generateDefaultName();
commonEventHeader.put(EVENT_ID, generateEventId());
commonEventHeader.put(TIME_ZONE_OFFSET, generateTimeZone(timestamp));
commonEventHeader.put(LAST_EPOCH_MICROSEC, timestamp);
@@ -70,8 +72,6 @@ final class JSONObjectFactory {
commonEventHeader.put(INTERNAL_HEADER_FIELDS, new JSONObject());
commonEventHeader.put(VERSION, VERSION_NUMBER);
commonEventHeader.put(VES_EVENT_LISTENER_VERSION, VES_EVENT_LISTENER_VERSION_NUMBER);
- String absPath = new File("").getAbsolutePath();
- String nodeName = absPath.substring(absPath.lastIndexOf(File.separator)+1);
commonEventHeader.put(SOURCE_NAME, nodeName);
commonEventHeader.put(REPORTING_ENTITY_NAME, nodeName);
return commonEventHeader;
@@ -118,6 +118,15 @@ final class JSONObjectFactory {
return String.format("FileReady_%s", timeAsString);
}
+ static String generateDefaultName() {
+ String defaultName = "default";
+ int year = Calendar.getInstance().get(Calendar.YEAR);
+ int month = Calendar.getInstance().get(Calendar.MONTH);
+ int day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
+
+ return defaultName + "-" + year + month + day;
+ }
+
static String generateTimeZone(long timestamp) {
TimeZone timeZone = TimeZone.getDefault();
int offsetInMillis = timeZone.getOffset(timestamp);