aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeguang He <hekeguang@chinamobile.com>2022-09-01 07:44:55 +0000
committerGerrit Code Review <gerrit@onap.org>2022-09-01 07:44:55 +0000
commitd004c121a83dfea3654d9ac47bd558e2237b7e6f (patch)
tree103640f096a16e868037470977bf77d4260258d8
parent63492d1459f46c889ba93641ec51ab8928cc0127 (diff)
parent54e7ca4ddf183cd15bd7afff0c53b1970698432b (diff)
Merge "Add UT to intent service"
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java43
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java37
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java122
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml2
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml53
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java121
-rw-r--r--intentanalysis/src/test/resources/application.yaml6
-rw-r--r--intentanalysis/src/test/resources/intentdb-test-data.sql71
-rw-r--r--intentanalysis/src/test/resources/intentdb-test-init.sql78
11 files changed, 256 insertions, 285 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
index cc253ab..1178b6d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
@@ -37,5 +37,5 @@ public interface IntentMapper {
int deleteIntent(@Param(value = "intentId") String intentId);
- List<Intent> getIntentByName(@Param(value = "name") String name);
+ List<Intent> getIntentByName(@Param(value = "intentName") String name);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
deleted file mode 100644
index 10538c4..0000000
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2022 Huawei Technologies Co., Ltd.
- *
- * 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.mapper;
-
-
-import java.util.List;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
-import org.onap.usecaseui.intentanalysis.bean.models.State;
-
-
-@Mapper
-
-public interface StateMapper {
-
- int insertStateList(@Param(value = "stateList") List<State> state,
- @Param(value = "expectationId") String expectationId);
-
- List<State> selectStateByExpectation(@Param(value = "expectationId") String expectationId);
-
- int deleteStateByExpectationId(@Param(value = "expectationId") String expectationId);
-
- int updateState(@Param(value = "state") State state);
-
- int insertState(@Param(value = "state") State state, @Param(value = "expectationId") String expectationId);
-
- int deleteStateById(@Param(value = "stateId") String stateId);
-}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
deleted file mode 100644
index d2d66c7..0000000
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2022 Huawei Technologies Co., Ltd.
- *
- * 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;
-
-
-import java.util.List;
-import org.onap.usecaseui.intentanalysis.bean.models.State;
-
-
-public interface StateService {
-
- void createStateList(List<State> stateList, String expectationId);
-
- void deleteStateListByExpectationId(String expectationId);
-
- void updateStateListByExpectationId(List<State> stateList, String expectationId);
-
- List<State> getStateListByExpectationId(String expectationId);
-
- void createState(State state, String expectationId);
-
- void deleteStateById(String stateId);
-}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
index 952b6dd..bb1759c 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
@@ -87,7 +87,9 @@ public class IntentServiceImpl implements IntentService {
public Intent getIntent(String intentId) {
Intent intent = intentMapper.selectIntent(intentId);
if (intent != null) {
- intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId()));
+ intent.setIntentExpectations(expectationService.getIntentExpectationList(intentId));
+ intent.setIntentContexts(contextService.getContextList(intentId));
+ intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(intentId));
} else {
log.info(String.format("Intent is null, intentId = %s", intentId));
}
@@ -140,6 +142,8 @@ public class IntentServiceImpl implements IntentService {
if (!CollectionUtils.isEmpty(intentList)) {
for (Intent intent : intentList) {
intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId()));
+ intent.setIntentContexts(contextService.getContextList(intent.getIntentId()));
+ intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(intent.getIntentId()));
}
} else {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
deleted file mode 100644
index b9c7b95..0000000
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2022 Huawei Technologies Co., Ltd.
- *
- * 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 lombok.extern.slf4j.Slf4j;
-import org.onap.usecaseui.intentanalysis.bean.models.State;
-import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
-import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
-import org.onap.usecaseui.intentanalysis.mapper.StateMapper;
-import org.onap.usecaseui.intentanalysis.service.StateService;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-
-@Service
-@Slf4j
-public class StateServiceImpl implements StateService {
-
- @Autowired
- private StateMapper stateMapper;
-
- @Autowired
- private StateService stateService;
-
- @Override
- public void createStateList(List<State> stateList, String expectationId) {
- int res = stateMapper.insertStateList(stateList, expectationId);
- if (res < 1) {
- String msg = "Create state to database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
- }
- }
-
- @Override
- public List<State> getStateListByExpectationId(String expectationId) {
- List<State> stateList = stateMapper.selectStateByExpectation(expectationId);
- if (stateList == null) {
- String msg = String.format("State: Expectation id %s doesn't exist in database.", expectationId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- return stateList;
- }
-
- @Override
- public void deleteStateListByExpectationId(String expectationId) {
- if (stateMapper.deleteStateByExpectationId(expectationId) < 1) {
- String msg = "Delete state in database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
- }
- }
-
- @Override
- public void updateStateListByExpectationId(List<State> stateList, String expectationId) {
- List<State> stateDBList = stateMapper.selectStateByExpectation(expectationId);
- if (stateDBList == null) {
- String msg = String.format("Expectation id %s doesn't exist in database.", expectationId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- List<String> stateDBIdList = new ArrayList<>();
- for (State stateDB : stateDBList) {
- stateDBIdList.add(stateDB.getStateId());
- }
- for (State state : stateList) {
- if (stateDBIdList.contains(state.getStateId())) {
- int res = stateMapper.updateState(state);
- if (res < 1) {
- String msg = "Update state in database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
- }
- stateDBIdList.remove(state.getStateId());
- } else {
- stateService.createState(state, expectationId);
- }
- }
- for (String stateDBId : stateDBIdList) {
- stateService.deleteStateById(stateDBId);
- }
- log.info("States are successfully updated.");
- }
-
- @Override
- public void createState(State state, String expectationId) {
- if (stateMapper.insertState(state, expectationId) < 1) {
- String msg = "Create state to database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
- }
- }
-
- @Override
- public void deleteStateById(String stateId) {
- if (stateMapper.deleteStateById(stateId) < 1) {
- String msg = "Delete state in database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
- }
- }
-} \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
index c5d3b3d..57c8952 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
@@ -34,7 +34,7 @@
<select id="getIntentByName" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
select intent_id intentId, intent_name intentName from intent
- where intent_name like "%"#{intent.intentName}"%"
+ where intent_name like #{intentName}
</select>
</mapper> \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
deleted file mode 100644
index d103015..0000000
--- a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.StateMapper">
-
- <select id="selectStateByExpectation" resultType="org.onap.usecaseui.intentanalysis.bean.models.State">
- select state_id stateId, state_name stateName, condition,
- is_satisfied isSatisfied
- from state
- where expectation_id = #{expectationId}
- </select>
-
- <insert id="insertStateList" parameterType="java.util.ArrayList">
- <if test="stateList != null">
- insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
- values
- <foreach collection="stateList" index="index" item="item" separator=",">
- (#{item.stateId}, #{item.stateName}, #{expectationId}, #{item.isSatisfied}, #{item.condition})
- </foreach>
- </if>
- </insert>
-
- <delete id="deleteStateByExpectationId">
- delete
- from state
- where expectation_id = #{expectationId}
- </delete>
-
- <insert id="insertState">
- <if test="state != null">
- insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
- values (#{state.stateId}, #{state.stateName}, #{expectationId}, #{state.isSatisfied}, #{state.condition})
- </if>
- </insert>
-
- <update id="updateState" parameterType="java.util.List">
- update state
- <trim prefix="set" suffixOverrides=",">
- <if test="stateName != null">state_name = #{stateName},</if>
- <if test="isSatisfied != null">is_satisfied = #{isSatisfied},</if>
- <if test="condition != null">condition = #{condition},</if>
- </trim>
- where state_id = #{stateId}
- </update>
-
- <delete id="deleteStateById">
- delete
- from state
- where state_id = #{stateId}
- </delete>
-
-</mapper> \ No newline at end of file
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java
index 3a692c0..6dc1062 100644
--- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/test/service/IntentServiceTest.java
@@ -15,11 +15,21 @@
package org.onap.usecaseui.intentanalysis.test.service;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.usecaseui.intentanalysis.bean.enums.*;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.models.Condition;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo;
+import org.onap.usecaseui.intentanalysis.bean.models.Context;
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
+import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
+import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
import org.onap.usecaseui.intentanalysis.service.IntentService;
import org.onap.usecaseui.intentanalysis.test.IntentAnalysisApplicationTests;
import org.onap.usecaseui.intentanalysis.util.SpringContextUtil;
@@ -36,6 +46,12 @@ public class IntentServiceTest extends AbstractJUnit4SpringContextTests {
private static final Logger LOGGER = LoggerFactory.getLogger(IntentServiceTest.class);
+ private static final String TEST_INTENT_ID_1 = "intentId1";
+
+ private static final String TEST_INTENT_ID_2 = "intentId2";
+
+ private static final String TEST_INTENT_NAME = "CLL Business intent";
+
@Autowired
private IntentService intentService;
@@ -47,10 +63,109 @@ public class IntentServiceTest extends AbstractJUnit4SpringContextTests {
@Test
public void testCreateIntentSuccess() throws IOException {
Intent intent = new Intent();
- intent.setIntentId("testUUID");
+ Expectation expectation1 = new Expectation();
+ ExpectationTarget target1 = new ExpectationTarget();
+ ExpectationObject object1 = new ExpectationObject();
+ Context intentContext = new Context();
+ FulfilmentInfo intentFulfilmentInfo = new FulfilmentInfo();
+ Condition targetCondition1 = new Condition();
+ targetCondition1.setConditionId("conditionId");
+ targetCondition1.setConditionName("conditionName");
+ targetCondition1.setOperator(OperatorType.valueOf("EQUALTO"));
+ targetCondition1.setConditionValue("conditionValue");
+ List<Condition> targetConditionList = new ArrayList<>();
+ targetConditionList.add(targetCondition1);
+ target1.setTargetId("targetId");
+ target1.setTargetName("targetName");
+ target1.setTargetConditions(targetConditionList);
+ List<ExpectationTarget> expectationTargetList = new ArrayList<>();
+ expectationTargetList.add(target1);
+ object1.setObjectType(ObjectType.valueOf("OBJECT1"));
+ object1.setObjectInstance("objectInstance");
+ expectation1.setExpectationId("expectationId");
+ expectation1.setExpectationName("expectationName");
+ expectation1.setExpectationType(ExpectationType.valueOf("DELIVERY"));
+ expectation1.setExpectationObject(object1);
+ expectation1.setExpectationTargets(expectationTargetList);
+ List<Expectation> expectationList = new ArrayList<>();
+ expectationList.add(expectation1);
+ intentContext.setContextId("intentContextId");
+ intentContext.setContextName("intentContextName");
+ List<Context> intentContextList = new ArrayList<>();
+ intentContextList.add(intentContext);
+ intentFulfilmentInfo.setFulfilmentStatus(FulfilmentStatus.valueOf("NOT_FULFILLED"));
+ intentFulfilmentInfo.setNotFulfilledReason("NotFulfilledReason");
+ intentFulfilmentInfo.setNotFulfilledState(NotFulfilledState.valueOf("COMPLIANT"));
+ intent.setIntentId("testIntentId");
intent.setIntentName("testIntentName");
- //ToDo
- //Intent intentTmp = intentService.createIntent(intent);
+ intent.setIntentContexts(intentContextList);
+ intent.setIntentExpectations(expectationList);
+ intent.setIntentFulfilmentInfo(intentFulfilmentInfo);
+
+ Intent intentTmp = intentService.createIntent(intent);
+ Assert.assertNotNull(intentTmp);
+ }
+
+ @Test
+ public void testGetIntentListSuccess() {
+ List<Intent> intentList = intentService.getIntentList();
+ Assert.assertNotNull(intentList);
+ }
+
+ @Test
+ public void testGetIntentSuccess() {
+ Intent intent = intentService.getIntent(TEST_INTENT_ID_1);
Assert.assertNotNull(intent);
}
+
+ @Test
+ public void testGetIntentByNameSuccess() {
+ List<Intent> intentList = intentService.getIntentByName(TEST_INTENT_NAME);
+ Assert.assertNotNull(intentList);
+
+ }
+
+ @Test
+ public void testUpdateIntentSuccess() {
+ Intent intent = intentService.getIntent(TEST_INTENT_ID_1);
+ intent.setIntentName("new intent name");
+ List<Context> contextList = intent.getIntentContexts();
+ Context intentContext = contextList.get(0);
+ intentContext.setContextName("new context name");
+ contextList.set(0, intentContext);
+ intent.setIntentContexts(contextList);
+ FulfilmentInfo intentFulfilmentInfo = intent.getIntentFulfilmentInfo();
+ intentFulfilmentInfo.setNotFulfilledReason("new reason");
+ intent.setIntentFulfilmentInfo(intentFulfilmentInfo);
+ List<Expectation> expectationList = intent.getIntentExpectations();
+ Expectation expectation = expectationList.get(0);
+ expectation.setExpectationName("new expectation name");
+ ExpectationObject expectationObject = expectation.getExpectationObject();
+ expectationObject.setObjectInstance("new object instance");
+ expectation.setExpectationObject(expectationObject);
+ List<ExpectationTarget> expectationTargetList = expectation.getExpectationTargets();
+ ExpectationTarget expectationTarget = expectationTargetList.get(0);
+ expectationTarget.setTargetName("new target name");
+ List<Condition> targetConditionList = expectationTarget.getTargetConditions();
+ Condition targetCondition = targetConditionList.get(0);
+ targetCondition.setConditionName("new conditon name");
+ targetConditionList.set(0, targetCondition);
+ expectationTarget.setTargetConditions(targetConditionList);
+ expectationTargetList.remove(2);
+ expectationTargetList.set(0, expectationTarget);
+ expectation.setExpectationTargets(expectationTargetList);
+ expectationList.set(0, expectation);
+ intent.setIntentExpectations(expectationList);
+
+ Intent updatedIntent = intentService.updateIntent(intent);
+ Assert.assertEquals("new intent name", updatedIntent.getIntentName());
+
+ }
+
+ @Test
+ public void testDeleteIntentSuccess() {
+ intentService.deleteIntent(TEST_INTENT_ID_2);
+ Intent intent = intentService.getIntent(TEST_INTENT_ID_2);
+ Assert.assertNull(intent);
+ }
}
diff --git a/intentanalysis/src/test/resources/application.yaml b/intentanalysis/src/test/resources/application.yaml
index 8973759..aa317ef 100644
--- a/intentanalysis/src/test/resources/application.yaml
+++ b/intentanalysis/src/test/resources/application.yaml
@@ -29,10 +29,12 @@ spring:
username:
password:
driver-class-name: org.h2.Driver
- schema: classpath:intentdb-test-init.sql
- data: classpath:intentdb-test-data.sql
main:
allow-bean-definition-overriding: true
+ sql:
+ init:
+ schema-locations: classpath:intentdb-test-init.sql
+ data-locations: classpath:intentdb-test-data.sql
###mybtis####
mybatis:
diff --git a/intentanalysis/src/test/resources/intentdb-test-data.sql b/intentanalysis/src/test/resources/intentdb-test-data.sql
index 14cbefc..058e055 100644
--- a/intentanalysis/src/test/resources/intentdb-test-data.sql
+++ b/intentanalysis/src/test/resources/intentdb-test-data.sql
@@ -16,7 +16,74 @@
*/
-- ----------------------------
-MERGE INTO intent (intent_id, intent_name)KEY(intent_id)values ('1234','test-intent');
+-- Records of intent
+-- ----------------------------
+MERGE INTO intent (intent_id, intent_name) KEY (intent_id)
+values ('intentId1', 'CLL Business intent');
+MERGE INTO intent (intent_id, intent_name) KEY (intent_id)
+values ('intentId2', 'CLL Business intent');
+
+-- ----------------------------
+-- Records of expectation
+-- ----------------------------
+MERGE INTO expectation (expectation_id, expectation_name, expectation_type, intent_id) KEY (expectation_id)
+values ('expectationId1', 'CLL Service Expectation', 'DELIVERY', 'intentId1');
+MERGE INTO expectation (expectation_id, expectation_name, expectation_type, intent_id) KEY (expectation_id)
+values ('expectationId2', 'CLL Assurance Expectation', 'ASSURANCE', 'intentId1');
+MERGE INTO expectation (expectation_id, expectation_name, expectation_type, intent_id) KEY (expectation_id)
+values ('expectationId3', 'CLL Service Expectation', 'DELIVERY', 'intentId2');
+
+-- ----------------------------
+-- Records of expectation_object
+-- ----------------------------
+MERGE INTO expectation_object (object_id, object_type, object_instance, expectation_id) KEY (object_id)
+values ('b1bc45a6-f396-4b65-857d-6d2312bfb352', 'OBJECT1', '', 'expectationId1');
+MERGE INTO expectation_object (object_id, object_type, object_instance, expectation_id) KEY (object_id)
+values ('931a8690-fa61-4c2b-a387-9e0fa6152136', 'OBJECT2', '', 'expectationId2');
+MERGE INTO expectation_object (object_id, object_type, object_instance, expectation_id) KEY (object_id)
+values ('3f36bf22-3416-4150-8005-cdc406a43310', 'OBJECT2', '', 'expectationId3');
+
+-- ----------------------------
+-- Records of expectation_target
+-- ----------------------------
+MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id)
+values ('target1-1', 'source', 'expectationId1');
+MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id)
+values ('target1-2', 'destination', 'expectationId1');
+MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id)
+values ('target1-3', 'bandwidth', 'expectationId1');
+MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id)
+values ('target2-1', 'bandwidthAssurance', 'expectationId2');
+MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id)
+values ('target3-1', 'source', 'expectationId3');
+-- ----------------------------
+-- Records of condition
+-- ----------------------------
+MERGE INTO condition (condition_id, condition_name, operator_type, condition_value, parent_id) KEY (condition_id)
+values ('condition1-1', 'condition of the cll service source', 'EQUALTO', 'Company A', 'target1-1');
+MERGE INTO condition (condition_id, condition_name, operator_type, condition_value, parent_id) KEY (condition_id)
+values ('condition1-2', 'condition of the cll service destination', 'EQUALTO', 'Cloud 1', 'target1-2');
+MERGE INTO condition (condition_id, condition_name, operator_type, condition_value, parent_id) KEY (condition_id)
+values ('condition1-3', 'condition of the cll service bandwidth', 'EQUALTO', '1000', 'target1-3');
+MERGE INTO condition (condition_id, condition_name, operator_type, condition_value, parent_id) KEY (condition_id)
+values ('condition2-1', 'condition of the cll service bandwidth', 'EQUALTO', 'true', 'target2-1');
+MERGE INTO condition (condition_id, condition_name, operator_type, condition_value, parent_id) KEY (condition_id)
+values ('condition3-1', 'condition of the cll service source', 'EQUALTO', 'Company A', 'target3-1');
+
+-- ----------------------------
+-- Records of context
+-- ----------------------------
+MERGE INTO context (context_id, context_name, parent_id) KEY (context_id)
+values ('d64f3a5f-b091-40a6-bca0-1bc6b1ce8f43', 'intentContextName', 'intentId1');
+MERGE INTO context (context_id, context_name, parent_id) KEY (context_id)
+values ('72f6c546-f234-4be5-a2fe-5740139e20cb', 'intentContextName', 'intentId2');
+
+-- ----------------------------
+-- Records of fulfilment_info
+-- ----------------------------
+MERGE INTO fulfilment_info (fulfilment_info_id, fulfilment_info_status, not_fulfilled_state, not_fulfilled_reason) KEY (fulfilment_info_id)
+values ('intentId1', 'NOT_FULFILLED', 'COMPLIANT', 'NotFulfilledReason');
+MERGE INTO fulfilment_info (fulfilment_info_id, fulfilment_info_status, not_fulfilled_state, not_fulfilled_reason) KEY (fulfilment_info_id)
+values ('intentId2', 'NOT_FULFILLED', 'COMPLIANT', 'NotFulfilledReason');
-MERGE INTO expectation (expectation_id, expectation_name, target_moi, intent_id)KEY(expectation_id)values ('2234','test-expectation',null, '1234');
diff --git a/intentanalysis/src/test/resources/intentdb-test-init.sql b/intentanalysis/src/test/resources/intentdb-test-init.sql
index b84f8e3..211e1cb 100644
--- a/intentanalysis/src/test/resources/intentdb-test-init.sql
+++ b/intentanalysis/src/test/resources/intentdb-test-init.sql
@@ -14,29 +14,67 @@
Date: 30/12/2019 14:40:23
*/
-DROP TABLE IF EXISTS intent;
-DROP TABLE IF EXISTS expectation;
-DROP TABLE IF EXISTS state;
-
-CREATE TABLE if NOT EXISTS intent(
- intent_id varchar(255),
- intent_name varchar(255),
- CONSTRAINT intent_test_task_pkey PRIMARY KEY (intent_id)
+//CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+
+DROP TABLE IF EXISTS intent;
+DROP TABLE IF EXISTS expectation;
+DROP TABLE IF EXISTS expectation_object;
+DROP TABLE IF EXISTS expectation_target;
+DROP TABLE IF EXISTS context;
+DROP TABLE IF EXISTS fulfilment_info;
+DROP TABLE IF EXISTS condition;
+
+create table if not exists intent
+(
+ intent_id varchar(255) primary key,
+ intent_name varchar(255)
);
-create table if not exists expectation(
- expectation_id varchar(255),
+create table if not exists expectation
+(
+ expectation_id varchar(255) primary key,
expectation_name varchar(255),
- target_moi varchar(255),
- intent_id varchar(255),
- CONSTRAINT expectation_test_task_pkey PRIMARY KEY (expectation_id)
+ expectation_type varchar(255),
+ intent_id varchar(255)
+);
+
+create table if not exists expectation_object
+(
+ object_id varchar(255) DEFAULT random_uuid(),
+ primary key (object_id),
+ object_type varchar(255),
+ object_instance varchar(255),
+ expectation_id varchar(255)
+);
+
+create table if not exists expectation_target
+(
+ target_id varchar(255) primary key,
+ target_name varchar(255),
+ expectation_id varchar(255)
);
-create table if not exists state(
- state_id varchar(255),
- state_name varchar(255),
- is_satisfied boolean,
- condition varchar(255),
- expectation_id varchar(255),
- CONSTRAINT state_test_task_pkey PRIMARY KEY (state_id)
+create table if not exists context
+(
+ context_id varchar(255) primary key,
+ context_name varchar(255),
+ parent_id varchar(255)
);
+
+create table if not exists fulfilment_info
+(
+ fulfilment_info_id varchar(255) primary key,
+ fulfilment_info_status varchar(255),
+ not_fulfilled_state varchar(255),
+ not_fulfilled_reason varchar(255)
+);
+
+create table if not exists condition
+(
+ condition_id varchar(255) primary key,
+ condition_name varchar(255),
+ operator_type varchar(255),
+ condition_value varchar(255),
+ parent_id varchar(255)
+);
+