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;
36 public class NotificationTest {
39 public void notificationTest() {
41 Notification notif = new Notification();
42 LteNeighborListInUseLteCell lteNeighborListInUseLteCell = new LteNeighborListInUseLteCell("pnf1", "true",
43 "Cell10", "true", "123456", "5", 22, "false");
45 ArrayList<LteNeighborListInUseLteCell> list = new ArrayList<>();
46 list.add(lteNeighborListInUseLteCell);
48 NeighborListInUse neighborListInUse = new NeighborListInUse(list, null, "1");
50 NotificationRan notificationRan = new NotificationRan(neighborListInUse, "Cell25");
51 NotificationLte notificationLte = new NotificationLte(notificationRan);
52 NotificationCellConfig notificationCell = new NotificationCellConfig(notificationLte);
53 X0005b9Lte lte = new X0005b9Lte(126, "pnf2");
54 FapServiceList fap = new FapServiceList("Cell1", lte, notificationCell);
56 ArrayList<FapServiceList> al = new ArrayList<>();
59 RadioAccess radioAccess = new RadioAccess("1", al);
60 NotificationPayload payload = new NotificationPayload(radioAccess);
62 notif.setRequestId("9d2d790e-a5f0-11e8-98d0-529269fb1459");
64 notif.setAction("NeighborListModified");
65 notif.setFrom("SDNR");
66 notif.setVersion("1.0.2");
67 notif.setPayload(payload);
68 assertNotEquals("159", notif.getRequestId());
70 String test = "{\n" + " \"requestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" + " \"AAI\": {},\n"
71 + " \"from\": \"SDNR\",\n" + " \"version\": \"1.0.2\",\n"
72 + " \"Action\": \"NeighborListModified\",\n" + " \"Payload\": {\n" + "\n" + " \"RadioAccess\":{ \n"
73 + " \"FAPServiceNumberOfEntries\":\"2\",\n" + " \"FAPServiceList\":[ \n" + " { \n"
74 + " \"alias\":\"Cell1\",\n" + " \"X0005b9Lte\":{ \n"
75 + " \"phyCellIdInUse\":\"35\",\n" + " \"pnfName\":\"DU-1\"\n"
76 + " },\n" + " \"CellConfig\":{ \n" + " \"LTE\":{ \n"
77 + " \"RAN\":{ \n" + " \"CellIdentity\":\"Cell1\",\n"
78 + " \"NeighborListInUse\":{ \n"
79 + " \"LTECellNumberOfEntries\":\"2\",\n"
80 + " \"LTENeighborListInUseLTECell\":[ \n" + " { \n"
81 + " \"pnfName\":\"DU-2\",\n"
82 + " \"enable\":\"true\",\n"
83 + " \"alias\":\"Cell10\",\n"
84 + " \"mustInclude\":\"true\",\n"
85 + " \"plmnid\":\"123456\",\n"
87 + " \"phyCellId\":\"22\",\n"
88 + " \"blacklisted\":\"false\"\n" + " },\n"
89 + " { \n" + " \"pnfName\":\"DU-3\",\n"
90 + " \"enable\":\"true\",\n"
91 + " \"alias\":\"Cell15\",\n"
92 + " \"mustInclude\":\"true\",\n"
93 + " \"plmnid\":\"123456\",\n"
95 + " \"phyCellId\":\"24\",\n"
96 + " \"blacklisted\":\"false\"\n" + " }\n"
97 + " ]\n" + " }\n" + " }\n"
98 + " }\n" + " }\n" + " }\n" + " ]\n" + " }\n" + "}\n" + "}";
100 ObjectMapper mapper = new ObjectMapper();
101 Notification notif1 = new Notification();
103 notif1 = mapper.readValue(test, Notification.class);
104 } catch (JsonParseException e) {
106 } catch (JsonMappingException e) {
108 } catch (IOException e) {
112 Notification notif2 = new Notification("9d2d790e-a5f0-11e8-98d0-529269fb1459", "{}", "SDNR", "1.0.2", "NeighborListModified", payload) ;
113 assertEquals(notif2.getPayload(), notif.getPayload());
114 assertNotEquals(notif, notif1);
115 assertEquals(notif.getAction(), notif1.getAction());
116 assertEquals(notif.getAai().toString(), notif1.getAai().toString());