summaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'intentanalysis/src/test')
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java9
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImplTest.java58
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/IntentReportServiceTest.java62
-rw-r--r--intentanalysis/src/test/resources/intent.json104
-rw-r--r--intentanalysis/src/test/resources/intentdb-test-init.sql12
-rw-r--r--intentanalysis/src/test/resources/logback-test.xml6
6 files changed, 240 insertions, 11 deletions
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java
index 2c04e7b..30ffd01 100644
--- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java
@@ -28,6 +28,8 @@ import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.*;
import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
+import org.onap.usecaseui.intentanalysis.service.ExpectationService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -40,8 +42,11 @@ import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest(classes = IntentAnalysisApplicationTests.class)
@RunWith(SpringRunner.class)
public class CLLDeliveryActuationModuleTest {
- @InjectMocks
+ @Autowired
CLLDeliveryActuationModule cllDeliveryActuationModulel;
+
+ @Autowired
+ private ExpectationService expectationService;
@Mock
private ExpectationObjectService expectationObjectService;
@Mock
@@ -92,7 +97,7 @@ public class CLLDeliveryActuationModuleTest {
Intent intent = new Intent();
List<Expectation> expectationList = new ArrayList<>();
Expectation expectation = new Expectation();
- expectation.setExpectationId("1234");
+ expectation.setExpectationId("expectationId1");
List<ExpectationTarget> targetList = new ArrayList<>();
ExpectationTarget target = new ExpectationTarget();
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImplTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImplTest.java
new file mode 100644
index 0000000..1925d4e
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImplTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. 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.
+ */
+
+package org.onap.usecaseui.intentanalysis.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.io.FileUtils;
+import org.apache.ibatis.io.Resources;
+import org.mockito.Mock;
+import org.onap.usecaseui.intentanalysis.adapters.policy.PolicyService;
+import org.onap.usecaseui.intentanalysis.adapters.so.SOService;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
+import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+
+@Component
+public class ComponentNotificationServiceImplTest implements ApplicationRunner {
+ @Autowired
+ ComponentNotificationServiceImpl componentNotificationService;
+
+ @Autowired
+ FormatIntentInputManagementFunction formatIntentInputManagementFunction;
+
+ @Mock
+ private PolicyService policyService;
+
+ @Mock
+ private SOService soService;
+
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ File policyTypeFile = Resources.getResourceAsFile("intent.json");
+ String intentStr = FileUtils.readFileToString(policyTypeFile, StandardCharsets.UTF_8);
+ Intent intent = JSONObject.parseObject(intentStr, Intent.class);
+ formatIntentInputManagementFunction.receiveIntentAsOwner(new IntentGoalBean(intent, IntentGoalType.CREATE));
+ }
+}
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/IntentReportServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/IntentReportServiceTest.java
new file mode 100644
index 0000000..a2c3dd9
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/impl/IntentReportServiceTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. 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.
+ */
+
+package org.onap.usecaseui.intentanalysis.service.impl;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
+import org.onap.usecaseui.intentanalysis.bean.models.*;
+import org.onap.usecaseui.intentanalysis.mapper.ExpectationObjectMapper;
+import org.onap.usecaseui.intentanalysis.service.IntentReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+@SpringBootTest(classes = IntentAnalysisApplicationTests.class)
+@RunWith(SpringRunner.class)
+public class IntentReportServiceTest {
+ @Autowired
+ private IntentReportService intentReportService;
+
+ @Autowired
+ ComponentNotificationServiceImpl componentNotificationService;
+
+ @Autowired
+ private ExpectationObjectMapper expectationObjectMapper;
+
+ @Test
+ public void getIntentReportByIntentIdTest() {
+ List<String> allObjectInstances = expectationObjectMapper.getAllObjectInstances();
+ List<String> cll = new ArrayList<>();
+ for (String target : allObjectInstances) {
+ if (target != null && target.contains("cll")) {
+ cll.add(target);
+ }
+ }
+ FulfillmentOperation fulfillmentOperation = new FulfillmentOperation();
+ fulfillmentOperation.setObjectInstances(Collections.singletonList(cll.get(0)));
+ fulfillmentOperation.setOperation("delivery");
+ componentNotificationService.callBack(fulfillmentOperation);
+ IntentReport report = intentReportService.getIntentReportByIntentId("testIntentId111");
+ Assert.assertNotNull(report);
+ }
+}
diff --git a/intentanalysis/src/test/resources/intent.json b/intentanalysis/src/test/resources/intent.json
new file mode 100644
index 0000000..66ebb21
--- /dev/null
+++ b/intentanalysis/src/test/resources/intent.json
@@ -0,0 +1,104 @@
+{
+ "intentId":"testIntentId111",
+ "intentName":"CLLBusiness intent",
+ "intentExpectations":[
+ {
+ "expectationId":"expectationId111",
+ "expectationName":"CLL Delivery Expectation",
+ "expectationType":"DELIVERY",
+ "expectationObject":{
+ "objectType":"CCVPN",
+ "objectInstance":""
+ },
+ "expectationTargets":[
+ {
+ "targetId":"target111-1",
+ "targetName":"source",
+ "targetConditions":[
+ {
+ "conditionId":"condition111-1",
+ "conditionName":"condition of the cll service source",
+ "operator":"EQUALTO",
+ "conditionValue":"tranportEp_src_ID_111_1(onu-1(companyA))",
+ "conditionList":null
+ }
+ ]
+ },
+ {
+ "targetId":"target111-2",
+ "targetName":"destination",
+ "targetConditions":[
+ {
+ "conditionId":"condition111-2",
+ "conditionName":"condition of the cll service destination",
+ "operator":"EQUALTO",
+ "conditionValue":"tranportEp_dst_ID_212_1(cloud-pop-1(cloud 1))",
+ "conditionList":null
+ }
+ ]
+ },
+ {
+ "targetId":"target111-3",
+ "targetName":"bandwidth",
+ "targetConditions":[
+ {
+ "conditionId":"condition111-3",
+ "conditionName":"condition of the cll service bandwidth",
+ "operator":"EQUALTO",
+ "conditionValue":"1000",
+ "conditionList":null
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "expectationId":"expectationId222",
+ "expectationName":"CLL Assurance Expectation",
+ "expectationType":"ASSURANCE",
+ "expectationObject":{
+ "objectType":"CCVPN",
+ "objectInstance":""
+ },
+ "expectationTargets":[
+ {
+ "targetId":"target222-1",
+ "targetName":"bandwidthAssurance",
+ "targetConditions":[
+ {
+ "conditionId":"condition222-1",
+ "conditionName":"condition of the cll service bandwidth assurance",
+ "operator":"EQUALTO",
+ "conditionValue":"true",
+ "conditionList":null
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "expectationId":"expectationId333",
+ "expectationName":"CLL Report Expectation",
+ "expectationType":"REPORT",
+ "expectationObject":{
+ "objectType":"CCVPN",
+ "objectInstance":""
+ },
+ "expectationTargets":[
+ {
+ "targetId":"target333-1",
+ "targetName":"bandwidthAssurance",
+ "targetConditions":[
+ {
+ "conditionId":"condition333-1",
+ "conditionName":"condition of the cll service bandwidth assurance",
+ "operator":"EQUALTO",
+ "conditionValue":"10",
+ "conditionList":null
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/intentanalysis/src/test/resources/intentdb-test-init.sql b/intentanalysis/src/test/resources/intentdb-test-init.sql
index 25dc9ba..c3abda1 100644
--- a/intentanalysis/src/test/resources/intentdb-test-init.sql
+++ b/intentanalysis/src/test/resources/intentdb-test-init.sql
@@ -90,12 +90,12 @@ create table if not exists intent_management_function_reg_info(
intent_function_type varchar(255)
);
-create table if not exists intent_Event_Record(
- id varchar(255) DEFAULT random_uuid(),
- intentId varchar(255),
- intentName varchar(255),
- intentStatus varchar (225),
- operateType varchar (225),
+create table if not exists intent_event_record(
+ id varchar(255) DEFAULT random_uuid (),
+ intent_id varchar(255),
+ intent_name varchar(255),
+ intent_status varchar (225),
+ operate_type varchar (225),
parent_id varchar(255)
);
diff --git a/intentanalysis/src/test/resources/logback-test.xml b/intentanalysis/src/test/resources/logback-test.xml
index ed1faf9..2d81180 100644
--- a/intentanalysis/src/test/resources/logback-test.xml
+++ b/intentanalysis/src/test/resources/logback-test.xml
@@ -20,7 +20,7 @@
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
- <pattern>%d{yyyy-MM-dd HH:mm:ss:SSS} %5p ${PID} --- [%15.15t] %-40.40c{40} : %m%n</pattern>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss:SSS} %5p ${PID} --- [%15.15t] %-40.40c{40}[%L] : %m%n</pattern>
</encoder>
</appender>
@@ -35,7 +35,7 @@
<!-- set immediateFlush to false for much higher logging throughput -->
<immediateFlush>true</immediateFlush>
<encoder>
- <pattern>%d{yyyy-MM-dd HH:mm:ss:SSS} %5p ${PID} --- [%15.15t] %-40.40c{40} : %m%n</pattern>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss:SSS} %5p ${PID} --- [%15.15t] %-40.40c{40}[%L] : %m%n</pattern>
</encoder>
</appender>
@@ -51,7 +51,7 @@
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<encoder>
- <pattern>>%d{yyyy-MM-dd HH:mm:ss:SSS} %5p ${PID} --- [%15.15t] %-40.40c{40} : %m%n</pattern>
+ <pattern>>%d{yyyy-MM-dd HH:mm:ss:SSS} %5p ${PID} --- [%15.15t] %-40.40c{40}[%L] : %m%n</pattern>
</encoder>
</appender>