diff options
author | 2020-09-08 13:02:32 +0530 | |
---|---|---|
committer | 2020-09-15 22:11:14 +0530 | |
commit | 8882e23eedce9e9236e1d979b2056b62dd974d91 (patch) | |
tree | ff7bce29e94a814c340df73607b9d0da59a1329a /components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap | |
parent | 2c6ad52e8d0e29b8037776fff035f031558cc4b0 (diff) |
Add support to consume, process pm message from DB
- Add support for analysing pm data
- Add support to trigger closed loop
- Add support for configDb Interface Implementation
- Add support for Intelligent slicing
Issue-ID: DCAEGEN2-2255
Signed-off-by: dhebeha <dhebeha.mj71@wipro.com>
Change-Id: I185dbb6da45ae6ee74f0a090e2d604914163588b
Diffstat (limited to 'components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap')
3 files changed, 35 insertions, 36 deletions
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java index f2420b02..b74056db 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java @@ -43,7 +43,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.Configuration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -54,10 +54,9 @@ public class DmaapClientTest { @Mock private CambriaTopicManager topicManager; - @InjectMocks DmaapClient client; - + @Before public void setup() { MockitoAnnotations.initMocks(this); @@ -77,53 +76,53 @@ public class DmaapClientTest { configuration.setPollingInterval(30); configuration.setPollingTimeout(100); configuration.setConfigDbService("sdnrService"); - + try { when(topicManager.getTopics()).thenReturn(topics); - + client=Mockito.mock(DmaapClient.class); client.initClient(); Mockito.verify(client).initClient(); - // Mockito.verifycreateAndConfigureTopics(); + // Mockito.verifycreateAndConfigureTopics(); } catch (IOException e) { e.printStackTrace(); } } - + @Test public void startClientTest() { try { Configuration configuration = Configuration.getInstance(); String configAllJson = readFromFile("src/test/resources/config_all.json"); - JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class); + JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class); - JsonObject config = configAll.getAsJsonObject("config"); - - configuration.updateConfigurationFromJsonObject(config); + JsonObject config = configAll.getAsJsonObject("config"); + System.out.println(configuration); + configuration.updateConfigurationFromJsonObject(config); DmaapClient client= new DmaapClient(); client.initClient(); //Mockito.verify(client).startClient(); - // Mockito.verifycreateAndConfigureTopics(); + // Mockito.verifycreateAndConfigureTopics(); } catch ( Exception e) { e.printStackTrace(); } } - private static String readFromFile(String file) { - String content = ""; - try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { - content = bufferedReader.readLine(); - String temp; - while ((temp = bufferedReader.readLine()) != null) { - content = content.concat(temp); - } - content = content.trim(); - } catch (Exception e) { - content = null; - } - return content; - } + private static String readFromFile(String file) { + String content = ""; + try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { + content = bufferedReader.readLine(); + String temp; + while ((temp = bufferedReader.readLine()) != null) { + content = content.concat(temp); + } + content = content.trim(); + } catch (Exception e) { + content = null; + } + return content; + } } diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java index f4b64397..9aab22c2 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java @@ -21,6 +21,11 @@ package org.onap.slice.analysis.ms.dmaap; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -28,11 +33,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import com.att.nsa.cambria.client.CambriaConsumer; diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java index a458d33c..3ff56ab1 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java @@ -22,10 +22,7 @@ package org.onap.slice.analysis.ms.dmaap; -import static org.junit.Assert.*; - -import com.att.nsa.cambria.client.CambriaBatchingPublisher; -import com.att.nsa.cambria.client.CambriaConsumer; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.HashMap; @@ -38,10 +35,13 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.Configuration; import org.onap.slice.analysis.ms.utils.DmaapUtils; import org.springframework.boot.test.context.SpringBootTest; +import com.att.nsa.cambria.client.CambriaBatchingPublisher; +import com.att.nsa.cambria.client.CambriaConsumer; + @RunWith(MockitoJUnitRunner.class) @SpringBootTest(classes = PolicyDmaapClient.class) public class PolicyDmaapClientTest { |