From 2854544959e84613257d6cd29bc4023416db7c87 Mon Sep 17 00:00:00 2001 From: Yulian Han Date: Tue, 6 Mar 2018 15:46:24 +0800 Subject: modify bug for UT case Issue-ID: SO-419 Change-Id: Ibef5e8e617dcfb1d4f9b4087f20d6058a47bd740 Signed-off-by: Yulian Han --- .../apihandlerinfra/E2EServiceInstancesTest.java | 143 +++++++++++++++++++++ 1 file changed, 143 insertions(+) (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra') diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java index 21c59ac6d5..225744e0e7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java @@ -610,4 +610,147 @@ public class E2EServiceInstancesTest { .getE2EServiceInstances("12345", "v3", "123456"); } + + @Test + public void updateE2EServiceInstanceTestNormal() { + new MockUp() { + @Mock + public OperationStatus getOperationStatusByServiceId( + String serviceID) { + OperationStatus operationStatus = new OperationStatus(); + operationStatus.setProgress("100"); + return operationStatus; + } + }; + new MockUp() { + @Mock + private void createOperationStatusRecordForError(Action action, + String requestId) throws MsoDatabaseException { + + } + }; + new MockUp() { + @Mock + public Service getServiceByModelName(String modelName) { + Service svc = new Service(); + return svc; + } + }; + + new MockUp() { + @Mock + public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, + String action) { + ServiceRecipe rec = new ServiceRecipe(); + return rec; + } + }; + + new MockUp() { + @Mock + public RequestClient getRequestClient(String orchestrationURI, + MsoJavaProperties props) throws IllegalStateException { + RequestClient client = new CamundaClient(); + client.setUrl("/test/url"); + return client; + } + }; + + new MockUp() { + @Mock + public HttpResponse post(String requestId, boolean isBaseVfModule, + int recipeTimeout, String requestAction, + String serviceInstanceId, String vnfId, String vfModuleId, + String volumeGroupId, String networkId, String serviceType, + String vnfType, String vfModuleType, String networkType, + String requestDetails, String recipeParamXsd) { + ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); + HttpResponse resp = new BasicHttpResponse(pv, 202, + "test response"); + BasicHttpEntity entity = new BasicHttpEntity(); + String body = "{\"response\":\"success\",\"message\":\"success\"}"; + InputStream instream = new ByteArrayInputStream(body.getBytes()); + entity.setContent(instream); + resp.setEntity(entity); + return resp; + } + }; + + E2EServiceInstances instance = new E2EServiceInstances(); + String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}"; + Response resp = instance.updateE2EServiceInstance(request, "v3", "12345"); + String respStr = resp.getEntity().toString(); + assertTrue(respStr.indexOf("success") != -1); + } + + @Test + public void updateE2EServiceInstanceTestChkStatusFalse() { + new MockUp() { + @Mock + public OperationStatus getOperationStatusByServiceId( + String serviceID) { + OperationStatus operationStatus = new OperationStatus(); + return operationStatus; + } + }; + new MockUp() { + @Mock + private void createOperationStatusRecordForError(Action action, + String requestId) throws MsoDatabaseException { + + } + }; + new MockUp() { + @Mock + public Service getServiceByModelName(String modelName) { + Service svc = new Service(); + return svc; + } + }; + + new MockUp() { + @Mock + public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, + String action) { + ServiceRecipe rec = new ServiceRecipe(); + return rec; + } + }; + + new MockUp() { + @Mock + public RequestClient getRequestClient(String orchestrationURI, + MsoJavaProperties props) throws IllegalStateException { + RequestClient client = new CamundaClient(); + client.setUrl("/test/url"); + return client; + } + }; + + new MockUp() { + @Mock + public HttpResponse post(String requestId, boolean isBaseVfModule, + int recipeTimeout, String requestAction, + String serviceInstanceId, String vnfId, String vfModuleId, + String volumeGroupId, String networkId, String serviceType, + String vnfType, String vfModuleType, String networkType, + String requestDetails, String recipeParamXsd) { + ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); + HttpResponse resp = new BasicHttpResponse(pv, 202, + "test response"); + BasicHttpEntity entity = new BasicHttpEntity(); + String body = "{\"response\":\"success\",\"message\":\"success\"}"; + InputStream instream = new ByteArrayInputStream(body.getBytes()); + entity.setContent(instream); + resp.setEntity(entity); + return resp; + } + }; + + E2EServiceInstances instance = new E2EServiceInstances(); + String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}"; + Response resp = instance.updateE2EServiceInstance(request, "v3", "12345"); + String respStr = resp.getEntity().toString(); + assertTrue(respStr.indexOf("SVC2000") != -1); + } } -- cgit 1.2.3-korg