72069d72cfd7db5032fdf4446afe0803a0de9701
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
9  * ================================================================================
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *     http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ============LICENSE_END=======================================================
22  *
23  */
24
25 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test;
26
27 import java.io.IOException;
28 import java.util.Collection;
29 import java.util.List;
30 import java.util.Properties;
31 import java.util.concurrent.TimeUnit;
32
33 import org.json.JSONObject;
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
37 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
38 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.GeneralConfig;
39 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher;
40 import org.onap.dmaap.mr.client.MRBatchingPublisher;
41 import org.onap.dmaap.mr.client.response.MRPublisherResponse;
42 import org.slf4j.Logger;
43
44 public class TestMountpointStatePublisher {
45
46         private static final String CONFIGURATIONTESTFILE = "test.properties";
47         public Thread publisher;
48
49         @Before
50         public void testMountpointStatePublisherData() {
51                 String testJsonData = "{\"NodeId\":\"69322972e178_50001\",\"NetConfNodeState\":\"Connecting\",\"TimeStamp\":\"2019-11-12T12:45:08.604Z\"}";
52                 JSONObject jsonObj = new JSONObject(testJsonData);
53                 MountpointStatePublisher.stateObjects.add(jsonObj);
54         }
55
56         @Test
57         public void testMountpointStatePublisherConfiguration() throws InterruptedException {
58                 ConfigurationFileRepresentation configFileRepresentation = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
59                 GeneralConfig cfg = new GeneralConfig(configFileRepresentation);
60
61                 MountpointStatePublisher pub = new MountpointStatePublisherMock(cfg);
62                 pub.createPublisher(null);
63                 pub.publishMessage(pub.createPublisher(null), "Test DMaaP Message");
64
65         }
66
67         public class MountpointStatePublisherMock extends MountpointStatePublisher {
68
69                 public MountpointStatePublisherMock(Configuration config) {
70                         super(config);
71                 }
72
73                 @Override
74                 public MRBatchingPublisher createPublisher(Properties publisherProperties) {
75
76                         return new MRBatchingPublisher() {
77
78                                 @Override
79                                 public int send(String msg) throws IOException {
80                                         // TODO Auto-generated method stub
81                                         System.out.println("Message to send - "+msg);
82                                         return 0;
83                                 }
84
85                                 @Override
86                                 public int send(String partition, String msg) throws IOException {
87                                         // TODO Auto-generated method stub
88                                         return 0;
89                                 }
90
91                                 @Override
92                                 public int send(message msg) throws IOException {
93                                         // TODO Auto-generated method stub
94                                         return 0;
95                                 }
96
97                                 @Override
98                                 public int send(Collection<message> msgs) throws IOException {
99                                         // TODO Auto-generated method stub
100                                         return 0;
101                                 }
102
103                                 @Override
104                                 public void close() {
105                                         // TODO Auto-generated method stub
106
107                                 }
108
109                                 @Override
110                                 public void logTo(Logger log) {
111                                         // TODO Auto-generated method stub
112
113                                 }
114
115                                 @Override
116                                 public void setApiCredentials(String apiKey, String apiSecret) {
117                                         // TODO Auto-generated method stub
118
119                                 }
120
121                                 @Override
122                                 public void clearApiCredentials() {
123                                         // TODO Auto-generated method stub
124
125                                 }
126
127                                 @Override
128                                 public int getPendingMessageCount() {
129                                         // TODO Auto-generated method stub
130                                         return 0;
131                                 }
132
133                                 @Override
134                                 public List<message> close(long timeout, TimeUnit timeoutUnits)
135                                                 throws IOException, InterruptedException {
136                                         // TODO Auto-generated method stub
137                                         return null;
138                                 }
139
140                                 @Override
141                                 public MRPublisherResponse sendBatchWithResponse() {
142                                         // TODO Auto-generated method stub
143                                         return null;
144                                 }
145
146                         };
147                 }
148         }
149
150 }