summaryrefslogtreecommitdiffstats
path: root/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java
diff options
context:
space:
mode:
authordecheng zhang <decheng.zhang@huawei.com>2022-02-28 11:15:20 -0500
committerdecheng zhang <decheng.zhang@huawei.com>2022-03-18 08:55:51 -0400
commit7f2e4aa47f56085be6c95cb81b6a8bea8126d56d (patch)
tree74a5316fdad985051a5a824934c522089a76ddf3 /components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java
parentf71b9f809b64f17ac2bedd02a1ed6cbdb7573517 (diff)
Jakarta changes in slice-analysis-ms for IBN Cloud leased line update and CCVPN closed-loop. This commit contains work in sub-task: 1) AAI monitor thread; 2) bandwidth evaluator; 3) policy notification code.1.1.0-slice-analysis-ms
Issue-ID: DCAEGEN2-3063 Signed-off-by: decheng zhang <decheng.zhang@huawei.com> Change-Id: I9029ffd7563e65be59f7fd76adc2a749ff624172 Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
Diffstat (limited to 'components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java')
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java92
1 files changed, 58 insertions, 34 deletions
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java
index fef9eb35..d9bf7617 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java
@@ -3,6 +3,7 @@
* slice-analysis-ms
* ================================================================================
* Copyright (C) 2020 Wipro Limited.
+ * Copyright (C) 2022 Huawei Canada Limited.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +35,7 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.onap.slice.analysis.ms.models.policy.AdditionalProperties;
import org.onap.slice.analysis.ms.models.policy.OnsetMessage;
+import org.onap.slice.analysis.ms.service.ccvpn.RequestOwner;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -44,41 +46,63 @@ import com.google.gson.Gson;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = PolicyServiceTest.class)
public class PolicyServiceTest {
- ObjectMapper obj = new ObjectMapper();
-
- @InjectMocks
- PolicyService policyService;
-
- @Test
- public void formPolicyOnsetMessageTest() {
- String snssai = "001-100001";
- Map<String, String> input = null;
- OnsetMessage output = null;
- String expected = "";
- String actual = "";
- Map<String, Map<String, Integer>> ricToThroughputMapping = new HashMap<>();
- Map<String, Integer> ric1 = new HashMap<>();
- Map<String, Integer> ric2 = new HashMap<>();
- ric1.put("dLThptPerSlice",50);
- ric1.put("uLThptPerSlice",40);
- ric2.put("dLThptPerSlice",50);
- ric2.put("uLThptPerSlice",30);
- ricToThroughputMapping.put("1", ric1);
- ricToThroughputMapping.put("2", ric2);
- try {
- input = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/serviceDetails.json"))), new TypeReference<Map<String,String>>(){});
- output = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/onsetMessage.json"))), OnsetMessage.class);
- expected = obj.writeValueAsString(output);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
+ ObjectMapper obj = new ObjectMapper();
+
+ @InjectMocks
+ PolicyService policyService;
+
+ @Test
+ public void formPolicyOnsetMessageTest() {
+ String snssai = "001-100001";
+ Map<String, String> input = null;
+ OnsetMessage output = null;
+ String expected = "";
+ String actual = "";
+ Map<String, Map<String, Integer>> ricToThroughputMapping = new HashMap<>();
+ Map<String, Integer> ric1 = new HashMap<>();
+ Map<String, Integer> ric2 = new HashMap<>();
+ ric1.put("dLThptPerSlice",50);
+ ric1.put("uLThptPerSlice",40);
+ ric2.put("dLThptPerSlice",50);
+ ric2.put("uLThptPerSlice",30);
+ ricToThroughputMapping.put("1", ric1);
+ ricToThroughputMapping.put("2", ric2);
+ try {
+ input = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/serviceDetails.json"))), new TypeReference<Map<String,String>>(){});
+ output = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/onsetMessage.json"))), OnsetMessage.class);
+ expected = obj.writeValueAsString(output);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
AdditionalProperties<Map<String, Map<String, Integer>>> addProps = new AdditionalProperties<>();
- addProps.setResourceConfig(ricToThroughputMapping);
+ addProps.setResourceConfig(ricToThroughputMapping);
actual = new Gson().toJson(policyService.formPolicyOnsetMessage(snssai,addProps,input));
-
+
+ assertThatJson(actual)
+ .whenIgnoringPaths("requestID","payload","closedLoopAlarmStart", "AAI", "target_type", "aai", "targetType")
+ .isEqualTo(expected);
+ }
+
+ @Test
+ public void formPolicyOnsetMessageForCCVPNTest() {
+ String cllId = "cll-instance-01";
+ OnsetMessage output = null;
+ String expected = "";
+ String actual = "";
+ try {
+ output = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/onsetMessage2.json"))), OnsetMessage.class);
+ expected = obj.writeValueAsString(output);
+
+ String msg = obj.writeValueAsString(policyService
+ .formPolicyOnsetMessageForCCVPN(cllId, 3000, RequestOwner.UUI));
+ actual = new Gson().toJson(msg);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
assertThatJson(actual)
- .whenIgnoringPaths("requestID","payload","closedLoopAlarmStart", "AAI", "target_type", "aai", "targetType")
- .isEqualTo(expected);
- }
+ .whenIgnoringPaths("requestID","payload","closedLoopAlarmStart", "AAI", "target_type", "aai", "targetType")
+ .isEqualTo(expected);
+ }
}