summaryrefslogtreecommitdiffstats
path: root/vnf-sdk-function-test/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'vnf-sdk-function-test/src/test/java/org')
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java)7
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java98
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfigurationTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java)26
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java)50
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/TestConfig.java)44
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java79
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java87
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java)10
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java)43
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java)13
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatusTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java)27
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java)23
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java)63
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/CaseRecordTest.java55
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java65
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java51
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultParserTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultParserTest.java)40
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java)23
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/VnfFuncTestResponseHandlerTest.java)47
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/scriptmgr/ScriptManagerTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java)143
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java218
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java68
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/TestGsonUtil.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java)33
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java42
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java62
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java102
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java37
27 files changed, 990 insertions, 566 deletions
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java
index bd46fc7..01e2c0b 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functests;
+package org.onap.vnfsdk.functest;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
import java.io.File;
-import org.junit.Test;
-import org.openo.vnfsdk.functest.FileUtil;
+import static org.junit.Assert.assertTrue;
public class FileUtilTest {
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java
new file mode 100644
index 0000000..86dc566
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.onap.vnfsdk.functest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
+import org.onap.vnfsdk.functest.externalservice.entity.EnvironmentMap;
+
+import java.util.UUID;
+
+public class TaskExecutionTest {
+
+ private TaskExecution testExecution = null;
+ private Environment functestEnv = null;
+
+ private String dirPath = "src\\test\\resources\\RobotScript";
+ private UUID UUIDEnv = UUID.randomUUID();
+ private UUID UUIDUpload = UUID.randomUUID();
+ private UUID uniqueKey = UUID.randomUUID();
+ private String remoteIP = "192.168.4.47";
+ private String userName = "root";
+ private String password = "root123";
+ private String path = "src\\test\\resources";
+ private UUID envId = UUID.randomUUID();
+ private UUID executeId = UUID.randomUUID();
+
+ @Before
+ public void setUp() {
+ testExecution = new TaskExecution();
+ functestEnv = new Environment();
+ }
+
+ @Test
+ public void testExecuteScript() {
+ try {
+ testExecution.executeScript(dirPath, uniqueKey);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testExecuteRobotScript() {
+ new MockUp<EnvironmentMap>() {
+ @Mock
+ public synchronized Environment getEnv(UUID uuid) {
+ functestEnv.setRemoteIp(remoteIP);
+ functestEnv.setUserName(userName);
+ functestEnv.setPassword(password);
+ functestEnv.setPath(path);
+ return functestEnv;
+ }
+ };
+ try {
+ testExecution.executeRobotScript(envId, executeId);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUploadScript() {
+ new MockUp<EnvironmentMap>() {
+ @Mock
+ public synchronized Environment getEnv(UUID uuid) {
+ functestEnv.setRemoteIp(remoteIP);
+ functestEnv.setUserName(userName);
+ functestEnv.setPassword(password);
+ functestEnv.setPath(path);
+ return functestEnv;
+ }
+ };
+ try {
+ testExecution.uploadScript(dirPath, UUIDEnv, UUIDUpload);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+}
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/onap/vnfsdk/functest/VnfSdkFuncTestAppConfigurationTest.java
index b9e2786..b727e35 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfigurationTest.java
@@ -14,29 +14,25 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functests;
-
-import org.junit.Test;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
+package org.onap.vnfsdk.functest;
import io.dropwizard.db.DataSourceFactory;
+import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class VnfSdkFuncTestAppConfigurationTest {
-
+
@Test
public void vnfSdkFuncTestBean() {
VnfSdkFuncTestAppConfiguration vnfSdkBean = new VnfSdkFuncTestAppConfiguration();
- vnfSdkBean.setTemplate( "" );
- vnfSdkBean.setMsbServerAddr( "127.0.0.1" );
- vnfSdkBean.setServiceIp( "127.0.0.1" );
- vnfSdkBean.setDataSourceFactory( new DataSourceFactory() );
-
- assertNotNull( vnfSdkBean );
- assertNotNull( vnfSdkBean.getTemplate() );
- assertNotNull( vnfSdkBean .getMsbServerAddr() );
- assertNotNull( vnfSdkBean.getServiceIp() );
- assertNotNull( vnfSdkBean.getDataSourceFactory() );
+ vnfSdkBean.setTemplate("");
+ vnfSdkBean.setServiceIp("127.0.0.1");
+ vnfSdkBean.setDataSourceFactory(new DataSourceFactory());
+
+ assertNotNull(vnfSdkBean);
+ assertNotNull(vnfSdkBean.getTemplate());
+ assertNotNull(vnfSdkBean.getServiceIp());
+ assertNotNull(vnfSdkBean.getDataSourceFactory());
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppTest.java
index 883ed61..684f8a3 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppTest.java
@@ -14,71 +14,47 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functests;
-
-import org.junit.Test;
-
-import org.openo.vnfsdk.functest.VnfSdkFuncTestApp;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
-import org.openo.vnfsdk.functest.common.Config;
-import org.openo.vnfsdk.functest.common.ServiceRegistration;
+package org.onap.vnfsdk.functest;
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
-
-import static org.junit.Assert.assertNotNull;
-
import org.junit.Before;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.common.Config;
-import java.lang.reflect.Method;
+import static org.junit.Assert.assertNotNull;
public class VnfSdkFuncTestAppTest {
private VnfSdkFuncTestApp vnfSdkFuncTestApp;
private Environment environment;
-
+
private Application<VnfSdkFuncTestAppConfiguration> vnfsdkFuncApp;
-
+
@Before
public void setUp() {
- vnfsdkFuncApp = new VnfSdkFuncTestApp();
+ vnfsdkFuncApp = new VnfSdkFuncTestApp();
}
-
+
@Test
public void RunApp() {
try {
VnfSdkFuncTestAppConfiguration oConfig = new VnfSdkFuncTestAppConfiguration();
- oConfig.setMsbServerAddr("http://127.0.0.1");
Config.setConfigration(oConfig);
- Thread registerExtsysService = new Thread(new ServiceRegistration());
- registerExtsysService.setName("Register vnfsdk-functionTest service to Microservice Bus");
- registerExtsysService.start();
- } catch(Exception e) {
+ } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
- @Test
- public void testGetName() {
- assertNotNull( vnfsdkFuncApp.getName() );
- }
-
+
@Test
- public void tesInitService() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
- try {
- VnfSdkFuncTestApp vnfsdkTest = new VnfSdkFuncTestApp();
- Method method = VnfSdkFuncTestApp.class.getDeclaredMethod( "initService" );
- method.setAccessible(true);
- method.invoke( vnfsdkTest );
- } catch( Exception e ) {
- e.printStackTrace();
- }
+ public void testGetName() {
+ assertNotNull(vnfsdkFuncApp.getName());
}
-
+
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/TestConfig.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java
index c2a33ab..132fdf8 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/TestConfig.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java
@@ -14,35 +14,31 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.common;
+package org.onap.vnfsdk.functest.common;
+import io.dropwizard.db.DataSourceFactory;
import org.junit.Before;
import org.junit.Test;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
-
-import io.dropwizard.db.DataSourceFactory;
-
-import org.openo.vnfsdk.functest.common.Config;
+import org.onap.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
import static org.junit.Assert.assertNotNull;
public class TestConfig {
-
- private VnfSdkFuncTestAppConfiguration vnfSdkBean;
-
- @Before
- public void setUp() {
- vnfSdkBean = new VnfSdkFuncTestAppConfiguration();
- }
-
- @Test
- public void testVnfSdkConfigBean() {
- vnfSdkBean.setTemplate( "" );
- vnfSdkBean.setMsbServerAddr( "127.0.0.1" );
- vnfSdkBean.setServiceIp( "127.0.0.1" );
- vnfSdkBean.setDataSourceFactory( new DataSourceFactory() );
-
- Config.setConfigration( vnfSdkBean );
- assertNotNull( Config.getConfigration() );
- }
+
+ private VnfSdkFuncTestAppConfiguration vnfSdkBean;
+
+ @Before
+ public void setUp() {
+ vnfSdkBean = new VnfSdkFuncTestAppConfiguration();
+ }
+
+ @Test
+ public void testVnfSdkConfigBean() {
+ vnfSdkBean.setTemplate("");
+ vnfSdkBean.setServiceIp("127.0.0.1");
+ vnfSdkBean.setDataSourceFactory(new DataSourceFactory());
+
+ Config.setConfigration(vnfSdkBean);
+ assertNotNull(Config.getConfigration());
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java
new file mode 100644
index 0000000..11e7f07
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * 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.onap.vnfsdk.functest.db;
+
+import io.dropwizard.testing.junit.DAOTestRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+
+import javax.persistence.PersistenceException;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TaskMgrCaseTblDAOTest {
+
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(CaseRecord.class)
+ .build();
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String funcID = "";
+ private String testID = "INTEL";
+ private String testResult = "SUCCESS";
+ private String testDescription = "";
+ private TaskMgrCaseTblDAO taskMgrCaseTblDAO;
+
+ @Before
+ public void setUp() throws Exception {
+ taskMgrCaseTblDAO = new TaskMgrCaseTblDAO(daoTestRule.getSessionFactory());
+ }
+
+ @Test
+ public void testSaveOrUpdate() {
+ final CaseRecord caseRecord = daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ assertThat(caseRecord.getTaskID()).isEqualTo("c0a1a373-8635-484d-bc6c-307a606cb8a1");
+ assertThat(caseRecord.getTestID()).isEqualTo("INTEL");
+ assertThat(caseRecord.getTestResult()).isEqualTo("SUCCESS");
+ assertThat(taskMgrCaseTblDAO.findByTaskID(caseRecord.getTaskID()).equals(caseRecord));
+ }
+
+ @Test
+ public void findAll() {
+ daoTestRule.inTransaction(() -> {
+ taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription));
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a2";
+ testResult = "NOT FOUND";
+ taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription));
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a3";
+ testResult = "FAILURE";
+ taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription));
+ });
+
+ final List<CaseRecord> caseRecordList = taskMgrCaseTblDAO.findAll();
+ assertThat(caseRecordList).extracting("taskID").containsOnly("c0a1a373-8635-484d-bc6c-307a606cb8a1", "c0a1a373-8635-484d-bc6c-307a606cb8a2", "c0a1a373-8635-484d-bc6c-307a606cb8a3");
+ assertThat(caseRecordList).extracting("testResult").containsOnly("SUCCESS", "NOT FOUND", "FAILURE");
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void handlesNullTaskID() {
+ testID = null;
+ daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java
new file mode 100644
index 0000000..e6ff003
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * 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.onap.vnfsdk.functest.db;
+
+import io.dropwizard.testing.junit.DAOTestRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+
+import javax.persistence.PersistenceException;
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TaskMgrTaskTblDAOTest {
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(TaskRecord.class)
+ .build();
+ private String packageID = "1234567890";
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String envID = "0034b3f3-caea-4138-b186-e260a0cc509c";
+ private String uploadID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String operID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String funcID = "";
+ private String status = "CREATED";
+ private String operFinished = "True";
+ private String operResult = "SUCCESS";
+ private String operResultMessage = "";
+ private TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+
+ @Before
+ public void setUp() throws Exception {
+ taskMgrTaskTblDAO = new TaskMgrTaskTblDAO(daoTestRule.getSessionFactory());
+ }
+
+ @Test
+ public void testSaveOrUpdate() {
+ final TaskRecord taskRecord = daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ assertThat(taskRecord.getTaskID()).isEqualTo("c0a1a373-8635-484d-bc6c-307a606cb8a1");
+ assertThat(taskRecord.getStatus()).isEqualTo("CREATED");
+ assertThat(taskRecord.getOperResult()).isEqualTo("SUCCESS");
+ assertThat(taskMgrTaskTblDAO.findByPackageID(taskRecord.getPackageID())).isEqualTo(Optional.of(taskRecord));
+ assertThat(taskMgrTaskTblDAO.findByTaskID(taskRecord.getTaskID()).get(0).equals(taskRecord));
+ }
+
+ @Test
+ public void findAll() {
+ daoTestRule.inTransaction(() -> {
+ taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage));
+ packageID = "1234567891";
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a2";
+ status = "NOT FOUND";
+ taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage));
+ packageID = "1234567892";
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a3";
+ status = "DONE";
+ taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage));
+ });
+
+ final List<TaskRecord> taskRecordList = taskMgrTaskTblDAO.findAll();
+ assertThat(taskRecordList).extracting("taskID").containsOnly("c0a1a373-8635-484d-bc6c-307a606cb8a1", "c0a1a373-8635-484d-bc6c-307a606cb8a2", "c0a1a373-8635-484d-bc6c-307a606cb8a3");
+ assertThat(taskRecordList).extracting("status").containsOnly("CREATED", "NOT FOUND", "DONE");
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void handlesNullTaskID() {
+ taskID = null;
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
index 0ca9cc7..887171b 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
import java.util.UUID;
-import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
public class EnvironmentMapTest {
@@ -38,11 +38,11 @@ public class EnvironmentMapTest {
@Test
public void testAddEnv() {
- EnvironmentMap.getInstance().addEnv( uuid, new Environment() );
+ EnvironmentMap.getInstance().addEnv(uuid, new Environment());
}
@Test
public void testDelEnv() {
- EnvironmentMap.getInstance().delEnv( uuid );
+ EnvironmentMap.getInstance().delEnv(uuid);
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
index 2dcb7a3..61ae077 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
@@ -14,31 +14,32 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
+
import static org.junit.Assert.assertNotNull;
public class EnvironmentTest {
- private Environment environment = null;
-
- @Before
- public void setUp() {
- environment = new Environment();
- }
-
- @Test
- public void testEnvironment() {
- environment.setRemoteIp( "192.168.4.47" );
- environment.setUserName( "root" );
- environment.setPassword( "root123" );
- environment.setPath( "src\\test\\resources" );
-
- assertNotNull( environment );
- assertNotNull( environment.getRemoteIp() );
- assertNotNull( environment.getUserName() );
- assertNotNull( environment.getPassword() );
- assertNotNull( environment.getPath() );
- }
+ private Environment environment = null;
+
+ @Before
+ public void setUp() {
+ environment = new Environment();
+ }
+
+ @Test
+ public void testEnvironment() {
+ environment.setRemoteIp("192.168.4.47");
+ environment.setUserName("root");
+ environment.setPassword("root123");
+ environment.setPath("src\\test\\resources");
+
+ assertNotNull(environment);
+ assertNotNull(environment.getRemoteIp());
+ assertNotNull(environment.getUserName());
+ assertNotNull(environment.getPassword());
+ assertNotNull(environment.getPath());
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java
index 5c19d7a..bbfc3db 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java
@@ -14,19 +14,18 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import javax.ws.rs.core.Response;
-
-import org.junit.Test;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
public class OPerationStatusHandlerTest {
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
index 5696269..37b8d2a 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+
import static org.junit.Assert.assertNotNull;
@@ -33,15 +34,15 @@ public class OperationStatusTest {
@Test
public void testOperationStatus() {
- operationStatus.setoResultCode(operResultCode.SUCCESS);
- operationStatus.setOperResultMessage("success");
- operationStatus.setOperFinished(true);
-
- assertNotNull( operationStatus );
- assertNotNull( operationStatus.getoResultCode() );
- assertNotNull( operationStatus.getoResultCode() );
- assertNotNull( operationStatus.isOperFinished() );
-
- }
-
+ operationStatus.setoResultCode(operResultCode.SUCCESS);
+ operationStatus.setOperResultMessage("success");
+ operationStatus.setOperFinished(true);
+
+ assertNotNull(operationStatus);
+ assertNotNull(operationStatus.getoResultCode());
+ assertNotNull(operationStatus.getoResultCode());
+ assertNotNull(operationStatus.isOperFinished());
+
+ }
+
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
index 9ebf220..24e780f 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
+
import static org.junit.Assert.assertNotNull;
public class ServiceNodeTest {
@@ -28,16 +29,16 @@ public class ServiceNodeTest {
public void setUp() {
serviceNode = new ServiceNode();
}
-
+
@Test
public void testServiceNode() {
- serviceNode.setIp("192.168.4.47");
- serviceNode.setPort("8080");
- serviceNode.setTtl( 10 );
-
- assertNotNull( serviceNode );
- assertNotNull( serviceNode.getIp() );
- assertNotNull( serviceNode.getPort() );
- assertNotNull( serviceNode.getTtl() );
- }
+ serviceNode.setIp("192.168.4.47");
+ serviceNode.setPort("8080");
+ serviceNode.setTtl(10);
+
+ assertNotNull(serviceNode);
+ assertNotNull(serviceNode.getIp());
+ assertNotNull(serviceNode.getPort());
+ assertNotNull(serviceNode.getTtl());
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
index dfaf7ae..493882f 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
@@ -14,15 +14,16 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
+import static org.junit.Assert.assertNotNull;
+
public class ServiceRegisterEntityTest {
private ServiceRegisterEntity serviceRegistry;
@@ -35,33 +36,33 @@ public class ServiceRegisterEntityTest {
}
@Test
- public void ServiceRegisterEntity() {
-
- List<ServiceNode> nodes = new ArrayList<ServiceNode>();
-
- serviceRegistry.setServiceName("nfvo");
- serviceRegistry.setVersion("5.6");
- serviceRegistry.setProtocol("http");
- serviceRegistry.setVisualRange("range");
-
- serviceNode.setIp( "192.168.4.47" );
- serviceNode.setPort( "8080" );
- serviceNode.setTtl( 10 );
- nodes.add( serviceNode );
-
- serviceRegistry.setNodes( nodes );
-
- assertNotNull( serviceRegistry );
- assertNotNull( serviceRegistry.getServiceName() );
- assertNotNull( serviceRegistry.getVersion() );
- assertNotNull( serviceRegistry.getProtocol() );
- assertNotNull( serviceRegistry.getVisualRange() );
- assertNotNull( serviceRegistry.getNodes() );
-
- }
-
- @Test
- public void testSetSingleNode() {
- serviceRegistry.setSingleNode( "192.168.4.47", "8080", 10 );
- }
+ public void ServiceRegisterEntity() {
+
+ List<ServiceNode> nodes = new ArrayList<ServiceNode>();
+
+ serviceRegistry.setServiceName("nfvo");
+ serviceRegistry.setVersion("5.6");
+ serviceRegistry.setProtocol("http");
+ serviceRegistry.setVisualRange("range");
+
+ serviceNode.setIp("192.168.4.47");
+ serviceNode.setPort("8080");
+ serviceNode.setTtl(10);
+ nodes.add(serviceNode);
+
+ serviceRegistry.setNodes(nodes);
+
+ assertNotNull(serviceRegistry);
+ assertNotNull(serviceRegistry.getServiceName());
+ assertNotNull(serviceRegistry.getVersion());
+ assertNotNull(serviceRegistry.getProtocol());
+ assertNotNull(serviceRegistry.getVisualRange());
+ assertNotNull(serviceRegistry.getNodes());
+
+ }
+
+ @Test
+ public void testSetSingleNode() {
+ serviceRegistry.setSingleNode("192.168.4.47", "8080", 10);
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/CaseRecordTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/CaseRecordTest.java
new file mode 100644
index 0000000..49535df
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/CaseRecordTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * 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.onap.vnfsdk.functest.models;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public class CaseRecordTest {
+
+ private CaseRecord caseRecord = null;
+
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String funcID = "";
+ private String testID = "INTEL";
+ private String testResult = "SUCCESS";
+ private String testDescription = "";
+
+ @Before
+ public void setUp() {
+ caseRecord = new CaseRecord();
+ }
+
+ @Test
+ public void testCaseRecord() {
+ caseRecord.setTaskID(taskID);
+ caseRecord.setFuncID(funcID);
+ caseRecord.setTestID(testID);
+ caseRecord.setTestResult(testResult);
+ caseRecord.setTestDescription(testDescription);
+
+ assertNotNull(caseRecord);
+ assertNotNull(caseRecord.getTestID());
+ assertThat(caseRecord.getTestID(), is("INTEL"));
+ assertNotNull(caseRecord.getTestResult(), is("SUCCESS"));
+ assertNotNull(caseRecord.getTestDescription(), is(""));
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java
new file mode 100644
index 0000000..f51a6b5
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * 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.onap.vnfsdk.functest.models;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public class TaskRecordTest {
+
+ private TaskRecord taskRecord = null;
+
+ private String packageID = "1234567890";
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String envID = "0034b3f3-caea-4138-b186-e260a0cc509c";
+ private String uploadID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String operID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String funcID = "";
+ private String status = "CREATED";
+ private String operFinished = "True";
+ private String operResult = "SUCCESS";
+ private String operResultMessage = "";
+
+ @Before
+ public void setUp() {
+ taskRecord = new TaskRecord();
+ }
+
+ @Test
+ public void testTaskRecord() {
+ taskRecord.setPackageID(packageID);
+ taskRecord.setTaskID(taskID);
+ taskRecord.setEnvID(envID);
+ taskRecord.setUploadID(uploadID);
+ taskRecord.setOperID(operID);
+ taskRecord.setFuncID(funcID);
+ taskRecord.setStatus(status);
+ taskRecord.setOperFinished(operFinished);
+ taskRecord.setOperResult(operResult);
+ taskRecord.setOperResultMessage(operResultMessage);
+
+ assertNotNull(taskRecord);
+ assertNotNull(taskRecord.getPackageID());
+ assertThat(taskRecord.getTaskID(), is("c0a1a373-8635-484d-bc6c-307a606cb8a1"));
+ assertNotNull(taskRecord.getOperFinished(), is("True"));
+ assertNotNull(taskRecord.getOperResult(), is("SUCCESS"));
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java
new file mode 100644
index 0000000..e70be84
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * 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.onap.vnfsdk.functest.responsehandler;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.junit.Assert.assertNotNull;
+
+public class TestResultMapTest {
+
+ private UUID uuid = UUID.randomUUID();
+
+ private Map<UUID, TestResult> testResultMap = new HashMap<UUID, TestResult>();
+
+ @Test
+ public void testGetInstance() {
+ assertNotNull(TestResultMap.getInstance());
+ }
+
+ @Test
+ public void testGetTestResultMap() {
+ assertNotNull(TestResultMap.getInstance().getTestResultMap());
+ }
+
+ @Test
+ public void testSetTestResultMap() {
+ TestResult testResult = new TestResult();
+ testResult.setName("INTEL");
+ testResult.setStatus("SUCCESS");
+ testResult.setDescription("INTEL TEST");
+ testResultMap.put(uuid, testResult);
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultParserTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultParserTest.java
index d0be770..2357346 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultParserTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultParserTest.java
@@ -14,19 +14,22 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.responsehandler;
+package org.onap.vnfsdk.functest.responsehandler;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Before;
+import org.junit.Test;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.openo.vnfsdk.functest.responsehandler.TestResultParser;
+import static org.junit.Assert.assertNotNull;
public class TestResultParserTest {
private TestResultParser testResParser = null;
+ private UUID UUIDTask = UUID.randomUUID();
@Before
public void setUp() {
@@ -35,19 +38,22 @@ public class TestResultParserTest {
@Test
public void testPopulateResultList() {
- assertNotNull(testResParser.populateResultList("src/test/resources/sample.xml"));
- }
-
+ assertNotNull(testResParser.populateResultList(UUIDTask.toString(), "src/test/resources/sample.xml"));
+ }
+
@Test
public void testParseResultData() {
- try {
- Class<?> resParser = Class.forName( "TestResultParser" );
- Object serviceRegObj = resParser.newInstance();
- Method m=( ( Class<?> ) serviceRegObj ).getDeclaredMethod( "threadSleep",new Class[]{String.class});
- m.setAccessible( true );
- m.invoke( serviceRegObj,100 );
- } catch( Exception e ) {
- e.printStackTrace();
- }
+ String taskID = "12919afc-5975-4da9-bd41-c050b305262c";
+ String xmlFile = "src/test/resources/sample.xml";
+ List<TestResult> resultData = new ArrayList<>();
+ try {
+ Class<?> resParser = Class.forName("org.onap.vnfsdk.functest.responsehandler.TestResultParser");
+ Object resParserObj = resParser.newInstance();
+ Method m = resParserObj.getClass().getDeclaredMethod("parseResultData", new Class[]{String.class, String.class, List.class});
+ m.setAccessible(true);
+ m.invoke(resParserObj, taskID, xmlFile, resultData);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultTest.java
index 56756d6..d5bd6b0 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultTest.java
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.responsehandler;
+package org.onap.vnfsdk.functest.responsehandler;
import org.junit.Before;
import org.junit.Test;
-import org.openo.vnfsdk.functest.responsehandler.TestResult;
import static org.junit.Assert.assertNotNull;
@@ -30,16 +29,16 @@ public class TestResultTest {
public void setUp() {
testResult = new TestResult();
}
-
+
@Test
public void testResultTest() {
- testResult.setName("Huawei");
- testResult.setDescription("description");
- testResult.setStatus("success");
-
- assertNotNull( testResult );
- assertNotNull( testResult.getName() );
- assertNotNull( testResult.getStatus() );
- assertNotNull( testResult.getDescription() );
- }
+ testResult.setName("Huawei");
+ testResult.setDescription("description");
+ testResult.setStatus("success");
+
+ assertNotNull(testResult);
+ assertNotNull(testResult.getName());
+ assertNotNull(testResult.getStatus());
+ assertNotNull(testResult.getDescription());
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/VnfFuncTestResponseHandlerTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java
index 4b0bbf3..26007e3 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/VnfFuncTestResponseHandlerTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java
@@ -14,34 +14,33 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.responsehandler;
+package org.onap.vnfsdk.functest.responsehandler;
import org.junit.Test;
-import org.openo.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
-
-import static org.junit.Assert.assertNotNull;
import java.lang.reflect.Method;
+import static org.junit.Assert.assertNotNull;
+
public class VnfFuncTestResponseHandlerTest {
-
- private VnfFuncTestResponseHandler vnfSdkFuncHandler;
-
- @Test
- public void testGetInstance() {
- vnfSdkFuncHandler = VnfFuncTestResponseHandler.getInstance();
- assertNotNull( vnfSdkFuncHandler );
- }
-
- @Test
- public void testLoadConfigurations() {
- try {
- Class<?> vnfsdkResHandler = Class.forName( "VnfFuncTestResponseHandler" );
- Object serviceRegObj = vnfsdkResHandler.newInstance();
- Method m=( ( Class<?> ) serviceRegObj ).getDeclaredMethod( "loadConfigurations" );
- m.setAccessible( true );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
+
+ private VnfFuncTestResponseHandler vnfSdkFuncHandler;
+
+ @Test
+ public void testGetInstance() {
+ vnfSdkFuncHandler = VnfFuncTestResponseHandler.getInstance();
+ assertNotNull(vnfSdkFuncHandler);
+ }
+
+ @Test
+ public void testLoadConfigurations() {
+ try {
+ Object vnfFuncTestResponseHandlerObj = VnfFuncTestResponseHandler.getInstance();
+ Method m = vnfFuncTestResponseHandlerObj.getClass().getDeclaredMethod("loadConfigurations");
+ m.setAccessible(true);
+ m.invoke(vnfFuncTestResponseHandlerObj);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
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/onap/vnfsdk/functest/scriptmgr/ScriptManagerTest.java
index 32a03f5..cf77560 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/onap/vnfsdk/functest/scriptmgr/ScriptManagerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,86 +14,56 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.resource;
+package org.onap.vnfsdk.functest.scriptmgr;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import io.dropwizard.testing.junit.DAOTestRule;
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.FileUtil;
+import org.onap.vnfsdk.functest.db.TaskMgrCaseTblDAO;
+import org.onap.vnfsdk.functest.db.TaskMgrTaskTblDAO;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+import org.onap.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
+import org.onap.vnfsdk.functest.util.RestResponseUtil;
+import org.onap.vnfsdk.functest.util.ZipCompressor;
+import javax.ws.rs.core.Response;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
import java.util.UUID;
-import javax.ws.rs.core.Response;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openo.vnfsdk.functest.FileUtil;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
-import org.openo.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
-import org.openo.vnfsdk.functest.util.RestResponseUtil;
-import org.openo.vnfsdk.functest.util.ZipCompressor;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-public class CommonManagerTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
- private CommonManager commonManger;
+public class ScriptManagerTest {
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(TaskRecord.class)
+ .addEntityClass(CaseRecord.class)
+ .build();
+ private ScriptManager scriptManager;
+ private TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+ private TaskMgrCaseTblDAO taskMgrCaseTblDAO;
private String instanceId;
-
- private String funcTestId = "59d1e651-df9f-4008-902f-e3b377e6ec30";
-
+ private UUID taskID = UUID.fromString("59d1e651-df9f-4008-902f-e3b377e6ec30");
+ private UUID envID = UUID.fromString("f5881897-c748-4f6e-9294-92c730faa001");
+ private UUID operID = UUID.fromString("ed058d84-4a42-4c8e-8ecf-90de4c5a8bc8");
private Response response = null;
@Before
public void setUp() {
- commonManger = new CommonManager();
- }
-
- @Test
- public void testexecuteFunc() throws FileNotFoundException {
-
- URL url = Thread.currentThread().getContextClassLoader().getResource("RobotScript");
- String zipFileName = url.getPath() + ".zip";
- try {
- new ZipCompressor(zipFileName).compress(url.getPath());
- } catch(IOException e) {
-
- }
-
- InputStream mockInputStream = new FileInputStream(zipFileName);
- Response response = commonManger.executeFuncTest(mockInputStream);
- instanceId = response.getEntity().toString();
- assertNotNull(instanceId);
- }
-
- @Test
- public void testQueryResultWhenInstanceIdPresent() {
-
- Map<String, String> mapConfigValues = new HashMap<String, String>();
- String resultFolder = "59d1e651-df9f-4008-902f-e3b377e6ec30";
- URL url = Thread.currentThread().getContextClassLoader().getResource(resultFolder);
- File file = new File(url.getPath());
- File parentFile = file.getParentFile();
- mapConfigValues.put("DIR_RESULT", parentFile.getAbsolutePath());
- VnfFuncTestResponseHandler.getInstance().setConfigMap(mapConfigValues);
- Response response = commonManger.queryResultByFuncTest(resultFolder);
- assertNotNull(response);
- }
-
- @Test
- public void testQueryResultWhenInstanceIdAbsent() {
- Response response = commonManger.queryResultByFuncTest(funcTestId);
- assertNotNull(response);
+ taskMgrTaskTblDAO = new TaskMgrTaskTblDAO(daoTestRule.getSessionFactory());
+ taskMgrCaseTblDAO = new TaskMgrCaseTblDAO(daoTestRule.getSessionFactory());
+ scriptManager = new ScriptManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO);
}
@Test
@@ -113,10 +83,9 @@ public class CommonManagerTest {
try {
// InputStream mockInputStream = new FileInputStream(zipFileName);
- response = commonManger.uploadFuncTestPackage(funcTestId, zipFileName);
- assertNotNull(response);
- assertEquals(200, response.getStatus());
- } catch(Exception e) {
+ UUID uploadID = scriptManager.uploadFuncTestPackage(taskID, envID, zipFileName);
+ assertNotNull(uploadID);
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -124,35 +93,35 @@ public class CommonManagerTest {
@Test
public void testGetOperationResult() {
try {
- response = commonManger.getOperationResult(funcTestId);
+ response = scriptManager.getOperationResult(operID);
assertNotNull(response);
assertEquals(200, response.getStatus());
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testDownloadResults() {
- new MockUp<OperationStatusHandler>() {
+ MockUp<OperationStatusHandler> mockOperationStatusHandler = new MockUp<OperationStatusHandler>() {
@Mock
public Response getOperationStatus(UUID uuid) {
OperationStatus operstatus = new OperationStatus();
operstatus.setOperFinished(true);
- operstatus.setoResultCode(operResultCode.SUCCESS);
+ operstatus.setoResultCode(OperationStatus.operResultCode.SUCCESS);
operstatus.setOperResultMessage("finished");
return response;
}
};
- new MockUp<VnfFuncTestResponseHandler>() {
+ MockUp<VnfFuncTestResponseHandler> mockVnfFuncTestResponseHandler = new MockUp<VnfFuncTestResponseHandler>() {
@Mock
- public Response downloadResults(String funcTestId) {
+ public Response downloadResults(String taskID) {
OperationStatus operstatus = new OperationStatus();
operstatus.setOperFinished(true);
- operstatus.setoResultCode(operResultCode.SUCCESS);
+ operstatus.setoResultCode(OperationStatus.operResultCode.SUCCESS);
operstatus.setOperResultMessage("finished");
return RestResponseUtil.getSuccessResponse(operstatus);
@@ -160,12 +129,15 @@ public class CommonManagerTest {
};
try {
- response = commonManger.downloadResults(funcTestId);
+ response = scriptManager.downloadResults(taskID);
assertNotNull(response);
assertEquals(200, response.getStatus());
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
+
+ mockOperationStatusHandler.tearDown();
+ mockVnfFuncTestResponseHandler.tearDown();
}
@Test
@@ -174,11 +146,12 @@ public class CommonManagerTest {
String zipFileName = url.getPath() + ".zip";
try {
+ new ZipCompressor(zipFileName).compress(url.getPath());
InputStream mockInputStream = new FileInputStream(zipFileName);
String chunkFilePath =
- commonManger.storeChunkFileInLocal("src/test/resources", "chunkFileInLocal", mockInputStream);
+ scriptManager.storeChunkFileInLocal("src/test/resources", "chunkFileInLocal", mockInputStream);
assertNotNull(chunkFilePath);
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -189,10 +162,10 @@ public class CommonManagerTest {
String jsonInput =
"{\"remoteIp\":\"192.168.4.47\",\"userName\":\"root\",\"password\":\"root123\", \"path\":\"/src/test/resources\"}";
- response = commonManger.setEnvironment(jsonInput);
- commonManger.executeFunctionTest(funcTestId, response.getEntity().toString(), "robot");
- assertNotNull(response);
- } catch(Exception e) {
+ envID = scriptManager.setEnvironment(jsonInput);
+// scriptManager.executeFunctionTest(taskID.toString(), response.getEntity().toString(), "robot");
+ assertNotNull(envID);
+ } catch (Exception e) {
e.printStackTrace();
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java
new file mode 100644
index 0000000..921a8e0
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * 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.onap.vnfsdk.functest.taskmgr;
+
+import io.dropwizard.testing.junit.DAOTestRule;
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.db.TaskMgrCaseTblDAO;
+import org.onap.vnfsdk.functest.db.TaskMgrTaskTblDAO;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+import org.onap.vnfsdk.functest.scriptmgr.ScriptManager;
+import org.onap.vnfsdk.functest.util.RestResponseUtil;
+
+import javax.ws.rs.core.Response;
+import java.lang.reflect.Method;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class TaskManagerTest {
+
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(TaskRecord.class)
+ .addEntityClass(CaseRecord.class)
+ .build();
+ private TaskManager taskManager;
+ private ScriptManager scriptManager;
+ private TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+ private TaskMgrCaseTblDAO taskMgrCaseTblDAO;
+ private Response response = null;
+ private TaskManager.RequestBody requestBody;
+ private String packageID = "1234567890";
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String envID = "0034b3f3-caea-4138-b186-e260a0cc509c";
+ private String uploadID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String operID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String funcID = "";
+ private String status = "CREATED";
+ private String operFinished = "True";
+ private String operResult = "SUCCESS";
+ private String operResultMessage = "";
+ private String testID = "NOT CREATED";
+ private String testResult = "NULL";
+ private String testDescription = "";
+
+ @Before
+ public void setUp() throws Exception {
+ taskMgrTaskTblDAO = new TaskMgrTaskTblDAO(daoTestRule.getSessionFactory());
+ taskMgrCaseTblDAO = new TaskMgrCaseTblDAO(daoTestRule.getSessionFactory());
+ scriptManager = new ScriptManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO);
+ taskManager = new TaskManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO, scriptManager);
+ requestBody = new TaskManager.RequestBody();
+ requestBody.setPackageID("1234567890");
+ }
+
+ @Test
+ public void testStartOnboardTestingPackageIDAbsentInDB() {
+ new MockUp<ScriptManager>() {
+ @Mock
+ public UUID uploadFuncTestPackage(UUID taskID, UUID envID, String url) {
+ return UUID.randomUUID();
+ }
+ };
+
+ try {
+ response = taskManager.startOnboardTesting(requestBody);
+ assertNotNull(response);
+ assertEquals(201, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStartOnboardTestingPackageIDAlreadyPresentInDB() {
+ try {
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ response = taskManager.startOnboardTesting(requestBody);
+ assertNotNull(response);
+ assertEquals(500, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testQueryTestStatusPresentInDB() {
+ try {
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ response = taskManager.queryTestStatus(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testQueryTestStatusPresentInOperationStatus() {
+ try {
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ UUID operID = UUID.fromString(taskMgrTaskTblDAO.findByTaskID(taskID).get(0).getOperID());
+ OperationStatus operStatus = new OperationStatus();
+ operStatus.setoResultCode(OperationStatus.operResultCode.SUCCESS);
+ operStatus.setOperResultMessage("Execute function test finished");
+ operStatus.setOperFinished(true);
+ OperationStatusHandler.getInstance().setOperStatusMap(operID, operStatus);
+
+ response = taskManager.queryTestStatus(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testQueryTestStatusAbsent() {
+ try {
+ response = taskManager.queryTestStatus(taskID);
+ assertNotNull(response);
+ assertEquals(404, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCollectTaskResultCreated() {
+ try {
+ testID = "INTEL";
+ daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ response = taskManager.collectTaskResult(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCollectTaskResultUncreated() {
+ new MockUp<ScriptManager>() {
+ @Mock
+ public Response downloadResults(UUID taskID) {
+ return RestResponseUtil.getSuccessResponse(null);
+ }
+ };
+ try {
+ daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ response = taskManager.collectTaskResult(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCollectTaskResultAbsent() {
+ try {
+ response = taskManager.collectTaskResult(taskID);
+ assertNotNull(response);
+ assertEquals(404, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testInitOnboardTesting() {
+ TaskRecord taskRecord = new TaskRecord();
+ CaseRecord caseRecord = new CaseRecord();
+
+ try {
+ TaskManager taskManagerObj = new TaskManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO, scriptManager);
+ Method m = taskManagerObj.getClass().getDeclaredMethod("initOnboardTesting", new Class[]{TaskRecord.class, CaseRecord.class, String.class});
+ m.setAccessible(true);
+ m.invoke(taskManagerObj, taskRecord, caseRecord, packageID);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testLoadEnvConfigurations() {
+ try {
+ TaskManager loadEnvConfigurationsObj = new TaskManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO, scriptManager);
+ Method m = loadEnvConfigurationsObj.getClass().getDeclaredMethod("loadEnvConfigurations");
+ m.setAccessible(true);
+ m.invoke(loadEnvConfigurationsObj);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java
new file mode 100644
index 0000000..fcb47dc
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.onap.vnfsdk.functest.util;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
+
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class RestResponseUtilTest {
+
+ private Response response;
+ private Object envObj;
+
+ @Before
+ public void setUp() {
+ envObj = new Environment();
+ ((Environment) envObj).setRemoteIp("192.168.4.47");
+ ((Environment) envObj).setUserName("root");
+ ((Environment) envObj).setPassword("root123");
+ ((Environment) envObj).setPath("src\\test\\resources");
+ }
+
+
+ @Test
+ public void testGetSuccessResponse() {
+ response = RestResponseUtil.getSuccessResponse(envObj);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ }
+
+ @Test
+ public void testGetCreateSussceeResponse() {
+ response = RestResponseUtil.getCreateSuccessResponse(envObj);
+ assertNotNull(response);
+ assertEquals(201, response.getStatus());
+ }
+
+ @Test
+ public void testGetErrorResponse() {
+ response = RestResponseUtil.getErrorResponse(envObj);
+ assertEquals(500, response.getStatus());
+ }
+
+ @Test
+ public void testGetNotFoundResponse() {
+ response = RestResponseUtil.getNotFoundResponse(envObj);
+ assertEquals(404, response.getStatus());
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/TestGsonUtil.java
index a8ada98..04687ca 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/TestGsonUtil.java
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.util;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+package org.onap.vnfsdk.functest.util;
import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
public class TestGsonUtil {
@@ -39,19 +38,19 @@ public class TestGsonUtil {
public void testGetNowTime() {
assertNotNull(GsonUtil.getNowTime());
}
-
+
@Test
public void testObjectToString() {
- try {
- Object envObj = new Environment();
- ( ( Environment ) envObj ).setRemoteIp( "192.168.4.47" );
- ( ( Environment ) envObj ).setUserName( "root" );
- ( ( Environment ) envObj ).setPassword( "root123" );
- ( ( Environment ) envObj ).setPath( "src\\test\\resources" );
-
- assertNotNull( GsonUtil.objectToString( envObj ) );
- } catch( Exception e ) {
- e.printStackTrace();
- }
+ try {
+ Object envObj = new Environment();
+ ((Environment) envObj).setRemoteIp("192.168.4.47");
+ ((Environment) envObj).setUserName("root");
+ ((Environment) envObj).setPassword("root123");
+ ((Environment) envObj).setPath("src\\test\\resources");
+
+ assertNotNull(GsonUtil.objectToString(envObj));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java
deleted file mode 100644
index 8250700..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.functest.externalservice.msb;
-
-import javax.ws.rs.ProcessingException;
-
-import org.junit.Test;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
-import org.openo.vnfsdk.functest.common.Config;
-import org.openo.vnfsdk.functest.externalservice.entity.ServiceRegisterEntity;
-
-public class MicroserviceBusConsumerTest {
-
- @Test
- public void testRegisterService() {
-
- try {
- ServiceRegisterEntity entity = new ServiceRegisterEntity();
- VnfSdkFuncTestAppConfiguration oConfig = new VnfSdkFuncTestAppConfiguration();
- oConfig.setMsbServerAddr("http://127.0.0.1");
- Config.setConfigration(oConfig);
-
- MicroserviceBusConsumer.registerService(entity);
- } catch(ProcessingException e) {
- // Connect to MSB will fail, Connect refused is OK
- }
- }
-}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java
deleted file mode 100644
index b20b10a..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.functest.util;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-import javax.ws.rs.core.Response;
-
-public class RestResponseUtilTest {
-
- private Response response;
- private Object envObj;
-
- @Before
- public void setUp() {
- envObj = new Environment();
- ( ( Environment ) envObj ).setRemoteIp( "192.168.4.47" );
- ( ( Environment ) envObj ).setUserName( "root" );
- ( ( Environment ) envObj ).setPassword( "root123" );
- ( ( Environment ) envObj ).setPath( "src\\test\\resources" );
- }
-
-
- @Test
- public void testGetSuccessResponse() {
- response = RestResponseUtil.getSuccessResponse( envObj ) ;
- assertNotNull( response );
- assertEquals( 200, response.getStatus() );
- }
-
- @Test
- public void testGetCreateSussceeResponse() {
- response = RestResponseUtil.getCreateSussceeResponse( envObj );
- assertNotNull( response );
- assertEquals( 201, response.getStatus() );
- }
-
- @Test
- public void testGetErrorResponse() {
- response = RestResponseUtil.getErrorResponse(envObj );
- assertEquals( 500, response.getStatus() );
- }
-}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java
deleted file mode 100644
index 27d86bf..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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 java.util.UUID;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.openo.vnfsdk.functest.TaskExecution;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
-
-import org.openo.vnfsdk.functest.externalservice.entity.EnvironmentMap;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-public class TaskExecutionTest {
-
- private TaskExecution testExecution = null;
- private Environment functestEnv = null;
-
- private String dirPath = "src\\test\\resources\\RobotScript";
- private UUID UUIDEnv = UUID.randomUUID();
- private UUID UUIDUpload = UUID.randomUUID();
- private UUID uniqueKey = UUID.randomUUID();
- private String remoteIP = "192.168.4.47";
- private String userName = "root";
- private String password = "root123";
- private String path = "src\\test\\resources";
- private UUID envId = UUID.randomUUID();
- private UUID executeId = UUID.randomUUID();
-
- @Before
- public void setUp() {
- testExecution = new TaskExecution();
- functestEnv = new Environment();
- }
-
- @Test
- public void testExecuteScript() {
- try {
- testExecution.executeScript( dirPath, uniqueKey );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExecuteRobotScript() {
- new MockUp<EnvironmentMap>() {
- @Mock
- public synchronized Environment getEnv( UUID uuid ) {
- functestEnv.setRemoteIp( remoteIP );
- functestEnv.setUserName( userName );
- functestEnv.setPassword( password );
- functestEnv.setPath( path );
- return functestEnv;
- }
- };
- try {
- testExecution.executeRobotScript(envId, executeId );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testUploadScript() {
- new MockUp<EnvironmentMap>() {
- @Mock
- public synchronized Environment getEnv( UUID uuid ) {
- functestEnv.setRemoteIp( remoteIP );
- functestEnv.setUserName( userName );
- functestEnv.setPassword( password );
- functestEnv.setPath( path );
- return functestEnv;
- }
- };
- try {
- testExecution.uploadScript( dirPath, UUIDEnv, UUIDUpload );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
-
-}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java
deleted file mode 100644
index fd4906d..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.vnfsdkfunctest.common;
-
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-
-public class ServiceRegistrationTest {
- @Test
- public void testThreadSleep() {
- try {
- Class<?> serviceReg = Class.forName( "ServiceRegistration" );
- Object serviceRegObj = serviceReg.newInstance();
- Method m=( ( Class<?> ) serviceRegObj ).getDeclaredMethod( "threadSleep",new Class[]{String.class});
- m.setAccessible( true );
- m.invoke( serviceRegObj,100 );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
-}