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
11 * http://www.apache.org/licenses/LICENSE-2.0
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
17 * ============LICENSE_END==========================================================================
18 ******************************************************************************/
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;
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;
37 public class TestMountpointStatePublisher {
39 private static final String CONFIGURATIONTESTFILE = "test.properties";
40 public Thread publisher;
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);
50 public void testMountpointStatePublisherConfiguration() throws InterruptedException {
51 ConfigurationFileRepresentation configFileRepresentation = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
52 GeneralConfig cfg = new GeneralConfig(configFileRepresentation);
54 MountpointStatePublisher pub = new MountpointStatePublisherMock(cfg);
55 pub.createPublisher(null);
56 pub.publishMessage(pub.createPublisher(null), "Test DMaaP Message");
60 public class MountpointStatePublisherMock extends MountpointStatePublisher {
62 public MountpointStatePublisherMock(Configuration config) {
67 public MRBatchingPublisher createPublisher(Properties publisherProperties) {
69 return new MRBatchingPublisher() {
72 public int send(String msg) throws IOException {
73 // TODO Auto-generated method stub
74 System.out.println("Message to send - "+msg);
79 public int send(String partition, String msg) throws IOException {
80 // TODO Auto-generated method stub
85 public int send(message msg) throws IOException {
86 // TODO Auto-generated method stub
91 public int send(Collection<message> msgs) throws IOException {
92 // TODO Auto-generated method stub
98 // TODO Auto-generated method stub
103 public void logTo(Logger log) {
104 // TODO Auto-generated method stub
109 public void setApiCredentials(String apiKey, String apiSecret) {
110 // TODO Auto-generated method stub
115 public void clearApiCredentials() {
116 // TODO Auto-generated method stub
121 public int getPendingMessageCount() {
122 // TODO Auto-generated method stub
127 public List<message> close(long timeout, TimeUnit timeoutUnits)
128 throws IOException, InterruptedException {
129 // TODO Auto-generated method stub
134 public MRPublisherResponse sendBatchWithResponse() {
135 // TODO Auto-generated method stub