aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/pnfsimulator/src
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2018-08-20 15:58:27 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-20 15:58:27 +0000
commit0dd554bbe4cde92dff217fd4220007cd4b32ff04 (patch)
tree90ccfb477de34f14c27db6790d92c99186ae19ca /test/mocks/pnfsimulator/src
parentb0fdf2ab78735a23c6779f84658bbde5840f9601 (diff)
parentb22e45d0fdaae3d35e0e0be3b452ebd2e53ed782 (diff)
Merge "update according to new schema"
Diffstat (limited to 'test/mocks/pnfsimulator/src')
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java13
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java16
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java9
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java17
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java17
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/TestMessages.java32
6 files changed, 55 insertions, 49 deletions
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
index 1547f9e24..fd2b95af1 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
@@ -38,15 +38,16 @@ final class JSONObjectFactory {
commonEventHeader.put(START_EPOCH_MICROSEC, timestamp);
commonEventHeader.put(INTERNAL_HEADER_FIELDS, new JSONObject());
commonEventHeader.put(VERSION, VERSION_NUMBER);
+ commonEventHeader.put(VES_EVENT_LISTENER_VERSION, VES_EVENT_LISTENER_VERSION_NUMBER);
return commonEventHeader;
}
- static JSONObject generateConstantOtherFields() {
- JSONObject otherFields = new JSONObject();
- otherFields.put(OTHER_FIELDS_VERSION, OTHER_FIELDS_VERSION_VALUE);
- otherFields.put(PNF_LAST_SERVICE_DATE, System.currentTimeMillis());
- otherFields.put(PNF_MANUFACTURE_DATE, System.currentTimeMillis());
- return otherFields;
+ static JSONObject generatePnfRegistrationFields() {
+ JSONObject pnfRegistrationFields = new JSONObject();
+ pnfRegistrationFields.put(PNF_REGISTRATION_FIELDS_VERSION, PNF_REGISTRATION_FIELDS_VERSION_VALUE);
+ pnfRegistrationFields.put(PNF_LAST_SERVICE_DATE, String.valueOf(System.currentTimeMillis()));
+ pnfRegistrationFields.put(PNF_MANUFACTURE_DATE, String.valueOf(System.currentTimeMillis()));
+ return pnfRegistrationFields;
}
static String generateEventId() {
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
index 18a753fb6..7861d5f9c 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
@@ -34,9 +34,10 @@ public final class MessageConstants {
static final String START_EPOCH_MICROSEC = "startEpochMicrosec";
static final String INTERNAL_HEADER_FIELDS = "internalHeaderFields";
static final String VERSION = "version";
- static final String OTHER_FIELDS_VERSION = "otherFieldsVersion";
- static final String PNF_LAST_SERVICE_DATE = "pnfLastServiceDate";
- static final String PNF_MANUFACTURE_DATE = "pnfManufactureDate";
+ static final String PNF_REGISTRATION_FIELDS_VERSION = "pnfRegistrationFieldsVersion";
+ static final String PNF_LAST_SERVICE_DATE = "lastServiceDate";
+ static final String PNF_MANUFACTURE_DATE = "manufactureDate";
+ static final String VES_EVENT_LISTENER_VERSION = "vesEventListenerVersion";
// mandatory used in json file, but not in java logic
//public static final String PNF_OAM_IPV4_ADDRESS = "pnfOamIpv4Address";
@@ -46,18 +47,19 @@ public final class MessageConstants {
public static final String VES_SERVER_URL = "vesServerUrl";
public static final String TEST_DURATION = "testDuration";
public static final String MESSAGE_INTERVAL = "messageInterval";
- static final String PNF_PREFIX = "pnf";
+ static final String PNF_PREFIX = "pnf_";
static final String COMMON_EVENT_HEADER = "commonEventHeader";
- static final String OTHER_FIELDS = "otherFields";
+ static final String PNF_REGISTRATION_FIELDS = "pnfRegistrationFields";
//===============================================================
//constant values
static final String PNF_REGISTRATION ="pnfRegistration";
static final String PRIORITY_NORMAL = "Normal";
- static final float VERSION_NUMBER = 3.0f;
+ static final String VERSION_NUMBER = "4.0.1";
+ static final String VES_EVENT_LISTENER_VERSION_NUMBER = "7.0.1";
+ static final String PNF_REGISTRATION_FIELDS_VERSION_VALUE = "2.0";
static final int SEQUENCE_NUMBER = 0;
- static final int OTHER_FIELDS_VERSION_VALUE = 1;
private MessageConstants() {
}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
index e3b2b9cf0..7c3bf9ef8 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
@@ -22,8 +22,9 @@ package org.onap.pnfsimulator.message;
import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
-import static org.onap.pnfsimulator.message.MessageConstants.OTHER_FIELDS;
import static org.onap.pnfsimulator.message.MessageConstants.PNF_PREFIX;
+import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS;
+
import java.util.Map;
import org.json.JSONObject;
@@ -38,12 +39,12 @@ public class MessageProvider {
Map<String, Object> paramsMap = params.toMap();
JSONObject root = new JSONObject();
JSONObject commonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- JSONObject otherFields = JSONObjectFactory.generateConstantOtherFields();
+ JSONObject pnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
paramsMap.forEach((key, value) -> {
if (key.startsWith(PNF_PREFIX)) {
- otherFields.put(key, value);
+ pnfRegistrationFields.put(key.substring(PNF_PREFIX.length()), value);
} else {
commonEventHeader.put(key, value);
}
@@ -51,7 +52,7 @@ public class MessageProvider {
JSONObject event = new JSONObject();
event.put(COMMON_EVENT_HEADER, commonEventHeader);
- event.put(OTHER_FIELDS, otherFields);
+ event.put(PNF_REGISTRATION_FIELDS, pnfRegistrationFields);
root.put(EVENT, event);
return root;
}
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java
index a0f265a10..bc3d17f79 100644
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java
+++ b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java
@@ -32,7 +32,7 @@ public class JSONObjectFactoryTest {
@Test
public void generateConstantCommonEventHeader_shouldCreateProperly(){
JSONObject commonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- assertEquals(9,commonEventHeader.toMap().size());
+ assertEquals(10,commonEventHeader.toMap().size());
assertTrue(commonEventHeader.has(DOMAIN));
assertTrue(commonEventHeader.has(EVENT_ID));
assertTrue(commonEventHeader.has(EVENT_TYPE));
@@ -47,16 +47,17 @@ public class JSONObjectFactoryTest {
assertEquals(commonEventHeader.get(PRIORITY),PRIORITY_NORMAL);
assertEquals(commonEventHeader.get(SEQUENCE),SEQUENCE_NUMBER);
assertEquals(commonEventHeader.get(VERSION),VERSION_NUMBER);
+ assertEquals(commonEventHeader.get(VES_EVENT_LISTENER_VERSION),VES_EVENT_LISTENER_VERSION_NUMBER);
}
@Test
- public void generateConstantOtherFields_shouldCreateProperly(){
- JSONObject otherFields = JSONObjectFactory.generateConstantOtherFields();
- assertEquals(3,otherFields.toMap().size());
- assertTrue(otherFields.has(OTHER_FIELDS_VERSION));
- assertEquals(otherFields.get(OTHER_FIELDS_VERSION),OTHER_FIELDS_VERSION_VALUE);
- assertTrue(otherFields.has(PNF_LAST_SERVICE_DATE));
- assertTrue(otherFields.has(PNF_MANUFACTURE_DATE));
+ public void generateConstantPnfRegistrationFields_shouldCreateProperly(){
+ JSONObject pnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
+ assertEquals(3,pnfRegistrationFields.toMap().size());
+ assertTrue(pnfRegistrationFields.has(PNF_REGISTRATION_FIELDS_VERSION));
+ assertEquals(pnfRegistrationFields.get(PNF_REGISTRATION_FIELDS_VERSION), PNF_REGISTRATION_FIELDS_VERSION_VALUE);
+ assertTrue(pnfRegistrationFields.has(PNF_LAST_SERVICE_DATE));
+ assertTrue(pnfRegistrationFields.has(PNF_MANUFACTURE_DATE));
}
@Test
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
index 4f11088c5..3d1f25397 100644
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
+++ b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
@@ -25,7 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
-import static org.onap.pnfsimulator.message.MessageConstants.OTHER_FIELDS;
+import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS;
+
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -33,7 +34,7 @@ import org.junit.jupiter.api.Test;
public class MessageProviderTest {
private static final String testParamsJson =
- "{\"key1\": \"val1\",\"key2\": \"val2\",\"pnfKey3\": \"pnfVal3\",\"key4\": \"val4\"}";
+ "{\"key1\": \"val1\",\"key2\": \"val2\",\"pnf_key3\": \"pnfVal3\",\"key4\": \"val4\"}";
private static MessageProvider messageProvider;
@@ -55,19 +56,19 @@ public class MessageProviderTest {
JSONObject event = message.getJSONObject(EVENT);
JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER);
- JSONObject otherFields = event.getJSONObject(OTHER_FIELDS);
+ JSONObject pnfRegistrationFields = event.getJSONObject(PNF_REGISTRATION_FIELDS);
JSONObject expectedCommonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- JSONObject expectedOtherFields = JSONObjectFactory.generateConstantOtherFields();
+ JSONObject expectedPnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
expectedCommonEventHeader
.toMap()
.forEach((key, val) -> assertTrue(commonEventHeader.has(key),
() -> String.format("Key %s is not present", key)));
- expectedOtherFields
+ expectedPnfRegistrationFields
.toMap()
- .forEach((key, val) -> assertTrue(otherFields.has(key),
+ .forEach((key, val) -> assertTrue(pnfRegistrationFields.has(key),
() -> String.format("Key %s is not present", key)));
}
@@ -79,9 +80,9 @@ public class MessageProviderTest {
JSONObject event = message.getJSONObject(EVENT);
JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER);
- JSONObject otherFields = event.getJSONObject(OTHER_FIELDS);
+ JSONObject pnfRegistrationFields = event.getJSONObject(PNF_REGISTRATION_FIELDS);
- assertEquals("pnfVal3", otherFields.getString("pnfKey3"));
+ assertEquals("pnfVal3", pnfRegistrationFields.getString("key3"));
assertEquals("val1", commonEventHeader.getString("key1"));
assertEquals("val2", commonEventHeader.getString("key2"));
assertEquals("val4", commonEventHeader.getString("key4"));
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/TestMessages.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/TestMessages.java
index dc8abeb6a..2f166b26f 100644
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/TestMessages.java
+++ b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/TestMessages.java
@@ -33,22 +33,22 @@ final class TestMessages {
static final JSONObject VALID_MESSAGE_PARAMS = new JSONObject(
- "{\n" +
- " \"pnfSerialNumber\": \"val1\",\n" +
- " \"pnfVendorName\": \"val2\",\n" +
- " \"pnfOamIpv4Address\": \"val3\",\n" +
- " \"pnfOamIpv6Address\": \"val4\",\n" +
- " \"pnfFamily\": \"val5\",\n" +
- " \"pnfModelNumber\": \"val6\",\n" +
- " \"pnfSoftwareVersion\": \"val7\",\n" +
- " \"pnfType\": \"val8\",\n" +
- " \"eventName\": \"val9\",\n" +
- " \"nfNamingCode\": \"val10\",\n" +
- " \"nfcNamingCode\": \"val11\",\n" +
- " \"sourceName\": \"val12\",\n" +
- " \"sourceId\": \"val13\",\n" +
- " \"reportingEntityName\": \"val14\"\n" +
- "}");
+ "{\n"
+ + " \"pnf_serialNumber\": \"6061ZW3\",\n"
+ + " \"pnf_vendorName\": \"Nokia\",\n"
+ + " \"pnf_oamV4IpAddress\": \"val3\",\n"
+ + " \"pnf_oamV6IpAddress\": \"val4\",\n"
+ + " \"pnf_unitFamily\": \"BBU\",\n"
+ + " \"pnf_modelNumber\": \"val6\",\n"
+ + " \"pnf_softwareVersion\": \"val7\",\n"
+ + " \"pnf_unitType\": \"val8\",\n"
+ + " \"eventName\": \"pnfRegistration_Nokia_5gDu\",\n"
+ + " \"nfNamingCode\": \"gNB\",\n"
+ + " \"nfcNamingCode\": \"oam\",\n"
+ + " \"sourceName\": \"NOK6061ZW3\",\n"
+ + " \"sourceId\": \"val13\",\n"
+ + " \"reportingEntityName\": \"NOK6061ZW3\"\n"
+ + " }");
static final JSONObject INVALID_SIMULATOR_PARAMS = new JSONObject(
"{\n" +