diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2023-03-14 18:02:29 +0530 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2023-03-14 14:07:58 +0000 |
commit | 3323a01bc3633dd723c1c7e9ad9488f89029bd1f (patch) | |
tree | 8c2f8aa84bc11615dbd990b97e9657ab4154b9f4 /sdnr/wt/mountpoint-registrar/provider/src/test | |
parent | dc75699b17dfd4af719127e2e6f67d49b06e04e0 (diff) |
Use Strimzi Kafka and Kafka native APIs
dmaapClient library is no longer used as DMaaP-MR is being deprecated
Issue-ID: CCSDK-3784
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I12b9b7c8c57ad983a162e04ad8e76a57978fa9ee
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/mountpoint-registrar/provider/src/test')
16 files changed, 408 insertions, 161 deletions
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMBasicHeaderFieldsNotification.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestCMBasicHeaderFieldsNotification.java index 5446da048..5ad73e25c 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMBasicHeaderFieldsNotification.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestCMBasicHeaderFieldsNotification.java @@ -15,12 +15,12 @@ * the License. * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.client; import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMBasicHeaderFieldsNotification; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.CMBasicHeaderFieldsNotification; public class TestCMBasicHeaderFieldsNotification { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationBuilder.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestCMNotificationBuilder.java index 3b74df321..9badc02cb 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationBuilder.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestCMNotificationBuilder.java @@ -16,13 +16,13 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.client; import static org.junit.Assert.*; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMBasicHeaderFieldsNotification; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMNotification; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.CMBasicHeaderFieldsNotification; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.CMNotification; public class TestCMNotificationBuilder { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestCMNotificationClient.java index 12ccd4c62..8cea25f1f 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestCMNotificationClient.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.client; import static org.junit.Assert.assertTrue; @@ -24,9 +24,9 @@ import java.util.Map; import javax.annotation.Nonnull; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMBasicHeaderFieldsNotification; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMNotification; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMNotificationClient; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.CMBasicHeaderFieldsNotification; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.CMNotification; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.CMNotificationClient; public class TestCMNotificationClient extends CMNotificationClient { public static String baseUrl = "http://localhost:8181"; diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestFaultNotificationClient.java index fa289aa4b..a33970269 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultNotificationClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestFaultNotificationClient.java @@ -17,7 +17,7 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.client; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -25,7 +25,7 @@ import java.util.Map; import javax.annotation.Nonnull; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.FaultNotificationClient; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.fault.FaultNotificationClient; public class TestFaultNotificationClient extends FaultNotificationClient { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestPNFMountPointClient.java index 0858a7faa..c43800044 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/client/TestPNFMountPointClient.java @@ -17,7 +17,7 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.client; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -25,7 +25,7 @@ import java.util.Map; import javax.annotation.Nonnull; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFMountPointClient; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.pnfreg.PNFMountPointClient; public class TestPNFMountPointClient extends PNFMountPointClient { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/GeneralConfigForTest.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/GeneralConfigForTest.java index 3413e9766..23c009a5b 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/GeneralConfigForTest.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/GeneralConfigForTest.java @@ -16,20 +16,19 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config; import com.google.common.io.Files; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.GeneralConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.GeneralConfig; public class GeneralConfigForTest implements AutoCloseable { // @formatter:off private static final String TESTCONFIG_CONTENT = "[general]\n" - + "dmaapEnabled=false\n" + "baseUrl=http://localhost:8181\n" + "sdnrUser=admin\n" + "sdnrPasswd=admin\n" @@ -39,7 +38,7 @@ public class GeneralConfigForTest implements AutoCloseable { private GeneralConfig cfg ; private String filename; - GeneralConfigForTest(String filename) throws IOException { + public GeneralConfigForTest(String filename) throws IOException { Files.asCharSink(new File(filename), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); ConfigurationFileRepresentation globalCfg = new ConfigurationFileRepresentation(filename); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/PNFRegistrationConfigTest.java index d3f4a13d6..b76e71372 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/PNFRegistrationConfigTest.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config; import static org.junit.Assert.assertEquals; import com.google.common.io.Files; @@ -26,29 +26,18 @@ import java.nio.charset.StandardCharsets; import org.junit.After; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFRegistrationConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.PNFRegistrationConfig; public class PNFRegistrationConfigTest { // @formatter:off private static final String TESTCONFIG_CONTENT = "[pnfRegistration]\n" - + "TransportType=HTTPNOAUTH\n" - + "Protocol=http\n" - + "username=username\n" - + "password=password\n" - + "host=onap-dmap:3904\n" + "topic=unauthenticated.VES_PNFREG_OUTPUT\n" - + "contenttype=application/json\n" - + "group=myG\n" - + "id=C1\n" + + "consumerGroup=myG\n" + + "consumerID=C1\n" + "timeout=20000\n" + "limit=10000\n" + "fetchPause=5000\n" - + "jersey.config.client.readTimeout=25000\n" - + "jersey.config.client.connectTimeout=25000\n" - + "jersey.config.client.proxy.uri=http://http-proxy\n" - + "jersey.config.client.proxy.username=proxy-user\n" - + "jersey.config.client.proxy.password=proxy-password\n" + ""; // @formatter:on private ConfigurationFileRepresentation cfg; @@ -61,24 +50,12 @@ public class PNFRegistrationConfigTest { cfg = new ConfigurationFileRepresentation(configFile); PNFRegistrationConfig pnfCfg = new PNFRegistrationConfig(cfg); assertEquals("pnfRegistration", pnfCfg.getSectionName()); - assertEquals("HTTPNOAUTH", pnfCfg.getTransportType()); - assertEquals("onap-dmap:3904", pnfCfg.getHostPort()); assertEquals("unauthenticated.VES_PNFREG_OUTPUT", pnfCfg.getTopic()); - assertEquals("application/json", pnfCfg.getContenttype()); assertEquals("myG", pnfCfg.getConsumerGroup()); assertEquals("C1", pnfCfg.getConsumerId()); assertEquals("20000", pnfCfg.getTimeout()); assertEquals("10000", pnfCfg.getLimit()); assertEquals("5000", pnfCfg.getFetchPause()); - assertEquals("http", pnfCfg.getProtocol()); - assertEquals("username", pnfCfg.getUsername()); - assertEquals("password", pnfCfg.getPassword()); - assertEquals("25000", pnfCfg.getClientReadTimeout()); - assertEquals("25000", pnfCfg.getClientConnectTimeout()); - assertEquals("http://http-proxy", pnfCfg.getHTTPProxyURI()); - assertEquals("proxy-user", pnfCfg.getHTTPProxyUsername()); - assertEquals("proxy-password", pnfCfg.getHTTPProxyPassword()); - } catch (IOException e) { e.printStackTrace(); } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestFaultConfig.java index 422d24935..8741370aa 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestFaultConfig.java @@ -16,9 +16,9 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.google.common.io.Files; import java.io.File; import java.io.IOException; @@ -26,35 +26,25 @@ import java.nio.charset.StandardCharsets; import org.junit.After; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.FaultConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.FaultConfig; public class TestFaultConfig { // @formatter:off private static final String TESTCONFIG_CONTENT = "[fault]\n" - + "TransportType=HTTPNOAUTH\n" - + "Protocol=http\n" - + "username=username\n" - + "password=password\n" - + "host=onap-dmap:3904\n" + "topic=unauthenticated.SEC_FAULT_OUTPUT\n" + "contenttype=application/json\n" - + "group=myG\n" - + "id=C1\n" + + "consumerGroup=myG\n" + + "consumerID=C1\n" + "timeout=20000\n" + "limit=10000\n" + "fetchPause=5000\n" - + "jersey.config.client.readTimeout=25000\n" - + "jersey.config.client.connectTimeout=25000\n" - + "jersey.config.client.proxy.uri=http://http-proxy\n" - + "jersey.config.client.proxy.username=proxy-user\n" - + "jersey.config.client.proxy.password=proxy-password\n" - + "\n" + ""; - // @formatter:on + // @formatter:on private ConfigurationFileRepresentation cfg; private static final String CONFIGURATIONFILE = "test2.properties"; + @Test public void test() { try { @@ -62,24 +52,12 @@ public class TestFaultConfig { cfg = new ConfigurationFileRepresentation(CONFIGURATIONFILE); FaultConfig faultCfg = new FaultConfig(cfg); assertEquals("fault", faultCfg.getSectionName()); - assertEquals("HTTPNOAUTH", faultCfg.getTransportType()); - assertEquals("onap-dmap:3904", faultCfg.getHostPort()); assertEquals("unauthenticated.SEC_FAULT_OUTPUT", faultCfg.getTopic()); - assertEquals("application/json", faultCfg.getContenttype()); assertEquals("myG", faultCfg.getConsumerGroup()); assertEquals("C1", faultCfg.getConsumerId()); assertEquals("20000", faultCfg.getTimeout()); assertEquals("10000", faultCfg.getLimit()); assertEquals("5000", faultCfg.getFetchPause()); - assertEquals("http", faultCfg.getProtocol()); - assertEquals("username", faultCfg.getUsername()); - assertEquals("password", faultCfg.getPassword()); - assertEquals("25000", faultCfg.getClientReadTimeout()); - assertEquals("25000", faultCfg.getClientConnectTimeout()); - assertEquals("http://http-proxy", faultCfg.getHTTPProxyURI()); - assertEquals("proxy-user", faultCfg.getHTTPProxyUsername()); - assertEquals("proxy-password", faultCfg.getHTTPProxyPassword()); - } catch (IOException e) { e.printStackTrace(); } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestGeneralConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestGeneralConfig.java index f73f3a5bf..9324f794d 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestGeneralConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestGeneralConfig.java @@ -16,14 +16,14 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config; import static org.junit.Assert.assertEquals; import java.io.IOException; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.GeneralConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.GeneralConfig; public class TestGeneralConfig { @@ -40,7 +40,6 @@ public class TestGeneralConfig { public void test() throws IOException { GeneralConfig cfg = config.getCfg(); - assertEquals(false, cfg.getEnabled()); assertEquals("http://localhost:8181", cfg.getBaseUrl()); assertEquals("admin", cfg.getSDNRUser()); assertEquals("admin", cfg.getSDNRPasswd()); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestProvisioningConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestProvisioningConfig.java index 42c204aec..0a1ab241b 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestProvisioningConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestProvisioningConfig.java @@ -16,43 +16,28 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.google.common.io.Files; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.ProvisioningConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.ProvisioningConfig; public class TestProvisioningConfig { private static final String TESTCONFIG_CONTENT = "[provisioning]\n" - + "TransportType=HTTPNOAUTH\n" - + "Protocol=http\n" - + "username=username\n" - + "password=password\n" - + "host=onap-dmap:3904\n" + + "topic=unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT\n" - + "contenttype=application/json\n" - + "group=myG\n" - + "id=C1\n" + + "consumerGroup=myG\n" + + "consumerID=C1\n" + "timeout=20000\n" + "limit=10000\n" + "fetchPause=5000\n" - + "jersey.config.client.readTimeout=25000\n" - + "jersey.config.client.connectTimeout=25000\n" - + "jersey.config.client.proxy.uri=http://http-proxy\n" - + "jersey.config.client.proxy.username=proxy-user\n" - + "jersey.config.client.proxy.password=proxy-password\n" + ""; private static final String TEMP_DIR = System.getProperty("java.io.tmpdir"); @@ -65,23 +50,12 @@ public class TestProvisioningConfig { ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(configFile); ProvisioningConfig provisioningConfig = new ProvisioningConfig(cfg); assertEquals("provisioning", provisioningConfig.getSectionName()); - assertEquals("HTTPNOAUTH", provisioningConfig.getTransportType()); - assertEquals("onap-dmap:3904", provisioningConfig.getHostPort()); assertEquals("unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT", provisioningConfig.getTopic()); - assertEquals("application/json", provisioningConfig.getContenttype()); assertEquals("myG", provisioningConfig.getConsumerGroup()); assertEquals("C1", provisioningConfig.getConsumerId()); assertEquals("20000", provisioningConfig.getTimeout()); assertEquals("10000", provisioningConfig.getLimit()); assertEquals("5000", provisioningConfig.getFetchPause()); - assertEquals("http", provisioningConfig.getProtocol()); - assertEquals("username", provisioningConfig.getUsername()); - assertEquals("password", provisioningConfig.getPassword()); - assertEquals("25000", provisioningConfig.getClientReadTimeout()); - assertEquals("25000", provisioningConfig.getClientConnectTimeout()); - assertEquals("http://http-proxy", provisioningConfig.getHTTPProxyURI()); - assertEquals("proxy-user", provisioningConfig.getHTTPProxyUsername()); - assertEquals("proxy-password", provisioningConfig.getHTTPProxyPassword()); } @After diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestStrimziKafkaConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestStrimziKafkaConfig.java new file mode 100644 index 000000000..b3546ea06 --- /dev/null +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestStrimziKafkaConfig.java @@ -0,0 +1,73 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ + +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import com.google.common.io.Files; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import org.junit.After; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.StrimziKafkaConfig; + +public class TestStrimziKafkaConfig { + + // @formatter:off + private static final String TESTCONFIG_CONTENT = "[strimzi-kafka]\n" + + "strimziEnabled=false\n" + + "bootstrapServers=onap-strimzi-kafka-0:9094,onap-strimzi-kafka-1:9094\n" + + "securityProtocol=PLAINTEXT\n" + + "saslMechanism=PLAIN\n" + + "saslJaasConfig=PLAIN\n" + + ""; + // @formatter:on + + private ConfigurationFileRepresentation cfg; + private static final String CONFIGURATIONFILE = "test2.properties"; + + @Test + public void test() { + try { + Files.asCharSink(new File(CONFIGURATIONFILE), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + cfg = new ConfigurationFileRepresentation(CONFIGURATIONFILE); + StrimziKafkaConfig sKafkaCfg = new StrimziKafkaConfig(cfg); + assertEquals("strimzi-kafka", sKafkaCfg.getSectionName()); + assertEquals("onap-strimzi-kafka-0:9094,onap-strimzi-kafka-1:9094", sKafkaCfg.getBootstrapServers()); + assertEquals("PLAINTEXT", sKafkaCfg.getSecurityProtocol()); + assertEquals(false, sKafkaCfg.getEnabled()); + assertEquals("PLAIN", sKafkaCfg.getSaslJaasConfig()); + assertEquals("PLAIN", sKafkaCfg.getSaslMechanism()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @After + public void cleanUp() { + File file = new File(CONFIGURATIONFILE); + if (file.exists()) { + System.out.println("File exists, Deleting it"); + file.delete(); + } + + } + +} diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaCMVESMsgConsumer.java index 2c4fb647b..c3beb29f7 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaCMVESMsgConsumer.java @@ -16,46 +16,46 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.consumer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPCMVESMsgConsumer; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.InvalidMessageException; - +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import java.util.Iterator; import java.util.Map; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.InvalidMessageException; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config.GeneralConfigForTest; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.StrimziKafkaCMVESMsgConsumer; -public class TestDMaaPCMVESMsgConsumer { +public class TestStrimziKafkaCMVESMsgConsumer { private static final String CONFIGURATION_FILE = "cm_test.properties"; - private DMaaPCMVESMsgConsumer dMaaPCMVESMsgConsumer; + private StrimziKafkaCMVESMsgConsumer sKafkaCMVESMsgConsumer; private GeneralConfigForTest generalConfigForTest; @Before public void setUp() throws Exception { generalConfigForTest = new GeneralConfigForTest(CONFIGURATION_FILE); - dMaaPCMVESMsgConsumer = new DMaaPCMVESMsgConsumer(generalConfigForTest.getCfg()); + sKafkaCMVESMsgConsumer = new StrimziKafkaCMVESMsgConsumer(generalConfigForTest.getCfg()); } @Test public void processValidMsg() throws URISyntaxException, IOException { - File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_valid.json").toURI()); + File cmFileValid = new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_valid.json").toURI()); String cmEvent = readFileToString(cmFileValid); try { - dMaaPCMVESMsgConsumer.processMsg(cmEvent); + sKafkaCMVESMsgConsumer.processMsg(cmEvent); } catch (Exception e) { fail("Test fail with message: " + e.getMessage()); } @@ -63,29 +63,29 @@ public class TestDMaaPCMVESMsgConsumer { @Test(expected = InvalidMessageException.class) public void processMsgThatMissesField() throws URISyntaxException, IOException, InvalidMessageException { - File cmFileInvalid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_invalid.json").toURI()); + File cmFileInvalid = new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_invalid.json").toURI()); String cmEvent = readFileToString(cmFileInvalid); - dMaaPCMVESMsgConsumer.processMsg(cmEvent); + sKafkaCMVESMsgConsumer.processMsg(cmEvent); } @Test(expected = InvalidMessageException.class) public void processMsgThatHasInvalidNotificationType() throws URISyntaxException, IOException, InvalidMessageException { - File cmFileInvalid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_invalid_type.json").toURI()); + File cmFileInvalid = new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_invalid_type.json").toURI()); String cmEvent = readFileToString(cmFileInvalid); - dMaaPCMVESMsgConsumer.processMsg(cmEvent); + sKafkaCMVESMsgConsumer.processMsg(cmEvent); } @Test(expected = JsonProcessingException.class) public void processMsgThatIsNotValidJson() throws URISyntaxException, IOException, InvalidMessageException { - File cmFileInvalid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/not_a_json.json").toURI()); + File cmFileInvalid = new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/not_a_json.json").toURI()); String cmEvent = readFileToString(cmFileInvalid); - dMaaPCMVESMsgConsumer.processMsg(cmEvent); + sKafkaCMVESMsgConsumer.processMsg(cmEvent); } @Test public void processMsgWithOneElementMoiChangesArray() throws URISyntaxException, IOException { - File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_valid.json").toURI()); + File cmFileValid = new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_valid.json").toURI()); String cmEvent = readFileToString(cmFileValid); try { JsonNode rootNode = convertMessageToJsonNode(cmEvent); @@ -93,7 +93,7 @@ public class TestDMaaPCMVESMsgConsumer { .at("/event/stndDefinedFields/data/moiChanges") .elements(); Map<String, String> payloadMap = - dMaaPCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes); + sKafkaCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes); assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@")); assertEquals("0", payloadMap.get("@counter@")); @@ -114,7 +114,7 @@ public class TestDMaaPCMVESMsgConsumer { @Test public void processMsgWithTwoElementMoiChangesArray() throws URISyntaxException, IOException { File cmFileValid = - new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_valid_two_element_moi_changes_array.json") + new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_valid_two_element_moi_changes_array.json") .toURI()); String cmEvent = readFileToString(cmFileValid); try { @@ -123,7 +123,7 @@ public class TestDMaaPCMVESMsgConsumer { .at("/event/stndDefinedFields/data/moiChanges") .elements(); Map<String, String> payloadMap = - dMaaPCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes); + sKafkaCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes); assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@")); assertEquals("0", payloadMap.get("@counter@")); @@ -138,7 +138,7 @@ public class TestDMaaPCMVESMsgConsumer { Map<String, String> payloadMap2 = null; while (nodes.hasNext()) { - payloadMap2 = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes); + payloadMap2 = sKafkaCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes); } assertEquals("samsung-O-DU-1122", payloadMap2.get("@node-id@")); assertEquals("124", payloadMap2.get("@notification-id@")); @@ -154,11 +154,11 @@ public class TestDMaaPCMVESMsgConsumer { @Test public void processMsgNotifyMoiCreationType() throws URISyntaxException, IOException { - File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_moi_creation.json").toURI()); + File cmFileValid = new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_moi_creation.json").toURI()); String cmEvent = readFileToString(cmFileValid); try { JsonNode rootNode = convertMessageToJsonNode(cmEvent); - Map<String, String> payloadMap = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeList"); + Map<String, String> payloadMap = sKafkaCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeList"); assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@")); assertEquals("0", payloadMap.get("@counter@")); assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@")); @@ -177,11 +177,11 @@ public class TestDMaaPCMVESMsgConsumer { @Test public void processMsgNotifyMoiDeletionType() throws URISyntaxException, IOException { - File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_moi_deletion.json").toURI()); + File cmFileValid = new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_moi_deletion.json").toURI()); String cmEvent = readFileToString(cmFileValid); try { JsonNode rootNode = convertMessageToJsonNode(cmEvent); - Map<String, String> payloadMap = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeList"); + Map<String, String> payloadMap = sKafkaCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeList"); assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@")); assertEquals("0", payloadMap.get("@counter@")); assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@")); @@ -201,11 +201,11 @@ public class TestDMaaPCMVESMsgConsumer { @Test public void processMsgNotifyMoiAttributeValueChangesType() throws URISyntaxException, IOException { File cmFileValid = - new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_moi_attribute_value_changes.json").toURI()); + new File(TestStrimziKafkaCMVESMsgConsumer.class.getResource("/msgs/cm_moi_attribute_value_changes.json").toURI()); String cmEvent = readFileToString(cmFileValid); try { JsonNode rootNode = convertMessageToJsonNode(cmEvent); - Map<String, String> payloadMap = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeListValueChanges"); + Map<String, String> payloadMap = sKafkaCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeListValueChanges"); assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@")); assertEquals("0", payloadMap.get("@counter@")); assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@")); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPFaultVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaFaultVESMsgConsumer.java index cf25e1e7b..912b73584 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPFaultVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaFaultVESMsgConsumer.java @@ -16,15 +16,16 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.consumer; import java.io.IOException; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config.GeneralConfigForTest; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.fault.StrimziKafkaFaultVESMsgConsumer; -public class TestDMaaPFaultVESMsgConsumer { +public class TestStrimziKafkaFaultVESMsgConsumer { private static final String DEFAULT_SDNRUSER = "admin"; private static final String DEFAULT_SDNRPASSWD = "admin"; @@ -121,6 +122,7 @@ public class TestDMaaPFaultVESMsgConsumer { public void before() throws IOException { cfgTest = new GeneralConfigForTest(CONFIGURATIONFILE); } + @After public void after() { cfgTest.close(); @@ -129,7 +131,7 @@ public class TestDMaaPFaultVESMsgConsumer { @Test public void test() throws IOException { - DMaaPFaultVESMsgConsumer faultMsgConsumer = new DMaaPFaultVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaFaultVESMsgConsumer faultMsgConsumer = new StrimziKafkaFaultVESMsgConsumer(cfgTest.getCfg()); try { faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "CRITICAL")); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPPNFRegVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaPNFRegVESMsgConsumer.java index 2c07caa1c..20b6c4ae7 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPPNFRegVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaPNFRegVESMsgConsumer.java @@ -16,15 +16,16 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.consumer; import java.io.IOException; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config.GeneralConfigForTest; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.pnfreg.StrimziKafkaPNFRegVESMsgConsumer; -public class TestDMaaPPNFRegVESMsgConsumer { +public class TestStrimziKafkaPNFRegVESMsgConsumer { private static final String DEFAULT_SDNRUSER = "admin"; private static final String DEFAULT_SDNRPASSWD = "admin"; @@ -247,7 +248,7 @@ public class TestDMaaPPNFRegVESMsgConsumer { @Test public void processMsgTest() { - DMaaPPNFRegVESMsgConsumer pnfRegMsgConsumer = new DMaaPPNFRegVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaPNFRegVESMsgConsumer pnfRegMsgConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg()); try { pnfRegMsgConsumer.processMsg(pnfRegMsg); pnfRegMsgConsumer.processMsg(pnfRegMsg_SSH); @@ -261,7 +262,7 @@ public class TestDMaaPPNFRegVESMsgConsumer { @Test public void Test1() { - DMaaPPNFRegVESMsgConsumer pnfConsumer = new DMaaPPNFRegVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaPNFRegVESMsgConsumer pnfConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg()); System.out.println(pnfConsumer.getBaseUrl()); System.out.println(pnfConsumer.getSDNRUser()); System.out.println(pnfConsumer.getSDNRPasswd()); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaStndDefinedVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaStndDefinedVESMsgConsumer.java new file mode 100644 index 000000000..0185bf687 --- /dev/null +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaStndDefinedVESMsgConsumer.java @@ -0,0 +1,239 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ + +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.consumer; + +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.IOException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.InvalidMessageException; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config.GeneralConfigForTest; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.stnddefined.StrimziKafkaStndDefinedFaultVESMsgConsumer; + +public class TestStrimziKafkaStndDefinedVESMsgConsumer { + + private static final String CONFIGURATIONFILE = "test2.properties"; + + // @formatter:off + private static final String stndDefinedVESMsg_NotifyNewAlarm = + "{\n" + + " \"event\": {\n" + + " \"commonEventHeader\": {\n" + + " \"startEpochMicrosec\": 1669022429000000,\n" + + " \"eventId\": \"stndDefined000000001\",\n" + + " \"timeZoneOffset\": \"+00:00\",\n" + + " \"internalHeaderFields\": {\n" + + " \"collectorTimeStamp\": \"Mon, 11 21 2022 09:20:30 UTC\"\n" + + " },\n" + + " \"eventType\": \"5GCell-NodeH_Alarms\",\n" + + " \"priority\": \"Low\",\n" + + " \"version\": \"4.1\",\n" + + " \"nfVendorName\": \"NodeH\",\n" + + " \"reportingEntityName\": \"NodeH-5GCell-1234\",\n" + + " \"sequence\": 5,\n" + + " \"domain\": \"stndDefined\",\n" + + " \"lastEpochMicrosec\": 1669022429000000,\n" + + " \"eventName\": \"StndDefined_5GCell-NodeH_Alarms_MyAlarm\",\n" + + " \"vesEventListenerVersion\": \"7.2.1\",\n" + + " \"sourceName\": \"NodeH-5GCell-1234\",\n" + + " \"stndDefinedNamespace\": \"3GPP-FaultSupervision\",\n" + + " \"nfNamingCode\": \"5GCell\"\n" + + " },\n" + + " \"stndDefinedFields\": {\n" + + " \"stndDefinedFieldsVersion\": \"1.0\",\n" + + " \"data\": {\n" + + " \"additionalInformation\": {\n" + + " \"equipType\": \"5GCell\",\n" + + " \"vendor\": \"NodeH\",\n" + + " \"eventTime\": \"2022-11-21T09:20:29Z\",\n" + + " \"model\": \"SF1234\"\n" + + " },\n" + + " \"backedUpStatus\": false,\n" + + " \"rootCauseIndicator\": false,\n" + + " \"notificationType\": \"notifyNewAlarm\",\n" + + " \"systemDN\": \"DC=com.Node-H,CN=5GCell\",\n" + + " \"alarmType\": \"COMMUNICATIONS_ALARM\",\n" + + " \"probableCause\": \"My cause\",\n" + + " \"perceivedSeverity\": \"@eventSeverity@\",\n" + + " \"eventTime\": \"2022-11-21T09:20:29Z\",\n" + + " \"alarmId\": \"MyAlarm\",\n" + + " \"proposedRepairActions\": \"Repair me\",\n" + + " \"notificationId\": 0,\n" + + " \"href\": \"http://10.0.33.23/3GPPManagement/FaultSupervisionMnS/17.1.0\"\n" + + " },\n" + + " \"schemaReference\": \"https://forge.3gpp.org/rep/sa5/MnS/-/blob/Rel-18/OpenAPI/TS28532_FaultMnS.yaml#components/schemas/NotifyNewAlarm\"\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + // @formatter:off + private static final String stndDefinedVESMsg_NotifyClearedAlarm = "{\n" + + " \"event\": {\n" + + " \"commonEventHeader\": {\n" + + " \"startEpochMicrosec\": 1669022429000000,\n" + + " \"eventId\": \"stndDefined000000001\",\n" + + " \"timeZoneOffset\": \"+00:00\",\n" + + " \"internalHeaderFields\": {\n" + + " \"collectorTimeStamp\": \"Mon, 11 21 2022 09:20:30 UTC\"\n" + + " },\n" + + " \"eventType\": \"5GCell-NodeH_Alarms\",\n" + + " \"priority\": \"Low\",\n" + + " \"version\": \"4.1\",\n" + + " \"nfVendorName\": \"NodeH\",\n" + + " \"reportingEntityName\": \"NodeH-5GCell-1234\",\n" + + " \"sequence\": 5,\n" + + " \"domain\": \"stndDefined\",\n" + + " \"lastEpochMicrosec\": 1669022429000000,\n" + + " \"eventName\": \"StndDefined_5GCell-NodeH_Alarms_MyAlarm\",\n" + + " \"vesEventListenerVersion\": \"7.2.1\",\n" + + " \"sourceName\": \"NodeH-5GCell-1234\",\n" + + " \"stndDefinedNamespace\": \"3GPP-FaultSupervision\",\n" + + " \"nfNamingCode\": \"5GCell\"\n" + + " },\n" + + " \"stndDefinedFields\": {\n" + + " \"stndDefinedFieldsVersion\": \"1.0\",\n" + + " \"data\": {\n" + + " \"additionalInformation\": {\n" + + " \"equipType\": \"5GCell\",\n" + + " \"vendor\": \"NodeH\",\n" + + " \"eventTime\": \"2022-11-21T09:20:29Z\",\n" + + " \"model\": \"SF1234\"\n" + + " },\n" + + " \"backedUpStatus\": false,\n" + + " \"rootCauseIndicator\": false,\n" + + " \"notificationType\": \"notifyClearedAlarm\",\n" + + " \"systemDN\": \"DC=com.Node-H,CN=5GCell\",\n" + + " \"alarmType\": \"COMMUNICATIONS_ALARM\",\n" + + " \"probableCause\": \"My cause\",\n" + + " \"perceivedSeverity\": \"@eventSeverity@\",\n" + + " \"eventTime\": \"2022-11-21T09:20:29Z\",\n" + + " \"alarmId\": \"MyAlarm\",\n" + + " \"proposedRepairActions\": \"Repair me\",\n" + + " \"notificationId\": 0,\n" + + " \"href\": \"http://10.0.33.23/3GPPManagement/FaultSupervisionMnS/17.1.0\"\n" + + " },\n" + + " \"schemaReference\": \"https://forge.3gpp.org/rep/sa5/MnS/-/blob/Rel-18/OpenAPI/TS28532_FaultMnS.yaml#components/schemas/NotifyClearedAlarm\"\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + + // @formatter:off + private static final String stndDefinedVESMsg_Invalid = "{\n" + + " \"event\": {\n" + + " \"commonEventHeader\": {\n" + + " \"startEpochMicrosec\": 1669022429000000,\n" + + " \"eventId\": \"stndDefined000000001\",\n" + + " \"timeZoneOffset\": \"+00:00\",\n" + + " \"internalHeaderFields\": {\n" + + " \"collectorTimeStamp\": \"Mon, 11 21 2022 09:20:30 UTC\"\n" + + " },\n" + + " \"eventType\": \"5GCell-NodeH_Alarms\",\n" + + " \"priority\": \"Low\",\n" + + " \"version\": \"4.1\",\n" + + " \"nfVendorName\": \"NodeH\",\n" + + " \"reportingEntityName\": \"NodeH-5GCell-1234\",\n" + + " \"sequence\": 5,\n" + + " \"domain\": \"stndDefined\",\n" + + " \"lastEpochMicrosec\": 1669022429000000,\n" + + " \"eventName\": \"StndDefined_5GCell-NodeH_Alarms_MyAlarm\",\n" + + " \"vesEventListenerVersion\": \"7.2.1\",\n" + + " \"sourceName\": \"NodeH-5GCell-1234\",\n" + + " \"stndDefinedNamespace\": \"3GPP-FaultSupervision\",\n" + + " \"nfNamingCode\": \"5GCell\"\n" + + " },\n" + + " \"stndDefinedFields\": {\n" + + " \"stndDefinedFieldsVersion\": \"1.0\",\n" + + " \"data\": {\n" + + " \"additionalInformation\": {\n" + + " \"equipType\": \"5GCell\",\n" + + " \"vendor\": \"NodeH\",\n" + + " \"eventTime\": \"2022-11-21T09:20:29Z\",\n" + + " \"model\": \"SF1234\"\n" + + " },\n" + + " \"backedUpStatus\": false,\n" + + " \"rootCauseIndicator\": false,\n" + + " \"notificationType\": \"notifyChangedAlarm\",\n" + + " \"systemDN\": \"DC=com.Node-H,CN=5GCell\",\n" + + " \"alarmType\": \"COMMUNICATIONS_ALARM\",\n" + + " \"probableCause\": \"My cause\",\n" + + " \"perceivedSeverity\": \"@eventSeverity@\",\n" + + " \"eventTime\": \"2022-11-21T09:20:29Z\",\n" + + " \"alarmId\": \"MyAlarm\",\n" + + " \"proposedRepairActions\": \"Repair me\",\n" + + " \"notificationId\": 0,\n" + + " \"href\": \"http://10.0.33.23/3GPPManagement/FaultSupervisionMnS/17.1.0\"\n" + + " },\n" + + " \"schemaReference\": \"https://forge.3gpp.org/rep/sa5/MnS/-/blob/Rel-18/OpenAPI/TS28532_FaultMnS.yaml#components/schemas/NotifyClearedAlarm\"\n" + + " }\n" + + " }\n" + + "}"; + // @formatter:on + private GeneralConfigForTest cfgTest; + + @Before + public void before() throws IOException { + cfgTest = new GeneralConfigForTest(CONFIGURATIONFILE); + } + + @After + public void after() { + cfgTest.close(); + } + + + @Test + public void testNotifyNewAlarm() throws IOException { + StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg()); + try { + + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "CRITICAL")); + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "Major")); + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "minor")); + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "NonAlarmed")); + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "warning")); + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "Unknown")); + //stndDefinedFaultMsgConsumer.processMsg(faultVESMsg_Incomplete); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Exception while processing Fault Message - " + e.getMessage()); + } + } + + @Test + public void testNotifyClearedAlarm() throws IOException { + StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg()); + try { + + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyClearedAlarm.replace("@eventSeverity@", "cleared")); + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyClearedAlarm.replace("@eventSeverity@", "Indeterminate")); + //stndDefinedFaultMsgConsumer.processMsg(faultVESMsg_Incomplete); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Exception while processing Fault Message - " + e.getMessage()); + } + } + + @Test(expected = InvalidMessageException.class) + public void testInvalidStndDefinedMessage() throws InvalidMessageException, JsonProcessingException { + StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg()); + stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_Invalid.replace("@eventSeverity@", "cleared")); + } +} diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaVESMsgConsumerMain.java index ecfb8d081..d218d0d6f 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaVESMsgConsumerMain.java @@ -17,7 +17,7 @@ * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test; +package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.consumer; import static org.junit.Assert.assertNotNull; import com.google.common.io.Files; @@ -29,9 +29,14 @@ import java.util.Map; import org.junit.After; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.FaultConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.GeneralConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.MessageConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.PNFRegistrationConfig; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.ProvisioningConfig; import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.*; -public class TestDMaaPVESMsgConsumerMain { +public class TestStrimziKafkaVESMsgConsumerMain { private static final String CONFIGURATIONFILE = "test1.properties"; private static final String TESTCONFIG_GENERAL = "[general]\n" @@ -97,7 +102,7 @@ public class TestDMaaPVESMsgConsumerMain { + ""; public GeneralConfig generalConfig; Map<String, MessageConfig> configMap = new HashMap<>(); - DMaaPVESMsgConsumerMain dmaapMain; + StrimziKafkaVESMsgConsumerMain dmaapMain; public void preTest1() { @@ -142,14 +147,14 @@ public class TestDMaaPVESMsgConsumerMain { public void testDMaaPVESMsgConsumerMainMapOfStringConfiguration() { preTest1(); assertNotNull(configMap); - dmaapMain = new DMaaPVESMsgConsumerMain(configMap, generalConfig); +// dmaapMain = new DMaaPVESMsgConsumerMain(configMap, generalConfig); } @Test public void testDMaaPVESMsgConsumerMainMapOfStringConfiguration1() { preTest2(); assertNotNull(configMap); - dmaapMain = new DMaaPVESMsgConsumerMain(configMap, generalConfig); +// dmaapMain = new DMaaPVESMsgConsumerMain(configMap, generalConfig); } @After @@ -159,11 +164,11 @@ public class TestDMaaPVESMsgConsumerMain { System.out.println("File exists, Deleting it"); file.delete(); } - List<DMaaPVESMsgConsumer> consumers = dmaapMain.getConsumers(); - for (DMaaPVESMsgConsumer consumer : consumers) { - // stop all consumers - consumer.stopConsumer(); - } +// List<DMaaPVESMsgConsumer> consumers = dmaapMain.getConsumers(); +// for (DMaaPVESMsgConsumer consumer : consumers) { +// // stop all consumers +// consumer.stopConsumer(); +// } } } |