Update mountpoint-state-provider
[ccsdk/features.git] / sdnr / wt / mountpoint-state-provider / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / mountpointstateprovider / test / TestMountpointStatePublisher.java
index dcb62f2..5fc1c5e 100644 (file)
  * ============LICENSE_END=======================================================
  *
  */
-
 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test;
 
+
+import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
-
 import org.json.JSONObject;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.GeneralConfig;
-import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher;
+import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisherMain;
 import org.onap.dmaap.mr.client.MRBatchingPublisher;
 import org.onap.dmaap.mr.client.response.MRPublisherResponse;
 import org.slf4j.Logger;
 
 public class TestMountpointStatePublisher {
 
-    private static final String CONFIGURATIONTESTFILE = "test.properties";
+    private static final String CONFIGURATIONTESTFILE = "test3.properties";
     public Thread publisher;
+    MountpointStatePublisherMain mountpointStatePublisher;
+    ConfigurationFileRepresentation configFileRepresentation;
+    GeneralConfig cfg;
 
     @Before
     public void testMountpointStatePublisherData() {
         String testJsonData =
                 "{\"NodeId\":\"69322972e178_50001\",\"NetConfNodeState\":\"Connecting\",\"TimeStamp\":\"2019-11-12T12:45:08.604Z\"}";
+        configFileRepresentation =
+                new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
+        cfg = new GeneralConfig(configFileRepresentation);
         JSONObject jsonObj = new JSONObject(testJsonData);
-        MountpointStatePublisher.stateObjects.add(jsonObj);
+        mountpointStatePublisher = new MountpointStatePublisherMain(cfg);
+        mountpointStatePublisher.getStateObjects().add(jsonObj);
     }
 
     @Test
@@ -60,13 +68,13 @@ public class TestMountpointStatePublisher {
                 new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
         GeneralConfig cfg = new GeneralConfig(configFileRepresentation);
 
-        MountpointStatePublisher pub = new MountpointStatePublisherMock(cfg);
+        MountpointStatePublisherMain pub = new MountpointStatePublisherMock(cfg);
         pub.createPublisher(null);
         pub.publishMessage(pub.createPublisher(null), "Test DMaaP Message");
 
     }
 
-    public class MountpointStatePublisherMock extends MountpointStatePublisher {
+    public class MountpointStatePublisherMock extends MountpointStatePublisherMain {
 
         public MountpointStatePublisherMock(Configuration config) {
             super(config);
@@ -79,69 +87,58 @@ public class TestMountpointStatePublisher {
 
                 @Override
                 public int send(String msg) throws IOException {
-                    // TODO Auto-generated method stub
                     System.out.println("Message to send - " + msg);
                     return 0;
                 }
 
                 @Override
                 public int send(String partition, String msg) throws IOException {
-                    // TODO Auto-generated method stub
                     return 0;
                 }
 
                 @Override
                 public int send(message msg) throws IOException {
-                    // TODO Auto-generated method stub
                     return 0;
                 }
 
                 @Override
                 public int send(Collection<message> msgs) throws IOException {
-                    // TODO Auto-generated method stub
                     return 0;
                 }
 
                 @Override
                 public void close() {
-                    // TODO Auto-generated method stub
 
                 }
 
                 @Override
                 public void logTo(Logger log) {
-                    // TODO Auto-generated method stub
 
                 }
 
                 @Override
                 public void setApiCredentials(String apiKey, String apiSecret) {
-                    // TODO Auto-generated method stub
 
                 }
 
                 @Override
                 public void clearApiCredentials() {
-                    // TODO Auto-generated method stub
 
                 }
 
                 @Override
                 public int getPendingMessageCount() {
-                    // TODO Auto-generated method stub
                     return 0;
                 }
 
                 @Override
                 public List<message> close(long timeout, TimeUnit timeoutUnits)
                         throws IOException, InterruptedException {
-                    // TODO Auto-generated method stub
                     return null;
                 }
 
                 @Override
                 public MRPublisherResponse sendBatchWithResponse() {
-                    // TODO Auto-generated method stub
                     return null;
                 }
 
@@ -149,4 +146,14 @@ public class TestMountpointStatePublisher {
         }
     }
 
+    @After
+    public void after() {
+        File file = new File(CONFIGURATIONTESTFILE);
+        if (file.exists()) {
+            System.out.println("File exists, Deleting it");
+            file.delete();
+        }
+
+    }
+
 }