From c7c7fab17d0ba086d31036fc4395642c24335c56 Mon Sep 17 00:00:00 2001 From: Murali-P Date: Tue, 14 Feb 2017 20:40:25 +0530 Subject: Add/Update new UT Test cases Resolved:VNFSDK-21 Function test base code Change-Id: I74f57856a23ec83fbc5716d6507262a9594df666 Signed-off-by: Murali-P --- .../VnfFuncTestResponseHandler.java | 26 +++++++++---------- .../functest/resource/CommonManagerTest.java | 7 ++++++ .../VnfSdkFuncTestAppConfigurationTest.java | 29 ++++++++++++++++++++++ 3 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java (limited to 'vnf-sdk-function-test') diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java index 8fbf265..eb3174b 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java @@ -34,10 +34,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class VnfFuncTestResponseHandler { private static int actioninProgress = 21; + private static int error = 22; + private static String resultpathkey = "DIR_RESULT"; private static Map mapConfigValues; + private static VnfFuncTestResponseHandler vnfFuncRspHandler; private static final Logger logger = LoggerFactory.getLogger(VnfFuncTestResponseHandler.class); @@ -53,10 +56,13 @@ public class VnfFuncTestResponseHandler { return vnfFuncRspHandler; } + public void setConfigMap(Map inMapConfigValues) { + mapConfigValues = inMapConfigValues; + } + public Response getResponseByFuncTestId(String funcTestId) { - if((null == mapConfigValues) || (null == mapConfigValues.get(resultpathkey))) - { + if((null == mapConfigValues) || (null == mapConfigValues.get(resultpathkey))) { logger.warn("Result Store path not configfured !!!"); return RestResponseUtil.getErrorResponse(error); } @@ -83,30 +89,24 @@ public class VnfFuncTestResponseHandler { // Delete Result folders present if Success !!! // ---------------------------------------------- FileUtil.deleteFile(zipFileName); - FileUtil.deleteDirectory(fileName); + // Later will delete this file..FileUtil.deleteDirectory(fileName); logger.warn("Resquested function Test result Sucess !!!"); return RestResponseUtil.getSuccessResponse(byteArrayFile); - } - else - { + } else { logger.warn("Resquested function Test result Faiuled !!!"); return RestResponseUtil.getErrorResponse(error); } } @SuppressWarnings("unchecked") - private static void loadConfigurations() - { + private static void loadConfigurations() { String curDir = System.getProperty("user.dir"); String confDir = curDir + File.separator + "conf" + File.separator + "robot" + File.separator; ObjectMapper mapper = new ObjectMapper(); - try - { + try { mapConfigValues = mapper.readValue(new FileInputStream(confDir + "robotMetaData.json"), Map.class); - } - catch(IOException e) - { + } catch(IOException e) { logger.error("Reading Json Meta data file failed or file do not exist" + e.getMessage()); return; } diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java index 9336abf..8869ca3 100644 --- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java @@ -22,11 +22,14 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; import javax.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; +import org.openo.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler; public class CommonManagerTest { @@ -49,6 +52,10 @@ public class CommonManagerTest { @Test public void testQueryResultWhenInstanceIdPresent() { + + Map mapConfigValues = new HashMap(); + mapConfigValues.put("DIR_RESULT", ".\\src\\test\\resources"); + VnfFuncTestResponseHandler.getInstance().setConfigMap(mapConfigValues); Response response = commonManger.queryResultByFuncTest("59d1e651-df9f-4008-902f-e3b377e6ec30"); assertNotNull(response); } diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java new file mode 100644 index 0000000..4c06c1f --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2017 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.openo.vnfsdk.functests; + +import org.junit.Test; +import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration; + +public class VnfSdkFuncTestAppConfigurationTest { + + @Test + public void vnfSdkFuncTestBean() { + VnfSdkFuncTestAppConfiguration vnfSdkBean = new VnfSdkFuncTestAppConfiguration(); + } + +} -- cgit 1.2.3-korg