Add unit test for vfc-nfvo-wfengine 99/16299/2
authorZhaoxing <meng.zhaoxing1@zte.com.cn>
Thu, 28 Sep 2017 09:04:44 +0000 (17:04 +0800)
committerFu Jinhua <fu.jinhua@zte.com.cn>
Thu, 28 Sep 2017 09:16:41 +0000 (09:16 +0000)
Change-Id: I75acdc20d9aa6ccb650b80d93c675bab7c27dca9
Issue-id:  VFC-454
Signed-off-by: Zhaoxing <meng.zhaoxing1@zte.com.cn>
13 files changed:
wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java
wfenginemgrservice/src/main/java/org/onap/workflow/common/ToolUtil.java
wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java
wfenginemgrservice/src/test/java/org/onap/workflow/common/RestClientTest.java
wfenginemgrservice/src/test/java/org/onap/workflow/common/ToolUtilTest.java [moved from wfenginemgrservice/src/test/java/org/onap/workflow/resources/RestResponseTest.java with 57% similarity]
wfenginemgrservice/src/test/java/org/onap/workflow/resources/ActivitiServiceConsumerTest.java [deleted file]
wfenginemgrservice/src/test/java/org/onap/workflow/resources/EnumModuleUrlTest.java [deleted file]
wfenginemgrservice/src/test/java/org/onap/workflow/resources/RestClientTest.java
wfenginemgrservice/src/test/java/org/onap/workflow/resources/ToolUtilTest.java
wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowAppConfigTest.java [deleted file]
wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowAppTest.java [deleted file]
wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowInstanceWrapperTest.java
wfenginemgrservice/src/test/java/org/onap/workflow/tools/RequestParametersTest.java [moved from wfenginemgrservice/src/test/java/org/onap/workflow/resources/RestClientUtilsTest.java with 53% similarity]

index f179fe6..2eeb2fc 100644 (file)
@@ -124,34 +124,6 @@ public class RestClient {
     return request;
   }
 
-  /**
-   * 
-   * @param ip
-   * @param port
-   * @param url
-   * @return
-   * @throws ClientProtocolException
-   * @throws IOException
-   */
-  public static String get(String ip, int port, String url)
-      throws ClientProtocolException, IOException {
-    return executeHttp(HttpMethod.GET, ip, port, url, null).getResult();
-  }
-
-  /**
-   * 
-   * @param ip
-   * @param port
-   * @param url
-   * @return
-   * @throws ClientProtocolException
-   * @throws IOException
-   */
-  public static RestResponse delete(String ip, int port, String url)
-      throws ClientProtocolException, IOException {
-    return executeHttp(HttpMethod.GET, ip, port, url, null);
-  }
-
   /**
    * 
    * @param ip
index c148eb3..d24a787 100644 (file)
@@ -1,11 +1,11 @@
 /**\r
- * Copyright (C) 2017 ZTE, Inc. and others. All rights reserved. (ZTE)\r
+ * Copyright 2017 ZTE Corporation.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
  *\r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
  *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
@@ -40,18 +40,6 @@ public class ToolUtil {
     return authHeader;\r
   }\r
   \r
-  public static boolean isEmptyString(String val) {\r
-    return ((val == null || "".equals(val)) ? true : false);\r
-  }\r
-\r
-  public static boolean isTrimedEmptyString(String val) {\r
-    return ((val == null || "".equals(val.trim())) ? true : false);\r
-  }\r
-\r
-  public static boolean isTrimedEmptyArray(String[] val) {\r
-    return ((val == null || val.length == 0) ? true : false);\r
-  }\r
-  \r
   /**\r
    * @param ins\r
    */\r
index 017cf35..593f382 100644 (file)
@@ -21,7 +21,6 @@ import java.io.InputStream;
 import javax.ws.rs.core.Response;
 
 import org.apache.http.client.ClientProtocolException;
-import org.glassfish.jersey.client.ClientConfig;
 import org.onap.workflow.common.Config;
 import org.onap.workflow.common.EnumModuleUrl;
 import org.onap.workflow.common.RestClient;
