Sonar issues fix review 39/15439/1
authorTal Gitelman <tg851x@intl.att.com>
Tue, 26 Sep 2017 10:16:05 +0000 (13:16 +0300)
committerTal Gitelman <tg851x@intl.att.com>
Tue, 26 Sep 2017 10:16:05 +0000 (13:16 +0300)
Change-Id: I84eddf5e65403fb617d9d2c32b8818b2b00c381f
Issue-ID:SDC-352
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java
sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java
sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java
sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java

index f78a38b..faabaeb 100644 (file)
@@ -27,13 +27,16 @@ import org.openecomp.sdc.api.IDistributionClient;
 import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
 import org.openecomp.sdc.utils.DistributionActionResultEnum;
 
+/**
+ * 
+ * @author tg851x
+ * This is class used in testing and run locally in the IDE
+ * logging not needed it is monitored through the IDE console.
+ */
 public class AdvanceCallBack extends SimpleCallback{
-       
-       
 
        public AdvanceCallBack(IDistributionClient client) {
                super(client);
-               // TODO Auto-generated constructor stub
        }
        
        @Override
@@ -45,13 +48,11 @@ public class AdvanceCallBack extends SimpleCallback{
     }
     
     protected void saveFile(byte[] bs, String fileName) {
-        try { 
                 String downloadPath = SimpleConfiguration.downloadPath();
-                FileOutputStream fileOuputStream = new FileOutputStream(downloadPath + fileName); 
+       try(FileOutputStream fileOuputStream = new FileOutputStream(downloadPath + fileName);) {
                         fileOuputStream.write(bs);
                         fileOuputStream.close();
         }   catch (IOException e) {
-                       // TODO Auto-generated catch block
                        e.printStackTrace();
                 }  
  }
index 7d79571..5c4c9e2 100644 (file)
@@ -28,50 +28,84 @@ import java.util.List;
  *
  */
 public enum ArtifactTypeEnum {
-       CHEF("CHEF"), PUPPET("PUPPET"), YANG("YANG"), SHELL_SCRIPT("SHELL_SCRIPT"), ICON("ICON"), UNKNOWN("UNKNOWN"), HEAT("HEAT"), DG_XML("DG_XML"), MURANO_PKG("MURANO_PKG"), 
-       HEAT_ENV("HEAT_ENV"), YANG_XML("YANG_XML"), HEAT_VOL("HEAT_VOL"), HEAT_NET("HEAT_NET"), OTHER("OTHER"), WORKFLOW("WORKFLOW"), NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), 
-       TOSCA_TEMPLATE("TOSCA_TEMPLATE"), TOSCA_CSAR("TOSCA_CSAR"), VNF_CATALOG("VNF_CATALOG"), VF_LICENSE("VF_LICENSE"), VENDOR_LICENSE("VENDOR_LICENSE"), 
-       MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), APPC_CONFIG("APPC_CONFIG"), HEAT_NESTED("HEAT_NESTED"), 
-       HEAT_ARTIFACT("HEAT_ARTIFACT"), VF_MODULES_METADATA("VF_MODULES_METADATA"),
-       // DCAE Artifacts
-       DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"), DCAE_EVENT("DCAE_EVENT"), DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), 
-       DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), 
-       DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"),
-       // AAI Artifacts
-       AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"),
-       // MIB artifacts
-       SNMP_POLL ("SNMP_POLL"), SNMP_TRAP("SNMP_TRAP"), GUIDE("GUIDE")
-       ;
 
-       ArtifactTypeEnum(String type) {
-               this.type = type;
-       }
+    CHEF("CHEF"),
+    PUPPET("PUPPET"),
+    YANG("YANG"),
+    SHELL_SCRIPT("SHELL_SCRIPT"),
+    ICON("ICON"),
+    UNKNOWN("UNKNOWN"),
+    HEAT("HEAT"),
+    DG_XML("DG_XML"),
+    MURANO_PKG("MURANO_PKG"),
+    HEAT_ENV("HEAT_ENV"),
+    YANG_XML("YANG_XML"),
+    HEAT_VOL("HEAT_VOL"),
+    HEAT_NET("HEAT_NET"),
+    OTHER("OTHER"),
+    WORKFLOW("WORKFLOW"),
+    NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"),
+    TOSCA_TEMPLATE("TOSCA_TEMPLATE"),
+    TOSCA_CSAR("TOSCA_CSAR"),
+    VNF_CATALOG("VNF_CATALOG"),
+    VF_LICENSE("VF_LICENSE"),
+    VENDOR_LICENSE("VENDOR_LICENSE"),
+    MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"),
+    MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"),
+    APPC_CONFIG("APPC_CONFIG"),
+    HEAT_NESTED("HEAT_NESTED"),
+    HEAT_ARTIFACT("HEAT_ARTIFACT"),
+    VF_MODULES_METADATA("VF_MODULES_METADATA"),
 
