From cd69d6ff83ee0d06683031f04ed71c692b6bffaa Mon Sep 17 00:00:00 2001 From: kaixiliu Date: Fri, 31 Mar 2023 09:17:43 +0800 Subject: update ut code Issue-ID: USECASEUI-785 Signed-off-by: kaixiliu Change-Id: I9c1a1058047116d513fef129bfb03363b24217db --- .../CLLBusinessIntentManagementFunctionTest.java | 9 +----- .../controller/IntentControllerTest.java | 32 +++++++--------------- 2 files changed, 11 insertions(+), 30 deletions(-) (limited to 'intentanalysis/src/test/java/org/onap') diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunctionTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunctionTest.java index 2f91691..055ac2e 100644 --- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunctionTest.java +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunctionTest.java @@ -121,14 +121,7 @@ public class CLLBusinessIntentManagementFunctionTest { cllBusinessIntentManagementFunction.investigation(intentGoalBean); Assert.assertTrue(true); } - @Test - public void testImplementIntentCreate() { // TODO: 2023/3/30 - LinkedHashMap map = new LinkedHashMap<>(); - map.put(intentGoalBean, cllDeliveryIntentManagementFunction); - Mockito.when(decisionModule.intentObjectDefine(any(),any())).thenReturn(intent); - cllBusinessIntentManagementFunction.implementIntent(intent, map); - Assert.assertTrue(true); - } + @Test public void testImplementIntentUpdate() { LinkedHashMap map = new LinkedHashMap<>(); diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java index fb30aaa..7c494f7 100644 --- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java @@ -68,11 +68,8 @@ public class IntentControllerTest { public void testCreateIntent() { Intent intent = new Intent(); intent.setIntentName("cllBussinessIntent"); - IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - Mockito.when(intentProcessService.intentProcess(any())).thenReturn(intentGoalBean); intentController.createIntent(intent); - verify(intentProcessService, times(1)).intentProcess(any()); - verify(intentService, times(1)).createIntent(any()); + verify(formatIntentInputManagementFunction, times(1)).receiveIntentAsOwner(any()); } @@ -81,27 +78,22 @@ public class IntentControllerTest { Intent intent = new Intent(); intent.setIntentName("cllBussinessIntent"); IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - //Mockito.when(intentProcessService.intentProcess(any())).thenReturn(intentGoalBean); - when(intentProcessService.intentProcess(any())).thenThrow(new CommonException("MSG", ResponseConsts.RET_UPDATE_DATA_FAIL)); intentController.createIntent(intent); Assert.assertTrue(true); } - @Test + @Test public void testUpdateIntentById(){ - Intent intent = new Intent(); - intent.setIntentName("cllBussinessIntent"); - IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - - Mockito.when(intentProcessService.intentProcess(any())).thenReturn(intentGoalBean); - intentController.updateIntentById(any(),any()); - verify(intentProcessService, times(1)).intentProcess(any()); - } + Intent intent = new Intent(); + intent.setIntentId("test"); + intent.setIntentName("cllBussinessIntent"); + IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); + intentController.updateIntentById(intent.getIntentId(),intent); + verify(formatIntentInputManagementFunction, times(1)).receiveIntentAsOwner(any()); + } @Test public void testUpdateIntentByIdCommonException() { Intent intent = new Intent(); intent.setIntentName("cllBussinessIntent"); - IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - //Mockito.when(intentProcessService.intentProcess(any())).thenReturn(intentGoalBean); when(intentProcessService.intentProcess(any())).thenThrow(new CommonException("MSG", ResponseConsts.RET_UPDATE_DATA_FAIL)); intentController.updateIntentById(any(),any()); Assert.assertTrue(true); @@ -113,11 +105,8 @@ public class IntentControllerTest { intent.setIntentName("cllBussinessIntent"); String id = "intentId"; IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - - Mockito.when(intentService.getIntent(any())).thenReturn(intent); - Mockito.when(intentProcessService.intentProcess(any())).thenReturn(intentGoalBean); intentController.removeIntentById(id); - verify(intentProcessService, times(1)).intentProcess(any()); + verify(formatIntentInputManagementFunction, times(1)).receiveIntentAsOwner(any()); } @Test @@ -125,7 +114,6 @@ public class IntentControllerTest { Intent intent = new Intent(); intent.setIntentName("cllBussinessIntent"); IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - //Mockito.when(intentProcessService.intentProcess(any())).thenReturn(intentGoalBean); when(intentProcessService.intentProcess(any())).thenThrow(new CommonException("MSG", ResponseConsts.RET_UPDATE_DATA_FAIL)); intentController.removeIntentById("intentId"); Assert.assertTrue(true); -- cgit 1.2.3-korg