diff options
author | Pawel Kadlubanski <pawel.kadlubanski@nokia.com> | 2018-05-28 11:34:50 +0200 |
---|---|---|
committer | Pawel Kadlubanski <pawel.kadlubanski@nokia.com> | 2018-05-28 11:35:31 +0200 |
commit | ae2335539459822eda2abf66b6062aae0795ad24 (patch) | |
tree | 962305468f9fca658bae78d35c314e2724e2a942 | |
parent | b2341a5b10c1dd57f19fdeb8fd19ed820dcaa2eb (diff) |
Correction in created message.
Issue-ID: INT-458
Change-Id: Ic66e27bc89eea194769d54dd367a9a09d484d87f
Signed-off-by: Pawel Kadlubanski <pawel.kadlubanski@nokia.com>
3 files changed, 36 insertions, 23 deletions
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 b49c1ea1d..5805a88c7 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 @@ -17,11 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.onap.pnfsimulator.message; public final class MessageConstants { + public static final String EVENT = "event"; public static final String DOMAIN = "domain"; public static final String EVENT_ID = "eventId"; public static final String EVENT_TYPE = "eventType"; 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 163d4e62d..94f5fc167 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 @@ -35,13 +35,12 @@ import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY; import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE; import static org.onap.pnfsimulator.message.MessageConstants.START_EPOCH_MICROSEC; import static org.onap.pnfsimulator.message.MessageConstants.VERSION; +import static org.onap.pnfsimulator.message.MessageConstants.EVENT; import java.util.Map; import java.util.UUID; import com.google.common.base.Preconditions; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.json.JSONObject; public class MessageProvider { @@ -72,8 +71,11 @@ public class MessageProvider { } }); - root.put(COMMON_EVENT_HEADER, commonEventHeader); - root.put(OTHER_FIELDS, otherFields); + JSONObject event = new JSONObject(); + event.put(COMMON_EVENT_HEADER, commonEventHeader); + event.put(OTHER_FIELDS, otherFields); + + root.put(EVENT, event); return root; } @@ -91,6 +93,7 @@ public class MessageProvider { commonEventHeader.put(START_EPOCH_MICROSEC, timestamp); commonEventHeader.put(INTERNAL_HEADER_FIELDS, new JSONObject()); commonEventHeader.put(VERSION, 3); + commonEventHeader.put("functionalRole", "test_rola"); return commonEventHeader; } 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 38540577e..bfd222dc2 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 @@ -1,22 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * org.onap.integration + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.pnfsimulator.message; import static org.junit.jupiter.api.Assertions.assertEquals; 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.DOMAIN; -import static org.onap.pnfsimulator.message.MessageConstants.EVENT_ID; -import static org.onap.pnfsimulator.message.MessageConstants.EVENT_TYPE; -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.OTHER_FIELDS; -import static org.onap.pnfsimulator.message.MessageConstants.OTHER_FIELDS_VERSION; -import static org.onap.pnfsimulator.message.MessageConstants.PNF_LAST_SERVICE_DATE; -import static org.onap.pnfsimulator.message.MessageConstants.PNF_MANUFACTURE_DATE; -import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY; -import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE; -import static org.onap.pnfsimulator.message.MessageConstants.START_EPOCH_MICROSEC; -import static org.onap.pnfsimulator.message.MessageConstants.VERSION; +import static org.onap.pnfsimulator.message.MessageConstants.*; import java.util.UUID; import org.json.JSONObject; @@ -45,9 +52,10 @@ public class MessageProviderTest { @Test public void createMessage_should_create_constant_message_when_no_params_specified() { JSONObject message = messageProvider.createMessage(new JSONObject()); + JSONObject event = message.getJSONObject(EVENT); - JSONObject commonEventHeader = message.getJSONObject(COMMON_EVENT_HEADER); - JSONObject otherFields = message.getJSONObject(OTHER_FIELDS); + JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER); + JSONObject otherFields = event.getJSONObject(OTHER_FIELDS); JSONObject expectedCommonEventHeader = generateConstantCommonEventHeader(); JSONObject expectedOtherFields = generateConstantOtherFields(); @@ -69,8 +77,9 @@ public class MessageProviderTest { JSONObject params = new JSONObject(testParamsJson); JSONObject message = messageProvider.createMessage(params); - JSONObject commonEventHeader = message.getJSONObject(COMMON_EVENT_HEADER); - JSONObject otherFields = message.getJSONObject(OTHER_FIELDS); + JSONObject event = message.getJSONObject(EVENT); + JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER); + JSONObject otherFields = event.getJSONObject(OTHER_FIELDS); assertEquals("pnfVal3", otherFields.getString("pnfKey3")); assertEquals("val1", commonEventHeader.getString("key1")); |