-       private String type;
+    // DCAE Artifacts
+    DCAE_TOSCA("DCAE_TOSCA"),
+    DCAE_JSON("DCAE_JSON"),
+    DCAE_POLICY("DCAE_POLICY"),
+    DCAE_DOC("DCAE_DOC"),
+    DCAE_EVENT("DCAE_EVENT"),
+    DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"),
+    DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"),
+    DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"),
+    DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"),
+    DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"),
+    DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"),
 
-       public String getType() {
-               return type;
-       }
+    // AAI Artifacts
+    AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"),
+    AAI_VF_MODEL("AAI_VF_MODEL"),
+    AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"),
+    AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"),
 
-       public void setType(String type) {
-               this.type = type;
-       }
+    // MIB artifacts
+    SNMP_POLL("SNMP_POLL"),
+    SNMP_TRAP("SNMP_TRAP"),
+    GUIDE("GUIDE");
 
-       public static ArtifactTypeEnum findType(final String type) {
-               for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) {
-                       // According to Pavel/Ella
-                       if (ate.getType().equalsIgnoreCase(type)) {
-                               return ate;
-                       }
-               }
-               return null;
-       }
+    ArtifactTypeEnum(String type) {
+        this.type = type;
+    }
 
-       public static List<String> getAllTypes() {
-               List<String> types = new ArrayList<String>();
-               for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) {
-                       types.add(ate.getType());
-               }
-               return types;
-       }
+    private String type;
+
+    public String getType() {
+        return type;
+    }
+
+    public static ArtifactTypeEnum findType(final String type) {
+        for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) {
+            // According to Pavel/Ella
+            if (ate.getType().equalsIgnoreCase(type)) {
+                return ate;
+            }
+        }
+        return null;
+    }
+
+    public static List<String> getAllTypes() {
+        List<String> types = new ArrayList<>();
+        for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) {
+            types.add(ate.getType());
+        }
+        return types;
+    }
 }
index c7345f2..434952b 100644 (file)
@@ -23,40 +23,36 @@ package org.openecomp.test;
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.IOException;
-
 import org.apache.commons.codec.binary.Base64;
 
 public class Decoder {
 
-       public static String encode(byte[] byteArrayToEncode) {
-
-               byte[] bytesEncoded = Base64.encodeBase64(byteArrayToEncode);
-               String strEncoded = new String(bytesEncoded);
-               return strEncoded;
-       }
-
-       public static String decode(String strEncoded) throws IOException {
-
-               byte[] byteDecoded = Base64.decodeBase64(strEncoded);
-               String decoded = new String(byteDecoded);
-
-               return decoded;
-
-       }
-
-       public static String readFileToString(String file) throws IOException {
-
-               BufferedReader reader = new BufferedReader(new FileReader(file));
-               String line = null;
-               StringBuilder stringBuilder = new StringBuilder();
-               String ls = System.getProperty("line.separator");
-
-               while ((line = reader.readLine()) != null) {
-                       stringBuilder.append(line);
-                       stringBuilder.append(ls);
-               }
-               reader.close();
-               return stringBuilder.toString();
-       }
-
+    public static String encode(byte[] byteArrayToEncode) {
+        return new String(Base64.encodeBase64(byteArrayToEncode));
+    }
+
+    public static String decode(String strEncoded) {
+        return new String(Base64.decodeBase64(strEncoded));
+    }
+
+    public static String readFileToString(String file) throws IOException {
+
+        try (FileReader fileReader = new FileReader(file);
+                BufferedReader reader = new BufferedReader(fileReader)) {
+            String line;
+            StringBuilder stringBuilder = new StringBuilder();
+            String ls = System.getProperty("line.separator");
+
+            while ((line = reader.readLine()) != null) {
+                stringBuilder.append(line);
+                stringBuilder.append(ls);
+            }
+            
+            reader.close();
+            fileReader.close();
+            return stringBuilder.toString();
+        } catch (IOException e) {
+            throw new IOException(e);
+        }
+    }
 }
index 98df4d0..0c03bb0 100644 (file)
@@ -44,7 +44,12 @@ import org.openecomp.sdc.utils.ArtifactTypeEnum;
 import org.openecomp.sdc.utils.DistributionActionResultEnum;
 import org.openecomp.sdc.utils.DistributionStatusEnum;
 
-
+/**
+ * 
+ * @author tg851x
+ * This is class used in testing and run locally in the IDE
+ * logging not needed it is monitored through the IDE console.
+ */
 public class SimpleCallback implements INotificationCallback {
        protected IDistributionClient client;
        public List<IArtifactInfo> iArtifactInfo;