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