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