Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / bpmn / servicedecomposition / SerializationTest.java
index cfafe16..b970b95 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.so.bpmn.servicedecomposition;
 
 import static org.junit.Assert.assertEquals;
-
 import java.io.ByteArrayOutputStream;
 import java.io.Externalizable;
 import java.io.File;
@@ -31,7 +30,6 @@ import java.io.OutputStream;
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
 import org.junit.Test;
@@ -41,50 +39,44 @@ import org.onap.so.bpmn.common.BuildingBlockExecution;
 import org.onap.so.bpmn.common.DelegateExecutionImpl;
 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
-
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class SerializationTest {
-       
-       private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
-       private static final String FLOW_VAR_NAME = "flowToBeCalled";
-       private static final String LOOKUP_KEY_MAP_VAR_NAME = "lookupKeyMap";
-       private static final String GBB_INPUT_VAR_NAME = "gBBInput";
-       protected ObjectMapper mapper = new ObjectMapper();
-       
-       @Test
-       public void testSerializationOfAllPojos() throws IOException {
-               GeneralBuildingBlock gbb = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
-                               GeneralBuildingBlock.class);
-               Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
-               DelegateExecution execution = new ExecutionImpl();
-               execution.setVariable(FLOW_VAR_NAME, "AssignServiceInstanceBB");
-               execution.setVariable(GBB_INPUT_VAR_NAME, gbb);
-               execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap);
-               System.out.println(execution.getVariables());
-               BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution);
-               boolean isSerializable = SerializationTest.isSerializable(gBuildingBlockExecution);
-               assertEquals(true, isSerializable);
-       }
-       
-       public static boolean isSerializable(final Object o)
-    {
+
+    private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+    private static final String FLOW_VAR_NAME = "flowToBeCalled";
+    private static final String LOOKUP_KEY_MAP_VAR_NAME = "lookupKeyMap";
+    private static final String GBB_INPUT_VAR_NAME = "gBBInput";
+    protected ObjectMapper mapper = new ObjectMapper();
+
+    @Test
+    public void testSerializationOfAllPojos() throws IOException {
+        GeneralBuildingBlock gbb = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+                GeneralBuildingBlock.class);
+        Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+        DelegateExecution execution = new ExecutionImpl();
+        execution.setVariable(FLOW_VAR_NAME, "AssignServiceInstanceBB");
+        execution.setVariable(GBB_INPUT_VAR_NAME, gbb);
+        execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap);
+        System.out.println(execution.getVariables());
+        BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution);
+        boolean isSerializable = SerializationTest.isSerializable(gBuildingBlockExecution);
+        assertEquals(true, isSerializable);
+    }
+
+    public static boolean isSerializable(final Object o) {
         final boolean retVal;
 
-        if(implementsInterface(o))
-        {
+        if (implementsInterface(o)) {
             retVal = attemptToSerialize(o);
-        }
-        else
-        {
+        } else {
             retVal = false;
         }
 
         return (retVal);
     }
 
-    private static boolean implementsInterface(final Object o)
-    {
+    private static boolean implementsInterface(final Object o) {
         final boolean retVal;
 
         retVal = ((o instanceof Serializable) || (o instanceof Externalizable));
@@ -92,34 +84,24 @@ public class SerializationTest {
         return (retVal);
     }
 
-    private static boolean attemptToSerialize(final Object o)
-    {
+    private static boolean attemptToSerialize(final Object o) {
         final OutputStream sink;
         ObjectOutputStream stream;
 
         stream = null;
 
-        try
-        {
-            sink   = new ByteArrayOutputStream();
+        try {
+            sink = new ByteArrayOutputStream();
             stream = new ObjectOutputStream(sink);
             stream.writeObject(o);
             // could also re-serilalize at this point too
-        }
-        catch(final IOException ex)
-        {
+        } catch (final IOException ex) {
             return (false);
-        }
-        finally
-        {
-            if(stream != null)
-            {
-                try
-                {
+        } finally {
+            if (stream != null) {
+                try {
                     stream.close();
-                }
-                catch(final IOException ex)
-                {
+                } catch (final IOException ex) {
                     // should not be able to happen
                 }
             }