update ut code 59/133959/1
authorkaixiliu <liukaixi@chinamobile.com>
Fri, 31 Mar 2023 01:17:43 +0000 (09:17 +0800)
committerkaixiliu <liukaixi@chinamobile.com>
Fri, 31 Mar 2023 01:18:00 +0000 (09:18 +0800)
Issue-ID: USECASEUI-785
Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Change-Id: I9c1a1058047116d513fef129bfb03363b24217db

intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunctionTest.java
intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java

index 2f91691..055ac2e 100644 (file)
@@ -121,14 +121,7 @@ public class CLLBusinessIntentManagementFunctionTest {
         cllBusinessIntentManagementFunction.investigation(intentGoalBean);
         Assert.assertTrue(true);
     }
-    @Test
-    public void testImplementIntentCreate() { // TODO: 2023/3/30  
-        LinkedHashMap<IntentGoalBean, IntentManagementFunction> 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<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
index fb30aaa..7c494f7 100644 (file)
@@ -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);