@@ -34,7 +33,6 @@ import org.onap.workflow.tools.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
 import com.google.gson.Gson;
 
 /**
@@ -47,18 +45,6 @@ public class ActivitiServiceConsumer {
   private static final String DEPLOY_BPMNFILE_URL =
       EnumModuleUrl.ACTIVITI.getApiRootDomain() + "/repository/deployments";
 
-  private static IActivitiRestService activitiServiceProxy = null;
-
-  private static IActivitiRestService getActivitiService() {
-    if (activitiServiceProxy == null) {
-      ClientConfig config = new ClientConfig();
-      activitiServiceProxy = ConsumerFactory.createConsumer(
-          EnumModuleUrl.getBaseUrl(EnumModuleUrl.ACTIVITI), config, IActivitiRestService.class);
-
-    }
-    return activitiServiceProxy;
-  }
-
   public static RestResponse undeploybpmnfile(String deploymentId) {
     /*
      * IActivitiRestService activitiProxy = getActivitiService();
index 27c3ddc..418cff6 100644 (file)
@@ -24,13 +24,10 @@ import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
-import org.onap.workflow.common.RestClient;
 import org.onap.workflow.common.RestClient.HttpMethod;
 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
 import org.powermock.api.mockito.PowerMockito;
@@ -52,6 +49,7 @@ public class RestClientTest {
   @After
   public void tearDown() throws Exception {}
 
+  @SuppressWarnings("static-access")
   @Test
   public final void testExecuteHttp() throws Exception {
     HttpEntity httpEntity = mock(HttpEntity.class);
@@ -67,6 +65,7 @@ public class RestClientTest {
     restClient.executeHttp(HttpMethod.POST, "127.0.0.1", 80, "test", httpEntity);
   }
 
+  @SuppressWarnings("static-access")
   @Test
   public final void testExecuteHttpDeleteDeploy() throws Exception {
     HttpEntity httpEntity = mock(HttpEntity.class);
@@ -80,6 +79,7 @@ public class RestClientTest {
     restClient.executeHttpDeleteDeploy(HttpMethod.DELETE, "127.0.0.1", 80, "test");
   }
 
+  @SuppressWarnings("static-access")
   @Test
   public final void testExecuteHttpStartIntance() throws Exception {
 
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.onap.workflow.common;
 
-package org.onap.workflow.resources;
 
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.Assert;
 import org.junit.Test;
 
-public class RestResponseTest {
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {}
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {}
-
-  @Before
-  public void setUp() throws Exception {}
-
-  @After
-  public void tearDown() throws Exception {}
-
-
-
+/**
+ * @author 10175158
+ *
+ */
+public class ToolUtilTest {
+  @Test
+  public void testgetHeader() {
+    String actual = "Basic a2VybWl0Omtlcm1pdA==";
+    Assert.assertEquals(actual, ToolUtil.getHeader());
+  }
 }
+
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/ActivitiServiceConsumerTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/ActivitiServiceConsumerTest.java
deleted file mode 100644 (file)
index e2d91f4..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * 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.workflow.resources;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ActivitiServiceConsumerTest {
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {}
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {}
-
-  @Before
-  public void setUp() throws Exception {}
-
-  @After
-  public void tearDown() throws Exception {}
-
-  @Test
-  public void testUndeploybpmnfile() {
-  }
-
-  @Test
-  public void testStartBpmnProcess() {
-  }
-
-  @Test
-  public void testDeleteDeployProcess() {
-  }
-
-  @Test
-  public void testStartProcess() {
-  }
-
-  @Test
-  public void testDeploybpmnfile() {
-  }
-
-}
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/EnumModuleUrlTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/EnumModuleUrlTest.java
deleted file mode 100644 (file)
index 837a8bf..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * 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.workflow.resources;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.workflow.common.EnumModuleUrl;
-
-public class EnumModuleUrlTest {
-
-
-  private EnumModuleUrl enumModuleUrl;
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {}
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {}
-
-  @Before
-  public void setUp() throws Exception {
-  }
-
-  @After
-  public void tearDown() throws Exception {}
-
-  @Test
-  public final void testGetApiRootDomain() {
-   // enumModuleUrl.getApiRootDomain();
-
-  }
-
-  @Test
-  public final void testGetBaseUrl() {
-  //  enumModuleUrl.getApiRootDomain();
-  }
-
-}
index 81d63d5..40f5793 100644 (file)
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onap.workflow.resources;
 
 import static org.powermock.api.mockito.PowerMockito.mock;
