Remove outdated doc for A1 Adaptor
[integration.git] / test / mocks / masspnfsim / pnf-sim-lightweight / src / test / java / org / onap / pnfsimulator / simulator / TestMessages.java
1 /*
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.pnfsimulator.simulator;
22
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;
28
29 public final class TestMessages {
30
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")));
37
38     static final JSONObject INVALID_SIMULATOR_PARAMS = new JSONObject(
39         "{\n" +
40             "    \"vesServerUrl\": \"http://10.42.111.42:8080/eventListener/v5\",\n" +
41             "    \"messageInterval\": \"1\"\n" +
42             "}");
43
44
45     static final Optional<JSONObject> INVALID_PNF_REGISTRATION_PARAMS_1 = Optional.of(new JSONObject(
46         "{\n" +
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" +
59             "}"));
60
61     static final Optional<JSONObject> INVALID_PNF_REGISTRATION_PARAMS_2 = Optional.of(new JSONObject(
62         "{\n" +
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" +
76             "}"));
77
78     static final Optional<JSONObject> INVALID_PNF_REGISTRATION_PARAMS_3 = Optional.of(new JSONObject(
79         "{\n" +
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" +
92             "}"));
93
94     static final Optional<JSONObject> INVALID_NOTIFICATION_PARAMS = Optional.of(new JSONObject(
95         "{\n" +
96             "    \"mother\": \"val1\",\n" +
97             "    \"father\": \"val3\",\n" +
98             "}"));
99
100
101     private TestMessages() {
102     }
103
104     private static String getContent(String fileName) {
105         try {
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);
110             });
111             return stringBuilder.toString();
112         } catch (IOException e) {
113             throw new RuntimeException(String.format("Cannot read JSON file %s", fileName));
114         }
115     }
116 }