diff options
author | zhuguanyu <zhuguanyu5@huawei.com> | 2022-09-01 20:15:30 +0800 |
---|---|---|
committer | zhuguanyu <zhuguanyu5@huawei.com> | 2022-09-06 10:34:47 +0800 |
commit | a822724a4928b19aba349776ac17bdc5c72e8696 (patch) | |
tree | b7a2d89b9562dc71e6e2f9af6ca8b3235700ead9 /intentanalysis/src/test | |
parent | 7a41339ea8a18aa7a93d73c509a74af1ef13f0a7 (diff) |
Add UT to uui services
Issue-ID: USECASEUI-716
Signed-off-by: zhuguanyu <zhuguanyu5@huawei.com>
Change-Id: I5650e9f859cf80d5ac04062fac851a092184f3e0
Diffstat (limited to 'intentanalysis/src/test')
6 files changed, 585 insertions, 6 deletions
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ContextServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ContextServiceTest.java new file mode 100644 index 0000000..9ef0c73 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ContextServiceTest.java @@ -0,0 +1,122 @@ +package org.onap.usecaseui.intentanalysis.service; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests; +import org.onap.usecaseui.intentanalysis.bean.models.Context; +import org.onap.usecaseui.intentanalysis.exception.DataBaseException; +import org.onap.usecaseui.intentanalysis.util.SpringContextUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import org.springframework.test.context.junit4.SpringRunner; + + +@SpringBootTest(classes = IntentAnalysisApplicationTests.class) +@RunWith(SpringRunner.class) +class ContextServiceTest extends AbstractJUnit4SpringContextTests { + + private static final String TEST_INTENT_ID_1 = "intentId1"; + + private static final String TEST_INTENT_ID_2 = "intentId2"; + + private static final String TEST_INTENT_ID_3 = "intent without affiliate"; + + private static final String TEST_EXPECTATION_ID = "expectation without affiliate"; + + private static final String TEST_CONTEXT_ID_1 = "d64f3a5f-b091-40a6-bca0-1bc6b1ce8f43"; + + @Autowired + private ContextService contextService; + + public Context createTestContext(String testName) { + Context context = new Context(); + context.setContextId(testName + "-contextId"); + context.setContextName(testName + "contextName"); + + return context; + } + + public List<Context> createTestContextList(String testName) { + List<Context> contextList = new ArrayList<>(); + contextList.add(createTestContext(testName)); + return contextList; + } + + @BeforeEach + void setUp() { + SpringContextUtil.setApplicationContext(applicationContext); + } + + @Test + void testCreateContextListSuccess() { + List<Context> contextList = createTestContextList("testCreateContextListSuccess"); + + try { + contextService.createContextList(contextList, TEST_INTENT_ID_3); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertNotNull(contextService.getContextList(TEST_INTENT_ID_3)); + } + + @Test + void testCreateContextSuccess() { + Context context = createTestContext("testCreateContextSuccess"); + + try { + contextService.createContext(context, TEST_INTENT_ID_1); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertNotNull(contextService.getContext(context.getContextId())); + } + + @Test + void testDeleteContextSuccess() { + contextService.deleteContext(TEST_CONTEXT_ID_1); + Context context = contextService.getContext(TEST_CONTEXT_ID_1); + Assert.assertNull(context); + } + + @Test + void testUpdateContextListSuccess() { + List<Context> contextList = contextService.getContextList(TEST_INTENT_ID_2); + Context context = contextList.get(0); + context.setContextName("new context name"); + + try { + contextService.updateContextList(contextList, TEST_INTENT_ID_2); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Context contextTmp = contextService.getContextList(TEST_INTENT_ID_2).get(0); + Assert.assertEquals("new context name", contextTmp.getContextName()); + } + + @Test + void testUpdateContextListSuccessToNull() { + List<Context> contextList = createTestContextList("testUpdateContextListSuccess_2"); + + try { + contextService.updateContextList(contextList, TEST_EXPECTATION_ID); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertNotNull(contextService.getContextList(TEST_EXPECTATION_ID)); + } + + @Test + void testGetContextListSuccess() { + List<Context> contextList = contextService.getContextList(TEST_INTENT_ID_1); + Assert.assertNotNull(contextList); + } +}
\ No newline at end of file diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectServiceTest.java new file mode 100644 index 0000000..c7dcee1 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectServiceTest.java @@ -0,0 +1,125 @@ +package org.onap.usecaseui.intentanalysis.service; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType; +import org.onap.usecaseui.intentanalysis.bean.models.Context; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject; +import org.onap.usecaseui.intentanalysis.exception.DataBaseException; +import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests; +import org.onap.usecaseui.intentanalysis.util.SpringContextUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import org.springframework.test.context.junit4.SpringRunner; + +@SpringBootTest(classes = IntentAnalysisApplicationTests.class) +@RunWith(SpringRunner.class) +class ExpectationObjectServiceTest extends AbstractJUnit4SpringContextTests { + + private static final String TEST_EXPECTATION_ID_1 = "expectationId1"; + + private static final String TEST_EXPECTATION_ID_2 = "expectation without affiliate"; + + private static final String TEST_EXPECTATION_ID_3 = "expectationId3"; + + @Autowired + private ExpectationObjectService expectationObjectService; + + public ExpectationObject createTestObject(String testName) { + ExpectationObject expectationObject = new ExpectationObject(); + expectationObject.setObjectType(ObjectType.OBJECT1); + expectationObject.setObjectInstance("true"); + + List<Context> contextList = new ArrayList<>(); + Context context = new Context(); + context.setContextId(testName + "-contextId"); + context.setContextName(testName + "-contextName"); + contextList.add(context); + expectationObject.setObjectContexts(contextList); + + return expectationObject; + } + + @BeforeEach + void setUp() { + SpringContextUtil.setApplicationContext(applicationContext); + } + + @Test + void testCreateExpectationObjectFalse() { + ExpectationObject expectationObject = createTestObject("testCreateExpectationObjectFalse"); + + try { + expectationObjectService.createExpectationObject(expectationObject, TEST_EXPECTATION_ID_1); + } catch (DataBaseException exception) { + exception.printStackTrace(); + String msg = String.format("It already exists an object for the expectation %s, update might work.", TEST_EXPECTATION_ID_1); + Assert.assertEquals(msg, exception.getMessage()); + } + } + + @Test + void testCreateExpectationObjectSuccess() { + ExpectationObject expectationObject = createTestObject("testCreateExpectationObjectSuccess"); + + try { + expectationObjectService.createExpectationObject(expectationObject, TEST_EXPECTATION_ID_2); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + Assert.assertNotNull(expectationObjectService.getExpectationObject(TEST_EXPECTATION_ID_2)); + } + + @Test + void testGetExpectationObjectSuccess() { + ExpectationObject expectationObject = expectationObjectService.getExpectationObject(TEST_EXPECTATION_ID_1); + Assert.assertNotNull(expectationObject); + } + + @Test + void testUpdateExpectationObjectSuccess() { + String testName = "testUpdateExpectationObjectSuccess_1"; + ExpectationObject expectationObject = createTestObject(testName); + + try { + expectationObjectService.updateExpectationObject(expectationObject, TEST_EXPECTATION_ID_1); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + ExpectationObject expectationObjectTmp = expectationObjectService.getExpectationObject(TEST_EXPECTATION_ID_1); + Assert.assertEquals(expectationObjectTmp.getObjectContexts().get(0).getContextName(), testName + "-contextName"); + } + + @Test + void testUpdateExpectationObjectToNullSuccess() { + ExpectationObject expectationObject = new ExpectationObject(); + expectationObject.setObjectType(ObjectType.OBJECT2); + + try { + expectationObjectService.updateExpectationObject(expectationObject, TEST_EXPECTATION_ID_2); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + ExpectationObject expectationObjectUpdated = expectationObjectService.getExpectationObject(TEST_EXPECTATION_ID_2); + Assert.assertNotNull(expectationObjectUpdated); + } + + @Test + void testDeleteExpectationObjectSuccess() { + try { + expectationObjectService.deleteExpectationObject(TEST_EXPECTATION_ID_3); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + ExpectationObject expectationObject = expectationObjectService.getExpectationObject(TEST_EXPECTATION_ID_3); + Assert.assertNull(expectationObject); + } +}
\ No newline at end of file diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java new file mode 100644 index 0000000..265c097 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java @@ -0,0 +1,166 @@ +package org.onap.usecaseui.intentanalysis.service; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType; +import org.onap.usecaseui.intentanalysis.bean.enums.FulfilmentStatus; +import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState; +import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType; +import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType; +import org.onap.usecaseui.intentanalysis.bean.models.Condition; +import org.onap.usecaseui.intentanalysis.bean.models.Expectation; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; +import org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo; +import org.onap.usecaseui.intentanalysis.exception.DataBaseException; +import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests; +import org.onap.usecaseui.intentanalysis.util.SpringContextUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.CollectionUtils; + + +@SpringBootTest(classes = IntentAnalysisApplicationTests.class) +@RunWith(SpringRunner.class) +class ExpectationServiceTest extends AbstractJUnit4SpringContextTests { + + private static final String TEST_INTENT_ID_1 = "intentId1"; + + private static final String TEST_INTENT_ID_2 = "intentId2"; + + private static final String TEST_INTENT_ID_3 = "intent without affiliate"; + + private static final String TEST_EXPECTATION_ID_1 = "expectationId1"; + + private static final String TEST_EXPECTATION_ID_2= "expectationId2"; + + @Autowired + private ExpectationService expectationService; + + public Expectation createTestExpectation(String testName) { + Expectation expectation = new Expectation(); + + ExpectationObject object = new ExpectationObject(); + object.setObjectType(ObjectType.valueOf("OBJECT1")); + object.setObjectInstance("objectInstance"); + + Condition targetCondition = new Condition(); + targetCondition.setConditionId(testName + "-conditionId"); + targetCondition.setConditionName(testName + "conditionName"); + targetCondition.setOperator(OperatorType.valueOf("EQUALTO")); + targetCondition.setConditionValue("conditionValue"); + List<Condition> targetConditionList = new ArrayList<>(); + targetConditionList.add(targetCondition); + + ExpectationTarget target = new ExpectationTarget(); + target.setTargetId(testName + "targetId"); + target.setTargetName(testName + "targetName"); + target.setTargetConditions(targetConditionList); + List<ExpectationTarget> expectationTargetList = new ArrayList<>(); + expectationTargetList.add(target); + + FulfilmentInfo expectationFulfilmentInfo = new FulfilmentInfo(); + expectationFulfilmentInfo.setFulfilmentStatus(FulfilmentStatus.valueOf("NOT_FULFILLED")); + expectationFulfilmentInfo.setNotFulfilledReason("NotFulfilledReason"); + expectationFulfilmentInfo.setNotFulfilledState(NotFulfilledState.valueOf("COMPLIANT")); + + expectation.setExpectationId(testName + "-expectationId"); + expectation.setExpectationName(testName + "expectationName"); + expectation.setExpectationType(ExpectationType.valueOf("DELIVERY")); + expectation.setExpectationObject(object); + expectation.setExpectationTargets(expectationTargetList); + expectation.setExpectationFulfilmentInfo(expectationFulfilmentInfo); + + return expectation; + } + + @BeforeEach + public void setUp() { + SpringContextUtil.setApplicationContext(applicationContext); + } + + @Test + public void testCreateIntentExpectationSuccess() { + Expectation expectation = createTestExpectation("testCreateIntentExpectationSuccess"); + + try { + expectationService.createIntentExpectation(expectation, TEST_INTENT_ID_3); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertNotNull(expectationService.getIntentExpectation(expectation.getExpectationId())); + } + + @Test + public void testCreateIntentExpectationListSuccess() { + List<Expectation> expectationList = new ArrayList<>(); + Expectation expectation = createTestExpectation("testCreateIntentExpectationListSuccess"); + expectationList.add(expectation); + + try { + expectationService.createIntentExpectationList(expectationList, TEST_INTENT_ID_3); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertNotNull(expectationService.getIntentExpectation(expectation.getExpectationId())); + } + + @Test + public void testDeleteIntentExpectationListSuccess() { + try { + expectationService.deleteIntentExpectation(TEST_EXPECTATION_ID_1); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertNull(expectationService.getIntentExpectation(TEST_EXPECTATION_ID_1)); + } + + @Test + public void deleteIntentExpectationSuccess() { + try { + expectationService.deleteIntentExpectationList(TEST_INTENT_ID_2); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertTrue(CollectionUtils.isEmpty(expectationService.getIntentExpectationList(TEST_INTENT_ID_2))); + } + + @Test + public void testUpdateIntentExpectationListSuccess() { + List<Expectation> expectationList = new ArrayList<>(); + Expectation expectation = createTestExpectation("testUpdateIntentExpectationListSuccess"); + expectationList.add(expectation); + + try { + expectationService.updateIntentExpectationList(expectationList, TEST_INTENT_ID_2); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Expectation updatedExpectation = expectationService.getIntentExpectationList(TEST_INTENT_ID_2).get(0); + Assert.assertEquals(updatedExpectation.getExpectationId(), expectation.getExpectationId()); + } + + @Test + public void testGetIntentExpectationListSuccess() { + List<Expectation> expectationList = expectationService.getIntentExpectationList(TEST_INTENT_ID_1); + Assert.assertFalse(CollectionUtils.isEmpty(expectationList)); + } + + @Test + public void testGetIntentExpectationSuccess() { + Expectation expectationGotten = expectationService.getIntentExpectation(TEST_EXPECTATION_ID_2); + Assert.assertNotNull(expectationGotten); + } + +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetServiceTest.java new file mode 100644 index 0000000..f12ac33 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetServiceTest.java @@ -0,0 +1,155 @@ +package org.onap.usecaseui.intentanalysis.service; + +import java.util.ArrayList; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType; +import org.onap.usecaseui.intentanalysis.bean.models.Condition; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; +import org.onap.usecaseui.intentanalysis.exception.DataBaseException; +import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests; +import org.onap.usecaseui.intentanalysis.util.SpringContextUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.CollectionUtils; + +@SpringBootTest(classes = IntentAnalysisApplicationTests.class) +@RunWith(SpringRunner.class) +@Slf4j +class ExpectationTargetServiceTest extends AbstractJUnit4SpringContextTests { + + private static final String TEST_EXPECTATION_ID_1 = "expectation without affiliate"; + + private static final String TEST_EXPECTATION_ID_2 = "expectationId2"; + + private static final String TEST_EXPECTATION_ID_3 = "expectationId3"; + + private static final String TEST_EXPECTATION_ID_4 = "expectationId4"; + + private static final String TEST_TARGET_ID_1 = "target1-1"; + + private static final String TEST_TARGET_ID_2 = "target2-2"; + + @Autowired + private ExpectationTargetService expectationTargetService; + + public ExpectationTarget createTestTarget(String testName) { + ExpectationTarget target = new ExpectationTarget(); + + Condition targetCondition = new Condition(); + targetCondition.setConditionId(testName + "-conditionId"); + targetCondition.setConditionName(testName + "conditionName"); + targetCondition.setOperator(OperatorType.valueOf("EQUALTO")); + targetCondition.setConditionValue("conditionValue"); + List<Condition> targetConditionList = new ArrayList<>(); + targetConditionList.add(targetCondition); + + target.setTargetId(testName + "-targetId"); + target.setTargetName(testName + "targetName"); + target.setTargetConditions(targetConditionList); + + return target; + } + + @BeforeEach + void setUp() { + SpringContextUtil.setApplicationContext(applicationContext); + } + + @Test + void testCreateExpectationTargetSuccess() { + ExpectationTarget expectationTarget = createTestTarget("testCreateExpectationTargetSuccess"); + try { + expectationTargetService.createExpectationTarget(expectationTarget, TEST_EXPECTATION_ID_2); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + List<ExpectationTarget> expectationTargetList = expectationTargetService.getExpectationTargetList( + TEST_EXPECTATION_ID_2); + List<String> targetIdList = new ArrayList<>(); + for (ExpectationTarget target : expectationTargetList) { + targetIdList.add(target.getTargetId()); + } + + Assert.assertTrue(targetIdList.contains(expectationTarget.getTargetId())); + } + + @Test + void testCreateExpectationTargetListSuccess() { + ExpectationTarget expectationTarget = createTestTarget("testCreateExpectationTargetListSuccess"); + List<ExpectationTarget> expectationTargetList = new ArrayList<>(); + expectationTargetList.add(expectationTarget); + + try { + expectationTargetService.createExpectationTargetList(expectationTargetList, TEST_EXPECTATION_ID_4); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + Assert.assertFalse(CollectionUtils.isEmpty(expectationTargetService.getExpectationTargetList( + TEST_EXPECTATION_ID_4))); + } + + @Test + void testGetExpectationTargetListSuccess() { + List<ExpectationTarget> expectationTargetList = expectationTargetService.getExpectationTargetList( + TEST_EXPECTATION_ID_2); + Assert.assertFalse(CollectionUtils.isEmpty(expectationTargetList)); + } + + @Test + void testGetExpectationTargetSuccess() { + ExpectationTarget target = expectationTargetService.getExpectationTarget(TEST_TARGET_ID_1); + Assert.assertNotNull(target); + } + + @Test + void testUpdateExpectationTargetListSuccess() { + ExpectationTarget expectationTarget = createTestTarget("testUpdateExpectationTargetListSuccess"); + List<ExpectationTarget> expectationTargetList = new ArrayList<>(); + expectationTargetList.add(expectationTarget); + + try { + expectationTargetService.updateExpectationTargetList(expectationTargetList, TEST_EXPECTATION_ID_3); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + ExpectationTarget updatedTarget = expectationTargetService.getExpectationTargetList(TEST_EXPECTATION_ID_3).get(0); + Assert.assertEquals(expectationTargetList.get(0).getTargetId(), updatedTarget.getTargetId()); + } + + @Test + void testDeleteExpectationTargetSuccess() { + try { + expectationTargetService.deleteExpectationTarget(TEST_TARGET_ID_2); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + List<ExpectationTarget> expectationTargetList = expectationTargetService.getExpectationTargetList( + TEST_EXPECTATION_ID_2); + for (ExpectationTarget target : expectationTargetList) { + Assert.assertNotEquals(TEST_TARGET_ID_2, target.getTargetId()); + } + } + + @Test + void testDeleteExpectationTargetListSuccess() { + try { + expectationTargetService.deleteExpectationTargetList(TEST_EXPECTATION_ID_1); + } catch (DataBaseException exception) { + exception.printStackTrace(); + } + + List<ExpectationTarget> expectationTargetList = expectationTargetService.getExpectationTargetList( + TEST_EXPECTATION_ID_1); + Assert.assertTrue(CollectionUtils.isEmpty(expectationTargetList)); + } +}
\ No newline at end of file diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java index 9e93b87..ace1683 100644 --- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java @@ -32,19 +32,16 @@ import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject; import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests; import org.onap.usecaseui.intentanalysis.util.SpringContextUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.CollectionUtils; @SpringBootTest(classes = IntentAnalysisApplicationTests.class) @RunWith(SpringRunner.class) 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"; @@ -108,7 +105,7 @@ public class IntentServiceTest extends AbstractJUnit4SpringContextTests { @Test public void testGetIntentListSuccess() { List<Intent> intentList = intentService.getIntentList(); - Assert.assertNotNull(intentList); + Assert.assertFalse(CollectionUtils.isEmpty(intentList)); } @Test @@ -147,7 +144,7 @@ public class IntentServiceTest extends AbstractJUnit4SpringContextTests { expectationTarget.setTargetName("new target name"); List<Condition> targetConditionList = expectationTarget.getTargetConditions(); Condition targetCondition = targetConditionList.get(0); - targetCondition.setConditionName("new conditon name"); + targetCondition.setConditionName("new condition name"); targetConditionList.set(0, targetCondition); expectationTarget.setTargetConditions(targetConditionList); expectationTargetList.remove(2); diff --git a/intentanalysis/src/test/resources/intentdb-test-data.sql b/intentanalysis/src/test/resources/intentdb-test-data.sql index 058e055..c03acd6 100644 --- a/intentanalysis/src/test/resources/intentdb-test-data.sql +++ b/intentanalysis/src/test/resources/intentdb-test-data.sql @@ -22,6 +22,8 @@ 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'); +MERGE INTO intent (intent_id, intent_name) KEY (intent_id) +values ('intent without affiliate', 'CLL Business intent'); -- ---------------------------- -- Records of expectation @@ -32,6 +34,12 @@ MERGE INTO expectation (expectation_id, expectation_name, expectation_type, inte 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'); +MERGE INTO expectation (expectation_id, expectation_name, expectation_type, intent_id) KEY (expectation_id) +values ('expectationId4', 'CLL Service Expectation', 'DELIVERY', 'intentId2'); +MERGE INTO expectation (expectation_id, expectation_name, expectation_type, intent_id) KEY (expectation_id) +values ('expectation without affiliate', 'CLL Assurance Expectation', 'DELIVERY', 'intentId2'); +MERGE INTO expectation (expectation_id, expectation_name, expectation_type, intent_id) KEY (expectation_id) +values ('expectation without affiliate 2', 'CLL Assurance Expectation', 'ASSURANCE', 'intentId2'); -- ---------------------------- -- Records of expectation_object @@ -55,7 +63,13 @@ 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 ('target2-2', 'bandwidthAssurance', 'expectationId2'); +MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id) +values ('target2-3', 'bandwidthAssurance', 'expectationId2'); +MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id) values ('target3-1', 'source', 'expectationId3'); +MERGE INTO expectation_target (target_id, target_name, expectation_id) KEY (target_id) +values ('target4-1', 'source', 'expectationId4'); -- ---------------------------- -- Records of condition |