@@ -60,6 +59,7 @@ public class RestClientTest {
   @After
   public void tearDown() throws Exception {}
 
+  @SuppressWarnings("static-access")
   @Test
   public final void testExecuteHttp() throws Exception {
     HttpEntity httpEntity = mock(HttpEntity.class);
@@ -73,6 +73,7 @@ public class RestClientTest {
     restClient.executeHttp(HttpMethod.POST, "127.0.0.1", 80, "test", httpEntity);
   }
 
+  @SuppressWarnings("static-access")
   @Test
   public final void testExecuteHttpDeleteDeploy() throws Exception {
     HttpEntity httpEntity = mock(HttpEntity.class);
@@ -86,6 +87,7 @@ public class RestClientTest {
     restClient.executeHttpDeleteDeploy(HttpMethod.DELETE, "127.0.0.1", 80, "test");
   }
 
+  @SuppressWarnings("static-access")
   @Test
   public final void testExecuteHttpStartIntance() throws Exception {
 
index bdc11c1..c479085 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2016-2017 ZTE Corporation.
+ * Copyright 2017 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.onap.workflow.resources;
 
-import static org.junit.Assert.assertTrue;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.Assert;
 import org.junit.Test;
-import org.mockito.InjectMocks;
 import org.onap.workflow.activitiext.common.ToolUtil;
 
 /**
@@ -31,38 +25,26 @@ import org.onap.workflow.activitiext.common.ToolUtil;
  *
  */
 public class ToolUtilTest {
+  @Test
+  public void testIsEmptyString() {
+    Assert.assertEquals(true, ToolUtil.isEmptyString(null));
+    Assert.assertEquals(true, ToolUtil.isEmptyString(""));
+    Assert.assertEquals(false, ToolUtil.isEmptyString("test"));
+  }
 
-  @InjectMocks
-  private ToolUtil toolUtil;
-
-  /**
-   * @throws java.lang.Exception
-   */
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {}
-
-  /**
-   * @throws java.lang.Exception
-   */
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {}
-
-  /**
-   * @throws java.lang.Exception
-   */
-  @Before
-  public void setUp() throws Exception {}
-
-  /**
-   * @throws java.lang.Exception
-   */
-  @After
-  public void tearDown() throws Exception {}
-
-  @SuppressWarnings("static-access")
   @Test
-  public void test() {
-    toolUtil.isEmptyString(null);
+  public void testisTrimedEmptyString() {
+    Assert.assertEquals(true, ToolUtil.isTrimedEmptyString(null));
+    Assert.assertEquals(true, ToolUtil.isTrimedEmptyString(""));
+    Assert.assertEquals(false, ToolUtil.isTrimedEmptyString("test"));
   }
 
+  @Test
+  public void testisTrimedEmptyArray() {
+    String[] originArray = new String[1];
+    originArray[0] = "122";
+    Assert.assertEquals(true, ToolUtil.isTrimedEmptyArray(null));
+    Assert.assertEquals(true, ToolUtil.isTrimedEmptyArray(new String[0]));
+    Assert.assertEquals(false, ToolUtil.isTrimedEmptyArray(originArray));
+  }
 }
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowAppConfigTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowAppConfigTest.java
deleted file mode 100644 (file)
index 4a523d9..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * 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.workflow.resources;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.workflow.entity.MsbClientConfig;
-
-public class WorkflowAppConfigTest {
-
-  private MsbClientConfig msbClientConfig;
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {}
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {}
-
-  @Before
-  public void setUp() throws Exception {
-    msbClientConfig = new MsbClientConfig();
-  }
-
-  @After
-  public void tearDown() throws Exception {}
-
-  @Test
-  public final void testGetMsbClientConfig() {
-    msbClientConfig.getMsbSvrIp();
-    // assertTrue("true", 1 == 1);
-  }
-
-
-  @Test
-  public final void testSetMsbClientConfig() {
-    msbClientConfig.setMsbSvrIp("127.0.0.1");
-    // assertTrue("true", 1 == 1);
-  }
-
-}
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowAppTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowAppTest.java
deleted file mode 100644 (file)
index 56c5dc6..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * 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.workflow.resources;
-
-import static org.powermock.api.mockito.PowerMockito.mock;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.workflow.WorkflowApp;
-import org.onap.workflow.WorkflowAppConfig;
-
-import io.dropwizard.setup.Environment;
-
-public class WorkflowAppTest {
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {}
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {}
-
-  private WorkflowApp workflowApp;
-  private WorkflowAppConfig workflowAppConfig;
-  private Environment environment;
-
-  @Before
-  public void setUp() throws Exception {
-    workflowAppConfig = mock(WorkflowAppConfig.class);
-    environment = mock(Environment.class);
-    workflowApp = mock(WorkflowApp.class);
-  }
-
-  @After
-  public void tearDown() throws Exception {}
-
-  @Test
-  public void testMain() {
-
-  }
-
-  @Test
-  public void testGetName() {
-    workflowApp.getName();
-  }
-
-  @Test
-  public void testRunWorkflowAppConfigEnvironment() {
-    try {
-      workflowApp.run(workflowAppConfig, environment);
-    } catch (Exception e) {
-
-    }
-  }
-
-}
index 205785b..0d08427 100644 (file)
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onap.workflow.resources;
 
 import static org.powermock.api.mockito.PowerMockito.mock;
@@ -58,14 +57,9 @@ public class WorkflowInstanceWrapperTest {
   @After
   public void tearDown() throws Exception {}
 
-  @Test
-  public final void testGetInstance() {
-    // fail("Not yet implemented"); // TODO
-  }
-
   @Test
   public final void testDeployBpmnFile() throws Exception {
-    
+
     InputStream fileInputStream = mock(InputStream.class);
     FormDataContentDisposition f = mock(FormDataContentDisposition.class);
     String filename = "test";
@@ -80,8 +74,8 @@ public class WorkflowInstanceWrapperTest {
   }
 
   @Test
-  public final void testUndeployBpmnFile() {
-
+  public final void testUndeployBpmnFile() throws Exception {
+    WorkflowInstanceWrapper.getInstance().undeployBpmnFile(null);
   }
 
   @Test
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.onap.workflow.tools;
 
-package org.onap.workflow.resources;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class RestClientUtilsTest {
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {}
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {}
-
-  @Before
-  public void setUp() throws Exception {}
-
-  @After
-  public void tearDown() throws Exception {}
-
+/**
+ *
+ */
+public class RequestParametersTest {
   @Test
-  public void testBuildMultipartRequest() {
-    //fail("Not yet implemented");
+  public void testToString(){
+    RequestParameters result = new RequestParameters();
+    result.toString();
   }
-
 }