2 * ============LICENSE_START=======================================================
3 * PNF-REGISTRATION-HANDLER
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.pnfsimulator.simulator;
23 import java.io.IOException;
24 import java.nio.file.Files;
25 import java.nio.file.Paths;
26 import java.util.Optional;
27 import org.json.JSONObject;
29 public final class TestMessages {
31 static final JSONObject VALID_SIMULATOR_PARAMS = new JSONObject(getContent("validSimulatorParams.json"));
32 public static final JSONObject VALID_COMMON_EVENT_HEADER_PARAMS = new JSONObject(getContent("validCommonEventHeaderParams.json"));
33 static final Optional<JSONObject> VALID_PNF_REGISTRATION_PARAMS = Optional
34 .of(new JSONObject(getContent("validPnfRegistrationParams.json")));
35 public static final Optional<JSONObject> VALID_NOTIFICATION_PARAMS = Optional
36 .of(new JSONObject(getContent("validNotificationParams.json")));
38 static final JSONObject INVALID_SIMULATOR_PARAMS = new JSONObject(
40 " \"vesServerUrl\": \"http://10.42.111.42:8080/eventListener/v5\",\n" +
41 " \"messageInterval\": \"1\"\n" +
45 static final Optional<JSONObject> INVALID_PNF_REGISTRATION_PARAMS_1 = Optional.of(new JSONObject(
47 " \"pnfSerialNumber\": \"val1\",\n" +
48 " \"pnfVendorName\": \"val2\",\n" +
49 " \"pnfFamily\": \"val5\",\n" +
50 " \"pnfModelNumber\": \"val6\",\n" +
51 " \"pnfSoftwareVersion\": \"val7\",\n" +
52 " \"pnfType\": \"val8\",\n" +
53 " \"eventName\": \"val9\",\n" +
54 " \"nfNamingCode\": \"val10\",\n" +
55 " \"nfcNamingCode\": \"val11\",\n" +
56 " \"sourceName\": \"val12\",\n" +
57 " \"sourceId\": \"val13\",\n" +
58 " \"reportingEntityName\": \"val14\"\n" +
61 static final Optional<JSONObject> INVALID_PNF_REGISTRATION_PARAMS_2 = Optional.of(new JSONObject(
63 " \"pnfVendorName\": \"val2\",\n" +
64 " \"pnfOamIpv4Address\": \"val3\",\n" +
65 " \"pnfOamIpv6Address\": \"val4\",\n" +
66 " \"pnfFamily\": \"val5\",\n" +
67 " \"pnfModelNumber\": \"val6\",\n" +
68 " \"pnfSoftwareVersion\": \"val7\",\n" +
69 " \"pnfType\": \"val8\",\n" +
70 " \"eventName\": \"val9\",\n" +
71 " \"nfNamingCode\": \"val10\",\n" +
72 " \"nfcNamingCode\": \"val11\",\n" +
73 " \"sourceName\": \"val12\",\n" +
74 " \"sourceId\": \"val13\",\n" +
75 " \"reportingEntityName\": \"val14\"\n" +
78 static final Optional<JSONObject> INVALID_PNF_REGISTRATION_PARAMS_3 = Optional.of(new JSONObject(
80 " \"pnfSerialNumber\": \"val1\",\n" +
81 " \"pnfOamIpv4Address\": \"val3\",\n" +
82 " \"pnfFamily\": \"val5\",\n" +
83 " \"pnfModelNumber\": \"val6\",\n" +
84 " \"pnfSoftwareVersion\": \"val7\",\n" +
85 " \"pnfType\": \"val8\",\n" +
86 " \"eventName\": \"val9\",\n" +
87 " \"nfNamingCode\": \"val10\",\n" +
88 " \"nfcNamingCode\": \"val11\",\n" +
89 " \"sourceName\": \"val12\",\n" +
90 " \"sourceId\": \"val13\",\n" +
91 " \"reportingEntityName\": \"val14\"\n" +
94 static final Optional<JSONObject> INVALID_NOTIFICATION_PARAMS = Optional.of(new JSONObject(
96 " \"mother\": \"val1\",\n" +
97 " \"father\": \"val3\",\n" +
101 private TestMessages() {
104 private static String getContent(String fileName) {
106 String pathAsString = TestMessages.class.getResource(fileName).getPath();
107 StringBuilder stringBuilder = new StringBuilder();
108 Files.readAllLines(Paths.get(pathAsString)).forEach(line -> {
109 stringBuilder.append(line);
111 return stringBuilder.toString();
112 } catch (IOException e) {
113 throw new RuntimeException(String.format("Cannot read JSON file %s", fileName));