summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmUseCaseTest.java36
-rw-r--r--examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java24
-rw-r--r--examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java10
-rw-r--r--examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java3
4 files changed, 43 insertions, 30 deletions
diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmUseCaseTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmUseCaseTest.java
index b73b98bc4..97f0aeaaa 100644
--- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmUseCaseTest.java
+++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmUseCaseTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ import org.slf4j.ext.XLoggerFactory;
// TODO: Auto-generated Javadoc
/**
* This class tests AADM use case.
- *
+ *
* @author Sergey Sachkov (sergey.sachkov@ericsson.com)
*
*/
@@ -133,9 +133,9 @@ public class AadmUseCaseTest {
// getting number of connections send it to policy, expecting probe action
logger.info("Sending too many connections trigger ");
EnEvent event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
+ event.put("IMSI", Long.valueOf(123456));
event.put("IMSI_IP", "101.111.121.131");
- event.put("ENODEB_ID", new Long(123));
+ event.put("ENODEB_ID", Long.valueOf(123));
event.put("SERVICE_REQUEST_COUNT", 99);
event.put("AVG_SUBSCRIBER_SERVICE_REQUEST", 101.0);
event.put("UE_IP_ADDRESS", "101.111.121.131");
@@ -170,9 +170,9 @@ public class AadmUseCaseTest {
logger.info("Sending too many connections trigger ");
event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
+ event.put("IMSI", Long.valueOf(123456));
event.put("IMSI_IP", "101.111.121.131");
- event.put("ENODEB_ID", new Long(123));
+ event.put("ENODEB_ID", Long.valueOf(123));
event.put("SERVICE_REQUEST_COUNT", 101);
event.put("AVG_SUBSCRIBER_SERVICE_REQUEST", 99.0);
event.put("UE_IP_ADDRESS", "101.111.121.131");
@@ -208,9 +208,9 @@ public class AadmUseCaseTest {
// getting number of connections send it to policy, expecting probe action
logger.info("Sending too many connections trigger ");
event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
+ event.put("IMSI", Long.valueOf(123456));
event.put("IMSI_IP", "101.111.121.131");
- event.put("ENODEB_ID", new Long(123));
+ event.put("ENODEB_ID", Long.valueOf(123));
event.put("SERVICE_REQUEST_COUNT", 99);
event.put("AVG_SUBSCRIBER_SERVICE_REQUEST", 101.0);
event.put("UE_IP_ADDRESS", "101.111.121.131");
@@ -243,9 +243,9 @@ public class AadmUseCaseTest {
// tcp correlation return positive dos
logger.info("Receiving action event with {} action", result.get("ACTTASK"));
event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
+ event.put("IMSI", Long.valueOf(123456));
event.put("IMSI_IP", "101.111.121.131");
- event.put("ENODEB_ID", new Long(123));
+ event.put("ENODEB_ID", Long.valueOf(123));
event.put("TCP_UE_SIDE_AVG_THROUGHPUT", 101.0);
event.put("ACTTASK", "");
event.put("APPLICATION", "");
@@ -279,9 +279,9 @@ public class AadmUseCaseTest {
// user moving enodeB
logger.info("Sending too many connections trigger ");
event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
+ event.put("IMSI", Long.valueOf(123456));
event.put("IMSI_IP", "101.111.121.131");
- event.put("ENODEB_ID", new Long(123));
+ event.put("ENODEB_ID", Long.valueOf(123));
event.put("SERVICE_REQUEST_COUNT", 99);
event.put("AVG_SUBSCRIBER_SERVICE_REQUEST", 101.0);
event.put("UE_IP_ADDRESS", "101.111.121.131");
@@ -313,8 +313,8 @@ public class AadmUseCaseTest {
logger.info("Sending too many connections trigger ");
event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
- event.put("ENODEB_ID", new Long(124));
+ event.put("IMSI", Long.valueOf(123456));
+ event.put("ENODEB_ID", Long.valueOf(124));
event.put("SERVICE_REQUEST_COUNT", 99);
event.put("AVG_SUBSCRIBER_SERVICE_REQUEST", 101.0);
event.put("UE_IP_ADDRESS", "101.111.121.131");
@@ -351,9 +351,9 @@ public class AadmUseCaseTest {
// user becomes non anomalous
logger.info("Sending too many connections trigger ");
event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
+ event.put("IMSI", Long.valueOf(123456));
event.put("IMSI_IP", "101.111.121.131");
- event.put("ENODEB_ID", new Long(123));
+ event.put("ENODEB_ID", Long.valueOf(123));
event.put("SERVICE_REQUEST_COUNT", 99);
event.put("AVG_SUBSCRIBER_SERVICE_REQUEST", 101.0);
event.put("UE_IP_ADDRESS", "101.111.121.131");
@@ -384,8 +384,8 @@ public class AadmUseCaseTest {
logger.info("Sending too many connections trigger ");
event = apexEngine.createEvent(axEvent.getKey());
- event.put("IMSI", new Long(123456));
- event.put("ENODEB_ID", new Long(123));
+ event.put("IMSI", Long.valueOf(123456));
+ event.put("ENODEB_ID", Long.valueOf(123));
event.put("SERVICE_REQUEST_COUNT", 99);
event.put("UE_IP_ADDRESS", "101.111.121.131");
event.put("ACTTASK", "");
diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java
index 69c7a7503..07dc96ba3 100644
--- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java
+++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java
@@ -65,12 +65,24 @@ public class MfpModelCliTest {
final File tempModelFile1 = File.createTempFile("TestMyFirstPolicy1CLI", ".json");
final File tempLogFile2 = File.createTempFile("TestMyFirstPolicy2CLI", ".log");
final File tempModelFile2 = File.createTempFile("TestMyFirstPolicy2CLI", ".json");
- final String[] testApexModel1CliArgs =
- {"-c", "src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.apex", "-l",
- tempLogFile1.getAbsolutePath(), "-o", tempModelFile1.getAbsolutePath()};
- final String[] testApexModel2CliArgs =
- {"-c", "src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex", "-l",
- tempLogFile2.getAbsolutePath(), "-o", tempModelFile2.getAbsolutePath()};
+ // @formatter:off
+ final String[] testApexModel1CliArgs = {
+ "-c",
+ "src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.apex",
+ "-l",
+ tempLogFile1.getAbsolutePath(),
+ "-o",
+ tempModelFile1.getAbsolutePath()
+ };
+ final String[] testApexModel2CliArgs = {
+ "-c",
+ "src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex",
+ "-l",
+ tempLogFile2.getAbsolutePath(),
+ "-o",
+ tempModelFile2.getAbsolutePath()
+ };
+ // @formatter:on
new ApexCommandLineEditorMain(testApexModel1CliArgs);
new ApexCommandLineEditorMain(testApexModel2CliArgs);
diff --git a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
index e7bba5905..3cb588dc7 100644
--- a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
+++ b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 huawei. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,9 @@ import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+
import javax.net.ssl.HttpsURLConnection;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -51,7 +53,7 @@ public class WebClientTest {
}
@Test
- public void httpsRequest() {
+ public void testHttpsRequest() {
WebClient cl = new WebClient();
String result =
cl.httpRequest("https://some.random.url/data", "POST", null, "admin", "admin", "application/json");
@@ -59,7 +61,7 @@ public class WebClientTest {
}
@Test
- public void httpRequest() {
+ public void testHttpRequest() {
WebClient cl = new WebClient();
String result =
cl.httpRequest("http://some.random.url/data", "GET", null, "admin", "admin", "application/json");
@@ -67,7 +69,7 @@ public class WebClientTest {
}
@Test
- public void toPrettyString() {
+ public void testToPrettyString() {
String xmlSample = "<input xmlns=\"org:onap:sdnc:northbound:generic-resource\">"
+ "<sdnc-request-header> <svc-action>update</svc-action> </sdnc-request-header></input>";
WebClient cl = new WebClient();
diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java
index 47c293d54..f228ccd76 100644
--- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java
+++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java
@@ -409,8 +409,7 @@ public class OnapVCpeSimEndpoint {
}
private static final String prettifyJsonString(final String uglyJsonString) {
- JsonParser jp = new JsonParser();
- JsonElement je = jp.parse(uglyJsonString);
+ JsonElement je = JsonParser.parseString(uglyJsonString);
return gson.toJson(je);
}
}