aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks')
-rwxr-xr-xtest/mocks/mass-pnf-sim/pnf-sim-lightweight/ROP_file_creator.sh12
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.json30
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/json_schema/input_validator.json96
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/FileProvider.java18
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java54
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java14
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java159
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java37
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template_new.xml.gz (renamed from test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template.xml.gz)bin188545 -> 188545 bytes
9 files changed, 110 insertions, 310 deletions
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/ROP_file_creator.sh b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/ROP_file_creator.sh
index 39d8498f1..6ea6ffde0 100755
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/ROP_file_creator.sh
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/ROP_file_creator.sh
@@ -1,7 +1,8 @@
#!/bin/bash
MAIN_DIRECTORY=${PWD##*/}
-FILE_DIRECTORY=./files/onap
-FILE_TEMPLATE=./templates/file_template.xml.gz
+FULL_DIRECTORY=${PWD}
+FILE_DIRECTORY=$FULL_DIRECTORY/files/onap
+FILE_TEMPLATE=$FULL_DIRECTORY/templates/file_template_new.xml.gz
UPDATE_MINS=15
NUM_FILES=96
@@ -11,11 +12,11 @@ mkdir -p "$FILE_DIRECTORY"
for ((n=0;n<$NUM_FILES;n++))
do
if [[ "$OSTYPE" == "linux-gnu" ]]; then # Linux OS
- DATE=$(date -d $(($UPDATE_MINS*$n))" minutes ago" +"%Y%m%d")
+ DATE=$(date -d $(($UPDATE_MINS*($n+1)-1))" minutes ago" +"%Y%m%d")
TIME_START=$(date -d $(($UPDATE_MINS*($n+1)-1))" minutes ago" +"%H%M%z")
TIME_END=$(date -d $(($UPDATE_MINS*$n))" minutes ago" +"%H%M%z")
elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS
- DATE=$(date -v "-"$(($UPDATE_MINS*$n))"M" +"%Y%m%d")
+ DATE=$(date -v "-"$(($UPDATE_MINS*($n+1)-1))"M" +"%Y%m%d")
TIME_START=$(date -v "-"$(($UPDATE_MINS*($n+1)-1))"M" +"%H%M%z")
TIME_END=$(date -v "-"$(($UPDATE_MINS*$n))"M" +"%H%M%z")
else
@@ -36,11 +37,12 @@ do
OLD_TIMESTAMP=${TIMESTAMP_ARRAY[$NUM_FILES-1]}
unset TIMESTAMP_ARRAY[$NUM_FILES-1]
- DATE=$(date +"%Y%m%d")
TIME_END=$(date +"%H%M%z")
if [[ "$OSTYPE" == "linux-gnu" ]]; then # Linux OS
+ DATE=$(date -d $(($UPDATE_MINS-1))" minutes ago" +"%Y%m%d")
TIME_START=$(date -d $(($UPDATE_MINS-1))" minutes ago" +"%H%M%z")
elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS
+ DATE=$(date -v "-"$(($UPDATE_MINS-1))"M" +"%Y%m%d")
TIME_START=$(date -v "-"$(($UPDATE_MINS-1))"M" +"%H%M%z")
else
echo "ERROR: OS not supported"
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.json b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.json
index 8d6342d9d..9d2ba7e08 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.json
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.json
@@ -1,35 +1,15 @@
{
"simulatorParams": {
- "vesServerUrl": "http://10.10.1.99:9999/eventListener/v7",
- "testDuration": "1",
- "messageInterval": "1"
+ "testDuration": "86400",
+ "messageInterval": "900"
},
"commonEventHeaderParams": {
- "eventName": "pnfRegistration_Nokia_5gDu",
+ "eventName": "Noti_RnNode-Ericsson_FileReady",
"nfNamingCode": "gNB",
- "nfcNamingCode": "oam",
- "sourceName": "NOK6061ZW3",
- "sourceId": "val13",
- "reportingEntityName": "NOK6061ZW3"
+ "nfcNamingCode": "oam"
},
"notificationParams": {
"changeIdentifier": "PM_MEAS_FILES",
- "changeType": "FileReady",
- "arrayOfNamedHashMap": [
- {"name": "A20161221.1031-1041.bin.gz", "hashMap": {
- "location": "ftpes://192.169.0.1:22/ftp/rop/A20161224.1030-1045.bin.gz",
- "compression": "gzip",
- "fileFormatType": "org.3GPP.32.435#measCollec",
- "fileFormatVersion": "V10"
- }
- },
- {"name": "A20161222.1042-1102.bin.gz", "hashMap": {
- "location": "ftpes://192.168.0.102:22/ftp/rop/A20161224.1045-1100.bin.gz",
- "compression": "gzip",
- "fileFormatType": "org.3GPP.32.435#measCollec",
- "fileFormatVersion": "V10"
- }
- }
- ]
+ "changeType": "FileReady"
}
}
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/json_schema/input_validator.json b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/json_schema/input_validator.json
index 4e75e0adc..7b38e05d6 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/json_schema/input_validator.json
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/json_schema/input_validator.json
@@ -5,9 +5,6 @@
"simulatorParams": {
"type": "object",
"properties": {
- "vesServerUrl": {
- "type": "string"
- },
"testDuration": {
"type": "string"
},
@@ -16,7 +13,6 @@
}
},
"required": [
- "vesServerUrl",
"testDuration",
"messageInterval"
]
@@ -32,22 +28,10 @@
},
"nfcNamingCode": {
"type": "string"
- },
- "sourceName": {
- "type": "string"
- },
- "sourceId": {
- "type": "string"
- },
- "reportingEntityName": {
- "type": "string"
}
},
"required": [
- "eventName",
- "sourceName",
- "sourceId",
- "reportingEntityName"
+ "eventName"
]
},
@@ -99,87 +83,11 @@
},
"changeType": {
"type": "string"
- },
- "arrayOfNamedHashMap": {
- "type": "array",
- "items": [
- {
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "hashMap": {
- "type": "object",
- "properties": {
- "location": {
- "type": "string"
- },
- "compression": {
- "type": "string"
- },
- "fileFormatType": {
- "type": "string"
- },
- "fileFormatVersion": {
- "type": "string"
- }
- },
- "required": [
- "location",
- "compression",
- "fileFormatType",
- "fileFormatVersion"
- ]
- }
- },
- "required": [
- "name",
- "hashMap"
- ]
- },
- {
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "hashMap": {
- "type": "object",
- "properties": {
- "location": {
- "type": "string"
- },
- "compression": {
- "type": "string"
- },
- "fileFormatType": {
- "type": "string"
- },
- "fileFormatVersion": {
- "type": "string"
- }
- },
- "required": [
- "location",
- "compression",
- "fileFormatType",
- "fileFormatVersion"
- ]
- }
- },
- "required": [
- "name",
- "hashMap"
- ]
- }
- ]
}
},
"required": [
"changeIdentifier",
- "changeType",
- "arrayOfNamedHashMap"
+ "changeType"
]
}
},
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/FileProvider.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/FileProvider.java
index 9361e4ceb..9eb733227 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/FileProvider.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/FileProvider.java
@@ -7,34 +7,34 @@ import java.util.List;
public class FileProvider {
- public static ArrayList<String> getFiles() {
+ private FileProvider() {}
- List<String> files = QueryFiles();
+ public static List<String> getFiles() {
- Collections.sort(files);
+ List<String> files = queryFiles();
- ArrayList<String> fileListSorted = new ArrayList<String>();
+ files.sort(Collections.reverseOrder());
+
+ List<String> fileListSorted = new ArrayList<>();
for (String f : files) {
- System.out.println("Next file: " + f);
fileListSorted.add(f);
}
return fileListSorted;
}
- private static List<String> QueryFiles() {
+ private static List<String> queryFiles() {
File folder = new File("./files/onap/");
File[] listOfFiles = folder.listFiles();
- ArrayList<String> results = new ArrayList<String>();
+ List<String> results = new ArrayList<>();
if (listOfFiles.length == 0) {
- return null;
+ return results;
// TODO: this should be a thrown exception catched in the Simulator class
}
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
- System.out.println("File: " + listOfFiles[i].getName());
results.add(listOfFiles[i].getName());
}
}
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
index 3ebf5674a..545a56882 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
@@ -20,9 +20,18 @@
package org.onap.pnfsimulator.message;
+import static org.onap.pnfsimulator.message.MessageConstants.COMPRESSION;
+import static org.onap.pnfsimulator.message.MessageConstants.COMPRESSION_VALUE;
import static org.onap.pnfsimulator.message.MessageConstants.EVENT_ID;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_TYPE;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_TYPE_VALUE;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_VERSION;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_VERSION_VALUE;
+import static org.onap.pnfsimulator.message.MessageConstants.HASH_MAP;
import static org.onap.pnfsimulator.message.MessageConstants.INTERNAL_HEADER_FIELDS;
import static org.onap.pnfsimulator.message.MessageConstants.LAST_EPOCH_MICROSEC;
+import static org.onap.pnfsimulator.message.MessageConstants.LOCATION;
+import static org.onap.pnfsimulator.message.MessageConstants.NAME;
import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS_VERSION;
import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS_VERSION_VALUE;
import static org.onap.pnfsimulator.message.MessageConstants.PNF_LAST_SERVICE_DATE;
@@ -31,14 +40,20 @@ import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FI
import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS_VERSION_VALUE;
import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY;
import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY_NORMAL;
+import static org.onap.pnfsimulator.message.MessageConstants.REPORTING_ENTITY_NAME;
import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE;
import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE_NUMBER;
+import static org.onap.pnfsimulator.message.MessageConstants.SOURCE_NAME;
import static org.onap.pnfsimulator.message.MessageConstants.START_EPOCH_MICROSEC;
+import static org.onap.pnfsimulator.message.MessageConstants.TIME_ZONE_OFFSET;
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.io.File;
+import java.util.List;
+import java.util.TimeZone;
+import org.json.JSONArray;
import org.json.JSONObject;
final class JSONObjectFactory {
@@ -47,6 +62,7 @@ final class JSONObjectFactory {
JSONObject commonEventHeader = new JSONObject();
long timestamp = System.currentTimeMillis();
commonEventHeader.put(EVENT_ID, generateEventId());
+ commonEventHeader.put(TIME_ZONE_OFFSET, generateTimeZone(timestamp));
commonEventHeader.put(LAST_EPOCH_MICROSEC, timestamp);
commonEventHeader.put(PRIORITY, PRIORITY_NORMAL);
commonEventHeader.put(SEQUENCE, SEQUENCE_NUMBER);
@@ -54,6 +70,10 @@ 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 = System.getProperty("user.dir");
+ String nodeName = absPath.substring(absPath.lastIndexOf(File.separator)+1);
+ commonEventHeader.put(SOURCE_NAME, nodeName);
+ commonEventHeader.put(REPORTING_ENTITY_NAME, nodeName);
return commonEventHeader;
}
@@ -71,11 +91,39 @@ final class JSONObjectFactory {
return notificationFields;
}
+ static JSONArray generateArrayOfNamedHashMap(List<String> fileList, String xnfUrl) {
+ JSONArray arrayOfNamedHashMap = new JSONArray();
+
+ for (String fileName : fileList) {
+ JSONObject namedHashMap = new JSONObject();
+ namedHashMap.put(NAME, fileName);
+
+ JSONObject hashMap = new JSONObject();
+ hashMap.put(FILE_FORMAT_TYPE, FILE_FORMAT_TYPE_VALUE);
+ hashMap.put(LOCATION, xnfUrl.concat(fileName));
+ hashMap.put(FILE_FORMAT_VERSION, FILE_FORMAT_VERSION_VALUE);
+ hashMap.put(COMPRESSION, COMPRESSION_VALUE);
+ namedHashMap.put(HASH_MAP, hashMap);
+
+ arrayOfNamedHashMap.put(namedHashMap);
+ }
+
+
+ return arrayOfNamedHashMap;
+ }
+
static String generateEventId() {
String timeAsString = String.valueOf(System.currentTimeMillis());
- return String.format("registration_%s",
- timeAsString.substring(timeAsString.length() - 11, timeAsString.length() - 3));
+ return String.format("FileReady_%s", timeAsString);
+ }
+
+ static String generateTimeZone(long timestamp) {
+ TimeZone timeZone = TimeZone.getDefault();
+ int offsetInMillis = timeZone.getOffset(timestamp);
+ String offsetHHMM = String.format("%02d:%02d", Math.abs(offsetInMillis / 3600000),
+ Math.abs((offsetInMillis / 60000) % 60));
+ return ("UTC" + (offsetInMillis >= 0 ? "+" : "-") + offsetHHMM);
}
private JSONObjectFactory() {
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
index 95e8f69f3..6ff6e5dc8 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
@@ -43,6 +43,7 @@ public final class MessageConstants {
//parameters
static final String DOMAIN = "domain";
static final String EVENT_ID = "eventId";
+ static final String TIME_ZONE_OFFSET = "timeZoneOffset";
static final String EVENT_TYPE = "eventType";
static final String LAST_EPOCH_MICROSEC = "lastEpochMicrosec";
static final String PRIORITY = "priority";
@@ -51,6 +52,8 @@ public final class MessageConstants {
static final String INTERNAL_HEADER_FIELDS = "internalHeaderFields";
static final String VERSION = "version";
static final String VES_EVENT_LISTENER_VERSION = "vesEventListenerVersion";
+ static final String SOURCE_NAME = "sourceName";
+ static final String REPORTING_ENTITY_NAME = "reportingEntityName";
//constant values
static final int SEQUENCE_NUMBER = 0;
static final String VERSION_NUMBER = "4.0.1";
@@ -71,9 +74,20 @@ public final class MessageConstants {
// Notifications
//parameters
static final String NOTIFICATION_FIELDS_VERSION = "notificationFieldsVersion";
+ static final String ARRAY_OF_NAMED_HASH_MAP = "arrayOfNamedHashMap";
+ static final String NAME = "name";
+ static final String HASH_MAP = "hashMap";
+ static final String FILE_FORMAT_TYPE = "fileFormatType";
+ static final String LOCATION = "location";
+ static final String FILE_FORMAT_VERSION = "fileFormatVersion";
+ static final String COMPRESSION = "compression";
+
//constant values
static final String NOTIFICATION_FIELDS_VERSION_VALUE = "2.0";
static final String DOMAIN_NOTIFICATION ="notification";
+ static final String FILE_FORMAT_TYPE_VALUE = "org.3GPP.32.435#measCollec";
+ static final String FILE_FORMAT_VERSION_VALUE = "V10";
+ static final String COMPRESSION_VALUE = "gzip";
private MessageConstants() {
}
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
index 839d40269..c86362509 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
@@ -17,6 +17,7 @@
package org.onap.pnfsimulator.message;
+import static org.onap.pnfsimulator.message.MessageConstants.ARRAY_OF_NAMED_HASH_MAP;
import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN;
import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN_NOTIFICATION;
@@ -25,7 +26,8 @@ import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
import static org.onap.pnfsimulator.message.MessageConstants.EVENT_TYPE;
import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS;
import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS;
-import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.json.JSONArray;
@@ -35,6 +37,13 @@ public class MessageProvider {
public JSONObject createMessage(JSONObject commonEventHeaderParams, Optional<JSONObject> pnfRegistrationParams,
Optional<JSONObject> notificationParams) {
+ List<String> emptyList = new ArrayList<>();
+ String emptyString = "";
+ return createMessage(commonEventHeaderParams, pnfRegistrationParams, notificationParams, emptyList, emptyString);
+ }
+
+ public JSONObject createMessage(JSONObject commonEventHeaderParams, Optional<JSONObject> pnfRegistrationParams,
+ Optional<JSONObject> notificationParams, List<String> fileList, String xnfUrl) {
if (!pnfRegistrationParams.isPresent() && !notificationParams.isPresent()) {
throw new IllegalArgumentException(
@@ -59,6 +68,8 @@ public class MessageProvider {
JSONObject notificationFields = JSONObjectFactory.generateNotificationFields();
notificationParams.ifPresent(jsonObject -> {
copyParametersToFields(jsonObject.toMap(), notificationFields);
+ JSONArray arrayOfNamedHashMap = JSONObjectFactory.generateArrayOfNamedHashMap(fileList, xnfUrl);
+ notificationFields.put(ARRAY_OF_NAMED_HASH_MAP, arrayOfNamedHashMap);
commonEventHeader.put(DOMAIN, DOMAIN_NOTIFICATION);
event.put(NOTIFICATION_FIELDS, notificationFields);
});
@@ -74,150 +85,4 @@ public class MessageProvider {
fieldsJsonObject.put(key, value);
});
}
-
- public JSONObject createOneVes(JSONObject commonEventHeaderParams, Optional<JSONObject> pnfRegistrationParams,
- Optional<JSONObject> notificationParams, String url, String fileName) {
-
-
- if (!pnfRegistrationParams.isPresent() && !notificationParams.isPresent()) {
- throw new IllegalArgumentException(
- "Both PNF registration and notification parameters objects are not present");
- }
- JSONObject event = new JSONObject();
-
- JSONObject commonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- Map<String, Object> commonEventHeaderFields = commonEventHeaderParams.toMap();
- commonEventHeaderFields.forEach((key, value) -> {
- commonEventHeader.put(key, value);
- });
-
- JSONObject pnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
- pnfRegistrationParams.ifPresent(jsonObject -> {
- copyParametersToFields(jsonObject.toMap(), pnfRegistrationFields);
- commonEventHeader.put(DOMAIN, DOMAIN_PNF_REGISTRATION);
- commonEventHeader.put(EVENT_TYPE, DOMAIN_PNF_REGISTRATION);
- event.put(PNF_REGISTRATION_FIELDS, pnfRegistrationFields);
- });
-
- JSONObject notificationFields = JSONObjectFactory.generateNotificationFields();
-
- Map hashMap = new HashMap();
- hashMap.put("location", "LOCATION_DUMMY");
- hashMap.put("fileFormatType", "org.3GPP.32.435#measCollec");
- hashMap.put("fileFormatVersion", "V10");
- hashMap.put("compression", "gzip");
-
-
- JSONObject jsonHashMap = new JSONObject();
- jsonHashMap.put("hashmap", jsonHashMap);
-
- JSONArray jsonArrayOfNamedHashMap = new JSONArray();
- jsonArrayOfNamedHashMap.put(jsonHashMap);
-
- event.put(COMMON_EVENT_HEADER, commonEventHeader);
- JSONObject root = new JSONObject();
- root.put(EVENT, event);
- return root;
-
- }
-
- public JSONObject createOneVesEvent(String xnfUrl, String fileName) {
-
- JSONObject nof = new JSONObject();
-
- nof.put("notificationFieldsVersion", "2.0");
-
- nof.put("changeType", "FileReady");
- nof.put("changeIdentifier", "PM_MEAS_FILES");
-
- JSONObject hm = new JSONObject();
- hm.put("location", "ftpes://".concat(xnfUrl).concat(fileName));
- hm.put("fileFormatType", "org.3GPP.32.435#measCollec");
- hm.put("fileFormatVersion", "V10");
- hm.put("compression", "gzip");
-
- JSONObject aonhElement = new JSONObject();
- aonhElement.put("name", fileName);
- aonhElement.put("hashMap", hm);
-
- JSONArray aonh = new JSONArray();
- aonh.put(aonhElement);
-
- nof.put("arrayOfNamedHashMap", aonh);
-
- JSONObject ceh = new JSONObject(); // commonEventHandler
- ceh.put("startEpochMicrosec", "1551865758690");
- ceh.put("sourceId", "val13");
- ceh.put("eventId", "registration_51865758");
- ceh.put("nfcNamingCode", "oam");
- ceh.put("priority", "Normal");
- ceh.put("version", "4.0.1");
- ceh.put("reportingEntityName", "NOK6061ZW3");
- ceh.put("sequence", "0");
- ceh.put("domain", "notification");
- ceh.put("lastEpochMicrosec", "1551865758690");
- ceh.put("eventName", "pnfRegistration_Nokia_5gDu");
- ceh.put("vesEventListenerVersion", "7.0.1");
- ceh.put("sourceName", "NOK6061ZW3");
- ceh.put("nfNamingCode", "gNB");
-
- JSONObject ihf = new JSONObject(); // internalHeaderFields
- ceh.put("internalHeaderFields", ihf);
-
- JSONObject eventContent = new JSONObject();
- eventContent.put("commonEventHeader", ceh);
- eventContent.put("notificationFields", nof);
-
-
- JSONObject event = new JSONObject();
- event.put("event", eventContent);
-
- System.out.println("VES messages to be sent: ");
- System.out.println(event.toString());
-
- return event;
-
- // @formatter:off
- /*
- {
- "event": {
- "commonEventHeader": { <== "ceh"
- "startEpochMicrosec": "1551865758690",
- "sourceId": "val13",
- "eventId": "registration_51865758",
- "nfcNamingCode": "oam",
- "internalHeaderFields": {}, <== "ihf"
- "priority": "Normal",
- "version": "4.0.1",
- "reportingEntityName": "NOK6061ZW3",
- "sequence": "0",
- "domain": "notification",
- "lastEpochMicrosec": "1551865758690",
- "eventName": "pnfRegistration_Nokia_5gDu",
- "vesEventListenerVersion": "7.0.1",
- "sourceName": "NOK6061ZW3",
- "nfNamingCode": "gNB"
- },
- "notificationFields": { <== "nof"
- "": "",
- "notificationFieldsVersion": "2.0",
- "changeType": "FileReady",
- "changeIdentifier": "PM_MEAS_FILES",
- "arrayOfNamedHashMap": [ <== "aonh"
- { <== "aonhElement"
- "name": "A20161224.1030-1045.bin.gz",
- "hashMap": { <== "hm"
- "location": "ftpes://192.169.0.1:22/ftp/rop/A20161224.1030-1045.bin.gz",
- "fileFormatType": "org.3GPP.32.435#measCollec",
- "fileFormatVersion": "V10",
- "compression": "gzip"
- }
- }
- ]
- }
- }
- }
- */
- // @formatter:on
- }
}
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
index 917e4eb63..cb58e3c7a 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
@@ -20,13 +20,11 @@ package org.onap.pnfsimulator.simulator;
import static java.lang.Integer.parseInt;
import static org.onap.pnfsimulator.message.MessageConstants.MESSAGE_INTERVAL;
import static org.onap.pnfsimulator.message.MessageConstants.TEST_DURATION;
-import static org.onap.pnfsimulator.message.MessageConstants.VES_SERVER_URL;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import java.io.IOException;
import java.time.Duration;
-import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
-import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.pnfsimulator.ConfigurationProvider;
import org.onap.pnfsimulator.FileProvider;
@@ -54,35 +52,20 @@ public class SimulatorFactory {
public Simulator create(JSONObject simulatorParams, JSONObject commonEventHeaderParams,
Optional<JSONObject> pnfRegistrationParams, Optional<JSONObject> notificationParams)
throws ProcessingException, IOException, ValidationException {
+ PnfSimConfig configuration = ConfigurationProvider.getConfigInstance();
+ String xnfUrl = "sftp://onap:pano@" + configuration.getIpsftp() + "/";
+ String vesUrl = configuration.getVesip() + "/eventListener/v7";
+
Duration duration = Duration.ofSeconds(parseInt(simulatorParams.getString(TEST_DURATION)));
Duration interval = Duration.ofSeconds(parseInt(simulatorParams.getString(MESSAGE_INTERVAL)));
- String vesUrl = simulatorParams.getString(VES_SERVER_URL);
- JSONObject messageBody =
- messageProvider.createMessage(commonEventHeaderParams, pnfRegistrationParams, notificationParams);
+ List<String> fileList = FileProvider.getFiles();
+ JSONObject messageBody = messageProvider
+ .createMessage(commonEventHeaderParams, pnfRegistrationParams, notificationParams, fileList, xnfUrl);
validator.validate(messageBody.toString(), DEFAULT_OUTPUT_SCHEMA_PATH);
- JSONArray messageBodyArray = new JSONArray();
-
- PnfSimConfig configuration = ConfigurationProvider.getConfigInstance();
- String xnfUrl = configuration.getIpsftp() + "/";
-
- ArrayList<String> fileList = FileProvider.getFiles();
-
- // for (String f : fileList) {
- // System.out.println("f processed from fileList: " + f.toString());
- // JSONObject vesEvent = messageProvider.createOneVes(commonEventHeaderParams,
- // pnfRegistrationParams,
- // notificationParams, url, f);
- // messageBodyArray.put(vesEvent);
- // }
-
- String fileName = fileList.get(1);
- System.out.println("f processed from fileList: " + fileName.toString());
- JSONObject vesEvent = messageProvider.createOneVesEvent(xnfUrl, fileName);
-
- return Simulator.builder().withVesUrl(configuration.getVesip()).withDuration(duration).withInterval(interval)
- .withMessageBody(vesEvent).build();
+ return Simulator.builder().withVesUrl(vesUrl).withDuration(duration).withInterval(interval)
+ .withMessageBody(messageBody).build();
}
}
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template.xml.gz b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template_new.xml.gz
index 0e6624a09..0e6624a09 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template.xml.gz
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template_new.xml.gz
Binary files differ