2 * Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
3 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
4 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
5 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
6 * Vestibulum commodo. Ut rhoncus gravida arcu.
9 package org.onap.ccsdk.sli.northbound.dmaapclient;
11 import static org.junit.Assert.assertTrue;
14 import java.io.IOException;
15 import java.io.InputStream;
16 import java.lang.reflect.Field;
18 import java.util.Properties;
20 import org.apache.commons.io.FileUtils;
22 import org.junit.Before;
23 import org.junit.Test;
25 import com.fasterxml.jackson.databind.JsonNode;
26 import com.fasterxml.jackson.databind.ObjectMapper;
29 public class TestCMNotifyDmaapConsumer {
30 private static final String cMNotifyInput = "{\n" +
33 " \"CommonHeader\": {\n" +
34 " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
35 " \"APIver\": \"1.0\",\n" +
36 " \"RequestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" +
37 " \"SubRequestID\": \"1\",\n" +
38 " \"RequestTrack\": {},\n" +
39 " \"Flags\": {}\n },\n" +
40 " \"Action\": \"nbrlist-change-notification\",\n" +
42 " \"fap-service-number-of-entries-changed\": 1,\n" +
43 " \"fap-service\": [{ \"alias\": \n" +
44 " \"Chn0001\", \"cid\": \"Chn0001\", \"lte-cell-number-of-entries\": 1,\n" +
45 " \"lte-ran-neighbor-list-in-use-lte-cell-changed\": \n" +
46 " [{ \"plmnid\": \"ran-1\", \"cid\": \"Chn0002\", \"phy-cell-id\": 4,\n" +
47 " \"pnf-name\": \"ncserver1\",\n" +
48 " \"blacklisted\": false }] }] }\n" +
51 " \"version\": \"1.0\",\n" +
52 " \"rpc-name\": \"nbrlist-change-notification\",\n" +
53 " \"correlation-id\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459-1\",\n" +
54 " \"type\": \"request\"\n" +
59 public void test() throws Exception {
60 Properties props = new Properties();
62 CMNotifyDmaapConsumer consumer = new CMNotifyDmaapConsumer();
63 InputStream propStr = TestCMNotifyDmaapConsumer.class.getResourceAsStream("/dmaap-consumer-cMNotify-1.properties");
65 consumer.init(props, "src/test/resources/dmaap-consumer-1.properties");
66 consumer.processMsg(cMNotifyInput);
69 @Test(expected = InvalidMessageException.class)
70 public void testProcessMsgNullMessage() throws Exception {
71 CMNotifyDmaapConsumer consumer = new CMNotifyDmaapConsumer();
72 consumer.processMsg(null);
76 public void testProcessMsgMissingBody() throws Exception {
78 " \"bodyTest\": {\n" +
80 " \"CommonHeader\": {\n" +
81 " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
82 " \"APIver\": \"1.0\",\n" +
83 " \"RequestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" +
84 " \"SubRequestID\": \"1\",\n" +
85 " \"RequestTrack\": {},\n" +
86 " \"Flags\": {}\n },\n" +
87 " \"Action\": \"nbrlist-change-notification\",\n" +
89 " \"fap-service-number-of-entries-changed\": 1,\n" +
90 " \"fap-service\": [{ \"alias\": \n" +
91 " \"Chn0001\", \"cid\": \"Chn0001\", \"lte-cell-number-of-entries\": 1,\n" +
92 " \"lte-ran-neighbor-list-in-use-lte-cell-changed\": \n" +
93 " [{ \"plmnid\": \"ran-1\", \"cid\": \"Chn0002\", \"phy-cell-id\": 4,\n" +
94 " \"pnf-name\": \"ncserver1\",\n" +
95 " \"blacklisted\": false }] }] }\n" +
98 " \"version\": \"1.0\",\n" +
99 " \"rpc-name\": \"nbrlist-change-notification\",\n" +
100 " \"correlation-id\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459-1\",\n" +
101 " \"type\": \"request\"\n" +
103 CMNotifyDmaapConsumer consumer = new CMNotifyDmaapConsumer();
104 consumer.processMsg(msg);
108 public void testProcessMsgInvalidRPC() throws Exception {
112 " \"CommonHeader\": {\n" +
113 " \"TimeStamp\": \"2018-11-30T09:13:37.368Z\",\n" +
114 " \"APIver\": \"1.0\",\n" +
115 " \"RequestID\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459\",\n" +
116 " \"SubRequestID\": \"1\",\n" +
117 " \"RequestTrack\": {},\n" +
118 " \"Flags\": {}\n },\n" +
119 " \"Action\": \"nbrlist-change-notification\",\n" +
120 " \"Payload\": {\n" +
121 " \"fap-service-number-of-entries-changed\": 1,\n" +
122 " \"fap-service\": [{ \"alias\": \n" +
123 " \"Chn0001\", \"cid\": \"Chn0001\", \"lte-cell-number-of-entries\": 1,\n" +
124 " \"lte-ran-neighbor-list-in-use-lte-cell-changed\": \n" +
125 " [{ \"plmnid\": \"ran-1\", \"cid\": \"Chn0002\", \"phy-cell-id\": 4,\n" +
126 " \"pnf-name\": \"ncserver1\",\n" +
127 " \"blacklisted\": false }] }] }\n" +
130 " \"version\": \"1.0\",\n" +
131 " \"rpc-nameTest\": \"nbrlist-change-notification\",\n" +
132 " \"correlation-id\": \"9d2d790e-a5f0-11e8-98d0-529269fb1459-1\",\n" +
133 " \"type\": \"request\"\n" +
136 CMNotifyDmaapConsumer consumer = new CMNotifyDmaapConsumer();
137 consumer.processMsg(msg);