dcb62f25302b1635a6fe6591cfb725c955e87ddd
[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 =
52                 "{\"NodeId\":\"69322972e178_50001\",\"NetConfNodeState\":\"Connecting\",\"TimeStamp\":\"2019-11-12T12:45:08.604Z\"}";
53         JSONObject jsonObj = new JSONObject(testJsonData);
54         MountpointStatePublisher.stateObjects.add(jsonObj);
55     }
56
57     @Test
58     public void testMountpointStatePublisherConfiguration() throws InterruptedException {
59         ConfigurationFileRepresentation configFileRepresentation =
60                 new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
61         GeneralConfig cfg = new GeneralConfig(configFileRepresentation);
62
63         MountpointStatePublisher pub = new MountpointStatePublisherMock(cfg);
64         pub.createPublisher(null);
65         pub.publishMessage(pub.createPublisher(null), "Test DMaaP Message");
66
67     }
68
69     public class MountpointStatePublisherMock extends MountpointStatePublisher {
70
71         public MountpointStatePublisherMock(Configuration config) {
72             super(config);
73         }
74
75         @Override
76         public MRBatchingPublisher createPublisher(Properties publisherProperties) {
77
78             return new MRBatchingPublisher() {
79
80                 @Override
81                 public int send(String msg) throws IOException {
82                     // TODO Auto-generated method stub
83                     System.out.println("Message to send - " + msg);
84                     return 0;
85                 }
86
87                 @Override
88                 public int send(String partition, String msg) throws IOException {
89                     // TODO Auto-generated method stub
90                     return 0;
91                 }
92
93                 @Override
94                 public int send(message msg) throws IOException {
95                     // TODO Auto-generated method stub
96                     return 0;
97                 }
98
99                 @Override
100                 public int send(Collection<message> msgs) throws IOException {
101                     // TODO Auto-generated method stub
102                     return 0;
103                 }
104
105                 @Override
106                 public void close() {
107                     // TODO Auto-generated method stub
108
109                 }
110
111                 @Override
112                 public void logTo(Logger log) {
113                     // TODO Auto-generated method stub
114
115                 }
116
117                 @Override
118                 public void setApiCredentials(String apiKey, String apiSecret) {
119                     // TODO Auto-generated method stub
120
121                 }
122
123                 @Override
124                 public void clearApiCredentials() {
125                     // TODO Auto-generated method stub
126
127                 }
128
129                 @Override
130                 public int getPendingMessageCount() {
131                     // TODO Auto-generated method stub
132                     return 0;
133                 }
134
135                 @Override
136                 public List<message> close(long timeout, TimeUnit timeoutUnits)
137                         throws IOException, InterruptedException {
138                     // TODO Auto-generated method stub
139                     return null;
140                 }
141
142                 @Override
143                 public MRPublisherResponse sendBatchWithResponse() {
144                     // TODO Auto-generated method stub
145                     return null;
146                 }
147
148             };
149         }
150     }
151
152 }