Fix sonarQube issue.

Issue-ID: SDC-2646
Change-Id: Ic426e1cccf50e3db40381896ee50b74e647129ee
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java
index a3f7ca0..ff3e19b 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/pnfd/model/Transformation.java
@@ -27,6 +27,8 @@
 import lombok.Setter;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
 
 /**
  * Represents a transformation from the PNFD transformation descriptor.
@@ -35,6 +37,8 @@
 @Setter
 public class Transformation {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(Transformation.class);
+
     private String name;
     private String description;
     private TransformationBlock block;
@@ -90,7 +94,8 @@
             try {
                 T value = clazz.cast(transformationProperty.get().getValue());
                 return Optional.of(value);
-            } catch (final ClassCastException ignored) {
+            } catch (final ClassCastException e) {
+                LOGGER.warn("Could not get property value.", e);
                 return Optional.empty();
             }
         }
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
index 6f6dd19..f1e0ae5 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
@@ -41,6 +41,18 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jmockit</groupId>
+      <artifactId>jmockit</artifactId>
+      <version>${jmockit.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>${mockito.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <parent>
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java
index b2038a0..3c99646 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java
@@ -81,6 +81,9 @@
      */
     @Override
     protected void executeTransformations() {
+        if (transformationDescription == null) {
+            return;
+        }
         final Set<Transformation> transformationSet = transformationDescription.getTransformationSet();
         if (CollectionUtils.isEmpty(transformationSet)) {
             return;
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
index 6ad04b0..92e1d8f 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
@@ -181,8 +181,9 @@
     private static Optional<String> parseStringAttribute(final String attribute, final Map<String, Object> transformationYaml) {
         try {
             return Optional.of((String) transformationYaml.get(attribute));
-        } catch (final Exception ignore) {
-            LOGGER.warn("Could not parse the String '{}' in transformation '{}'", attribute, transformationYaml.toString());
+        } catch (final Exception e) {
+            LOGGER.warn("Could not parse the String '{}' in transformation '{}'",
+                attribute, transformationYaml.toString(), e);
             return Optional.empty();
         }
     }
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
index be13d77..63a7d89 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/PnfTransformationEngineTest.java
@@ -20,6 +20,8 @@
 package org.openecomp.core.converter.impl.pnfd;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.spy;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,17 +29,24 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import mockit.Deencapsulation;
 import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
+import org.mockito.Mockito;
 import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
 import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
 import org.onap.sdc.tosca.services.YamlUtil;
 import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.converter.impl.pnfd.parser.PnfdCustomNodeTypeBlockParser;
 import org.openecomp.core.converter.pnfd.PnfdTransformationEngine;
+import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
 import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl;
 
 @RunWith(Parameterized.class)
@@ -79,6 +88,25 @@
         assertEquals(expectedResult, result);
     }
 
+    @Test
+    public void testBuildParseBlock() {
+        final PnfdCustomNodeTypeBlockParser blockParser = spy(new PnfdCustomNodeTypeBlockParser(null));
+        final ConversionDefinition conversionDefinition = Mockito.mock(ConversionDefinition.class);
+        final Map<String, Object> stringObjectMap = new HashMap<>();
+        stringObjectMap.put("type", null);
+        stringObjectMap.put("name", null);
+        assertEquals(Optional.empty(), Deencapsulation.invoke(blockParser, "buildParsedBlock",
+            stringObjectMap, stringObjectMap, conversionDefinition));
+    }
+
+    @Test
+    public void testReadDefinition() {
+        final PnfdTransformationEngine engine = spy(
+            new PnfdNodeTemplateTransformationEngine(null, null, "test.txt"));
+        Deencapsulation.invoke(engine, "readDefinition");
+        assertNull(Deencapsulation.getField(engine, "transformationDescription"));
+    }
+
     private String getExpectedResultFor(final String inputFilename) throws IOException {
         try (final InputStream inputStream = getOutputFileResourceCorrespondingTo(inputFilename)) {
             final ServiceTemplate serviceTemplate = toscaExtensionYamlUtil.yamlToObject(inputStream, ServiceTemplate.class);
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
index 2326318..cb901b6 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
@@ -21,6 +21,7 @@
 
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.QUERY;
@@ -28,7 +29,9 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 import org.junit.Test;
 import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
 import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
@@ -51,6 +54,11 @@
         assertConversionDefinition(definitionYaml, conversionDefinition);
     }
 
+    @Test
+    public void shouldReturnEmpty() {
+        assertEquals(Optional.empty(), ConversionDefinitionYamlParser.parse(new HashMap<>()));
+    }
+
     private void assertConversionDefinition(final Map<String, Object> definitionYaml,
             final ConversionDefinition conversionDefinition) {
         assertThat("The conversion definition should have been built"