Unit Test for 'FileCommonUtils'. 49/34449/1
authorYuanHu <yuan.hu1@zte.com.cn>
Wed, 7 Mar 2018 07:36:41 +0000 (15:36 +0800)
committerYuanHu <yuan.hu1@zte.com.cn>
Wed, 7 Mar 2018 07:36:41 +0000 (15:36 +0800)
Test method for FileCommonUtils#readString(String)

Issue-ID: SDC-1078

Change-Id: Ifffe7105b235fda932e1a39b40cafce7d371255f
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
distribution/src/main/assembly/ext-activities.json
sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java

index 8294da6..eae58fc 100644 (file)
           "type": "string",
           "default": "default",
           "required": false,
-          "constraints": [],
           "displayName": {
             "zh_CN": "参数1",
             "en_US": "Param1"
         },
         "param2": {
           "type": "string",
-          "default": "",
           "required": true,
           "displayName": {
             "zh_CN": "参数2",
       "outputs": {
         "out1": {
           "type": "string",
-          "default": "default",
           "required": false,
-          "constraints": [],
           "displayName": {
             "zh_CN": "输出1",
             "en_US": "Output Param 1"
       "produces": "application/json, text/plain",
       "inputs": {
         "param1": {
+          "in": "query",
           "type": "string",
           "default": "default",
           "required": false,
-          "constraints": [],
           "show": false,
           "editable": true
         },
         "param2": {
-          "type": "object",
-          "default": "",
-          "properties": {
-            "a": {
-              "type": "number"
-            },
-            "b": {
-              "type": "string"
-            },
-            "c": {
-              "type": "array",
-              "items": {
+          "in": "body",
+          "schema": {
+            "type": "object",
+            "properties": {
+              "a": {
+                "type": "number",
+                "default": 123
+              },
+              "b": {
                 "type": "string",
-                "enum": [
-                  "a",
-                  "b",
-                  "c"
-                ]
-              }
-            },
-            "d": {
-              "type": "array",
-              "items": {
-                "type": "object",
-                "properties": {
-                  "p1": {
-                    "type": "number"
-                  },
-                  "p2": {
-                    "type": "boolean"
+                "default": "xyz"
+              },
+              "c": {
+                "type": "array",
+                "items": {
+                  "type": "string",
+                  "enum": [
+                    "a",
+                    "b",
+                    "c"
+                  ]
+                }
+              },
+              "d": {
+                "type": "array",
+                "items": {
+                  "type": "object",
+                  "properties": {
+                    "p1": {
+                      "type": "number"
+                    },
+                    "p2": {
+                      "type": "boolean"
+                    }
                   }
                 }
-              }
-            },
-            "y": {
-              "type": "object",
-              "additionalProperties": {
-                "type": "string"
-              }
-            },
-            "z": {
-              "type": "object",
-              "additionalProperties": {
-                "type": "integer"
+              },
+              "y": {
+                "type": "object",
+                "additionalProperties": {
+                  "type": "string"
+                }
+              },
+              "z": {
+                "type": "object",
+                "additionalProperties": {
+                  "type": "integer"
+                }
               }
             }
           },
           "editable": true
         },
         "param3": {
+          "in": "path",
           "type": "string",
           "default": "value3",
           "required": true,
         }
       },
       "outputs": {
-        "out1": {
-          "type": "string",
-          "default": "default",
-          "required": false,
-          "constraints": [],
+        "body": {
           "displayName": {
-            "zh_CN": "输出1",
-            "en_US": "Output Param 1"
+            "zh_CN": "消息体",
+            "en_US": "Message Body"
           },
-          "show": true,
-          "editable": true
+          "schema": {
+            "type": "object",
+            "properties": {
+              "a": {
+                "type": "number"
+              },
+              "b": {
+                "type": "string"
+              },
+              "c": {
+                "type": "array",
+                "items": {
+                  "type": "string",
+                  "enum": [
+                    "a",
+                    "b",
+                    "c"
+                  ]
+                }
+              },
+              "d": {
+                "type": "array",
+                "items": {
+                  "type": "object",
+                  "properties": {
+                    "p1": {
+                      "type": "number"
+                    },
+                    "p2": {
+                      "type": "boolean"
+                    }
+                  }
+                }
+              },
+              "y": {
+                "type": "object",
+                "additionalProperties": {
+                  "type": "string"
+                }
+              },
+              "z": {
+                "type": "object",
+                "additionalProperties": {
+                  "type": "integer"
+                }
+              }
+            }
+          },
+          "editable": false
         }
       }
     }
index b8d4319..9a49b29 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2017 ZTE Corporation.
+ * Copyright (c) 2018 ZTE Corporation.
  * All rights reserved. This program and the accompanying materials
  * are made available under the Apache License, Version 2.0
  * and the Eclipse Public License v1.0 which both accompany this distribution,
@@ -14,6 +14,7 @@ package org.onap.sdc.workflowdesigner.utils;
 
 import static org.junit.Assert.assertEquals;
 
+import java.io.File;
 import java.io.IOException;
 
 import org.junit.After;
@@ -37,9 +38,29 @@ public class FileCommonUtilsTest {
   @After
   public void tearDown() throws Exception {}
 
+  /**
+   * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#readString(String)}
+   * 
+   */
+  @Test
+  public final void readStringString() {
+    String fileName = "src\\test\\resources\\workflow\\template-test.bpmn20.xml";
+    File file = new File(fileName);
+    if (file.exists()) {
+      try {
+        String s = FileCommonUtils.readString(fileName);
+        FileCommonUtils.write("test.xml", s);
+        assertEquals(s.isEmpty(), false);
+      } catch (IOException e) {
+      }
+    }
+  }
+
+
   /**
    * Test method for
-   * {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(String, String)} .
+   * {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(String, String)}
+   * 
    */
   @Test
   public final void writeStringString() {
@@ -57,7 +78,7 @@ public class FileCommonUtilsTest {
   /**
    * Test method for
    * {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#writetoAbsoluteFile(String, String, String)}
-   * .
+   * 
    */
   @Test
   public final void saveFileStringStringString() {