-/*-
- * ============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.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN;
+import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
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.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.json.JSONObject;
public class MessageProvider {
- private static MessageProvider instance;
+ public JSONObject createMessage(JSONObject params) {
- public static MessageProvider getInstance() {
- if (instance == null) {
- instance = new MessageProvider();
+ if (params == null) {
+ throw new IllegalArgumentException("Params object cannot be null");
}
- return instance;
- }
-
- public JSONObject createMessage(JSONObject params) {
- Preconditions.checkArgument(params != null, "Params object cannot be null");
- Map<String, Object> paramsMap = params.toMap();
+ Map<String, Object> paramsMap = params.toMap();
JSONObject root = new JSONObject();
JSONObject commonEventHeader = generateConstantCommonEventHeader();
JSONObject otherFields = generateConstantOtherFields();
JSONObject event = new JSONObject();
event.put(COMMON_EVENT_HEADER, commonEventHeader);
event.put(OTHER_FIELDS, otherFields);
-
root.put(EVENT, event);
return root;
}
commonEventHeader.put(START_EPOCH_MICROSEC, timestamp);
commonEventHeader.put(INTERNAL_HEADER_FIELDS, new JSONObject());
commonEventHeader.put(VERSION, 3);
- commonEventHeader.put("functionalRole", "test_rola");
return commonEventHeader;
}