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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=======================================================
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
32 * http://www.apache.org/licenses/LICENSE-2.0
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
38 * ============LICENSE_END==========================================================================
39 ******************************************************************************/
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;
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;
58 public class TestMountpointStatePublisher {
60 private static final String CONFIGURATIONTESTFILE = "test.properties";
61 public Thread publisher;
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);
71 public void testMountpointStatePublisherConfiguration() throws InterruptedException {
72 ConfigurationFileRepresentation configFileRepresentation = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
73 GeneralConfig cfg = new GeneralConfig(configFileRepresentation);
75 MountpointStatePublisher pub = new MountpointStatePublisherMock(cfg);
76 pub.createPublisher(null);
77 pub.publishMessage(pub.createPublisher(null), "Test DMaaP Message");
81 public class MountpointStatePublisherMock extends MountpointStatePublisher {
83 public MountpointStatePublisherMock(Configuration config) {
88 public MRBatchingPublisher createPublisher(Properties publisherProperties) {
90 return new MRBatchingPublisher() {
93 public int send(String msg) throws IOException {
94 // TODO Auto-generated method stub
95 System.out.println("Message to send - "+msg);
100 public int send(String partition, String msg) throws IOException {
101 // TODO Auto-generated method stub
106 public int send(message msg) throws IOException {
107 // TODO Auto-generated method stub
112 public int send(Collection<message> msgs) throws IOException {
113 // TODO Auto-generated method stub
118 public void close() {
119 // TODO Auto-generated method stub
124 public void logTo(Logger log) {
125 // TODO Auto-generated method stub
130 public void setApiCredentials(String apiKey, String apiSecret) {
131 // TODO Auto-generated method stub
136 public void clearApiCredentials() {
137 // TODO Auto-generated method stub
142 public int getPendingMessageCount() {
143 // TODO Auto-generated method stub
148 public List<message> close(long timeout, TimeUnit timeoutUnits)
149 throws IOException, InterruptedException {
150 // TODO Auto-generated method stub
155 public MRPublisherResponse sendBatchWithResponse() {
156 // TODO Auto-generated method stub