1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Wipro Limited.
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=========================================================
20 *******************************************************************************/
22 package org.onap.dcaegen2.services.sonhms.model;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotEquals;
27 import com.fasterxml.jackson.core.JsonParseException;
28 import com.fasterxml.jackson.databind.JsonMappingException;
29 import com.fasterxml.jackson.databind.ObjectMapper;
31 import java.io.IOException;
32 import java.util.ArrayList;
34 import org.junit.Test;
35 import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
36 import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell;
37 import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse;
38 import org.onap.dcaegen2.services.sonhms.model.Notification;
39 import org.onap.dcaegen2.services.sonhms.model.NotificationCellConfig;
40 import org.onap.dcaegen2.services.sonhms.model.NotificationLte;
41 import org.onap.dcaegen2.services.sonhms.model.NotificationPayload;
42 import org.onap.dcaegen2.services.sonhms.model.NotificationRan;
43 import org.onap.dcaegen2.services.sonhms.model.RadioAccess;
44 import org.onap.dcaegen2.services.sonhms.model.X0005b9Lte;
46 public class NotificationTest {
49 public void notificationTest() {
51 Notification notif = new Notification();
52 LteNeighborListInUseLteCell lteNeighborListInUseLteCell = new LteNeighborListInUseLteCell("pnf1", "true",
53 "Cell10", "true", "123456", "5", 22, "false");
55 ArrayList<LteNeighborListInUseLteCell> list = new ArrayList<>();
56 list.add(lteNeighborListInUseLteCell);
58 NeighborListInUse neighborListInUse = new NeighborListInUse(list, "1");
60 NotificationRan notificationRan = new NotificationRan(neighborListInUse, "Cell25");
61 NotificationLte notificationLte = new NotificationLte(notificationRan);
62 NotificationCellConfig notificationCell = new NotificationCellConfig(notificationLte);
63 X0005b9Lte lte = new X0005b9Lte(126, "pnf2");
64 FapServiceList fap = new FapServiceList("Cell1", lte, notificationCell);
66 ArrayList<FapServiceList> al = new ArrayList<>();
69 RadioAccess radioAccess = new RadioAccess("1", al);
70 NotificationPayload payload = new NotificationPayload(radioAccess);
72 notif.setRequestId("9d2d790e-a5f0-11e8-98d0-529269fb1459");
74 notif.setAction("NeighborListModified");
75 notif.setFrom("SDNR");
76 notif.setVersion("1.0.2");
77 notif.setPayload(payload);
78 assertNotEquals("159", notif.getRequestId());
80 String test = "{\n" + " \"requestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" + " \"AAI\": {},\n"
81 + " \"from\": \"SDNR\",\n" + " \"version\": \"1.0.2\",\n"
82 + " \"Action\": \"NeighborListModified\",\n" + " \"Payload\": {\n" + "\n" + " \"RadioAccess\":{ \n"
83 + " \"FAPServiceNumberOfEntries\":\"2\",\n" + " \"FAPServiceList\":[ \n" + " { \n"
84 + " \"alias\":\"Cell1\",\n" + " \"X0005b9Lte\":{ \n"
85 + " \"phyCellIdInUse\":\"35\",\n" + " \"pnfName\":\"DU-1\"\n"
86 + " },\n" + " \"CellConfig\":{ \n" + " \"LTE\":{ \n"
87 + " \"RAN\":{ \n" + " \"CellIdentity\":\"Cell1\",\n"
88 + " \"NeighborListInUse\":{ \n"
89 + " \"LTECellNumberOfEntries\":\"2\",\n"
90 + " \"LTENeighborListInUseLTECell\":[ \n" + " { \n"
91 + " \"pnfName\":\"DU-2\",\n"
92 + " \"enable\":\"true\",\n"
93 + " \"alias\":\"Cell10\",\n"
94 + " \"mustInclude\":\"true\",\n"
95 + " \"plmnid\":\"123456\",\n"
97 + " \"phyCellId\":\"22\",\n"
98 + " \"blacklisted\":\"false\"\n" + " },\n"
99 + " { \n" + " \"pnfName\":\"DU-3\",\n"
100 + " \"enable\":\"true\",\n"
101 + " \"alias\":\"Cell15\",\n"
102 + " \"mustInclude\":\"true\",\n"
103 + " \"plmnid\":\"123456\",\n"
104 + " \"cid\":\"5\",\n"
105 + " \"phyCellId\":\"24\",\n"
106 + " \"blacklisted\":\"false\"\n" + " }\n"
107 + " ]\n" + " }\n" + " }\n"
108 + " }\n" + " }\n" + " }\n" + " ]\n" + " }\n" + "}\n" + "}";
110 ObjectMapper mapper = new ObjectMapper();
111 Notification notif1 = new Notification();
113 notif1 = mapper.readValue(test, Notification.class);
114 } catch (JsonParseException e) {
116 } catch (JsonMappingException e) {
118 } catch (IOException e) {
122 assertNotEquals(notif, notif1);
123 assertEquals(notif.getAction(), notif1.getAction());
124 assertEquals(notif.getAai().toString(), notif1.getAai().toString());