Make use of lambda 81/33881/1
authorMunir Ahmad <munir.ahmad@bell.ca>
Sat, 3 Mar 2018 00:45:34 +0000 (19:45 -0500)
committerMunir Ahmad <munir.ahmad@bell.ca>
Sat, 3 Mar 2018 00:45:34 +0000 (19:45 -0500)
Change-Id: I3a9d2b98208bd37f2f0e05cbc3628484acdd96ed
Issue-ID: SO-437
Signed-off-by: Munir Ahmad <munir.ahmad@bell.ca>
asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java
bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java
common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java

index f22debc..65c30b8 100644 (file)
@@ -419,38 +419,33 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
                                 toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);\r
                         logger.debug("vfGroups:" + vfGroups.toString());\r
 \r
-                        Collections.sort(vfGroups, new Comparator<org.openecomp.sdc.toscaparser.api.Group>() {\r
-\r
-                            @Override\r
-                            public int compare(org.openecomp.sdc.toscaparser.api.Group group1,\r
-                                    org.openecomp.sdc.toscaparser.api.Group group2) {\r
-\r
-                                // Field name1Field = group1.class.getDeclaredField("name");\r
-                                // name1Field.setAccessible(true);\r
-                                String thisName = group1.getName(); // (String)\r
-                                                                    // name1Field.get(group1);\r
-                                String thatName = group2.getName(); // (String)\r
-                                                                    // name1Field.get(group2);\r
-\r
-                                Matcher m = lastDigit.matcher(thisName);\r
-                                Matcher m2 = lastDigit.matcher(thatName);\r
-\r
-                                String thisDigit = "0";\r
-                                String thatDigit = "0";\r
-                                if(m.find()) {\r
-                                    thisDigit = m.group();\r
-                                } else {\r
-                                    return -1;\r
-                                }\r
-                                if(m2.find()) {\r
-                                    thatDigit = m2.group();\r
-                                } else {\r
-                                    return 1;\r
-                                }\r
+                        Collections.sort(vfGroups, (group1, group2) -> {\r
+\r
+                            // Field name1Field = group1.class.getDeclaredField("name");\r
+                            // name1Field.setAccessible(true);\r
+                            String thisName = group1.getName(); // (String)\r
+                                                                // name1Field.get(group1);\r
+                            String thatName = group2.getName(); // (String)\r
+                                                                // name1Field.get(group2);\r
+\r
+                            Matcher m = lastDigit.matcher(thisName);\r
+                            Matcher m2 = lastDigit.matcher(thatName);\r
+\r
+                            String thisDigit = "0";\r
+                            String thatDigit = "0";\r
+                            if(m.find()) {\r
+                                thisDigit = m.group();\r
+                            } else {\r
+                                return -1;\r
+                            }\r
+                            if(m2.find()) {\r
+                                thatDigit = m2.group();\r
+                            } else {\r
+                                return 1;\r
+                            }\r
 \r
-                                return new Integer(thisDigit).compareTo(new Integer(thatDigit));\r
+                            return new Integer(thisDigit).compareTo(new Integer(thatDigit));\r
 \r
-                            }\r
                         });\r
 \r
                         logger.debug("vfGroupsAfter:" + vfGroups.toString());\r
index 126114d..6983b01 100644 (file)
@@ -44,19 +44,15 @@ public class NotificationLogging implements InvocationHandler {
 
        protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
        
-       private static InvocationHandler handler = new InvocationHandler() {
-               @Override
-               public Object invoke(Object arg0, Method arg1, Object[] arg2)
-                               throws Throwable {
-                       List<Method> methods = objectMethodsToLog.get(arg0);
-                       if ((methods == null) || (methods.isEmpty())) {
-                               // Do nothing for now...
-                               return null;
-                       }
-                       methods.add(arg1);
-                       return arg1.invoke(arg0, arg2);
-               }
-       };
+       private static InvocationHandler handler = (arg0, arg1, arg2) -> {
+        List<Method> methods = objectMethodsToLog.get(arg0);
+        if ((methods == null) || (methods.isEmpty())) {
+            // Do nothing for now...
+            return null;
+        }
+        methods.add(arg1);
+        return arg1.invoke(arg0, arg2);
+    };
        
        public static InvocationHandler getHandler() {
                return handler;
index c346308..07adc3c 100644 (file)
@@ -321,14 +321,8 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin {
                }
 
                private void loadFromDB(DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) {
-                       Command<List<URNMapping>> command = new Command<List<URNMapping>>() {
-                               @SuppressWarnings("unchecked")
-                               @Override
-                               public List<URNMapping> execute(CommandContext commandContext) {
-                                       return (List<URNMapping>) commandContext.getDbSqlSession().selectList(
-                                               "mso.urnMapping.selectAll", null);
-                               }
-                       };
+                       Command<List<URNMapping>> command = commandContext -> (List<URNMapping>) commandContext.getDbSqlSession().selectList(
+                "mso.urnMapping.selectAll", null);
 
                        CustomMyBatisSessionFactory sessionFactory = new CustomMyBatisSessionFactory();
                        sessionFactory.initFromProcessEngineConfiguration(processEngineConfiguration,
index f038cbc..e61da21 100644 (file)
@@ -70,77 +70,68 @@ public class MsoPropertiesFactoryConcurrencyTest {
                msoPropertiesFactory.initializeMsoProperties(MSO_PROP_ID, PATH_MSO_PROP1);
        }
 
-       private Callable<Integer> taskReload = new Callable<Integer>() {
-               @Override
-               public Integer call() {
-                       try {
-                               if (!msoPropertiesFactory.reloadMsoProperties()) {
-                                       return 1;
-                               }
-                       } catch (Exception e) {
-                           e.printStackTrace ();
-                               return 1;
-                       }
-                       return 0;
-               }
-       };
-
-       private Callable<Integer> taskRead = new Callable<Integer>() {
-               @Override
-               public Integer call() {
-                       try {
-                               MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_ID);
-                               String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue");
-                               String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue");
-                               String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue");
-                               String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue");
-                               String property5 = msoProperties.getProperty("does.not.exist", "defaultValue");
-                               String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue");
-                               String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue");
-
-                               assertEquals(property1, "MT");
-                               assertEquals(property2, "http://localhost:5000/v2.0");
-                               assertEquals(property3, "John");
-                               assertEquals(property4, "FD205490A48D48475607C36B9AD902BF");
-                               assertEquals(property5, "defaultValue");
-                               assertEquals(property6, "1234");
-                               assertEquals(property7, "true");
-
-                       } catch (MsoPropertiesException e) {
-                e.printStackTrace ();
-                               return 1;
-                       }
-                       return 0;
-               }
-       };
-
-       private Callable<Integer> taskReadAll = new Callable<Integer>() {
-               @Override
-               public Integer call() {
-                       try {
-                               List<AbstractMsoProperties> msoPropertiesList =  msoPropertiesFactory.getAllMsoProperties();
-                               String property1 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue");
-                               String property2 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue");
-                               String property3 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.msoId", "defaultValue");
-                               String property4 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue");
-                               String property5 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("does.not.exist", "defaultValue");
-                               String property6 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.test", "defaultValue");
-                               String property7 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.boolean", "defaultValue");
-
-                               assertEquals(property1, "MT");
-                               assertEquals(property2, "http://localhost:5000/v2.0");
-                               assertEquals(property3, "John");
-                               assertEquals(property4, "FD205490A48D48475607C36B9AD902BF");
-                               assertEquals(property5, "defaultValue");
-                               assertEquals(property6, "1234");
-                               assertEquals(property7, "true");
-                       } catch (Exception e) {
-                e.printStackTrace ();
-                               return 1;
-                       }
-                       return 0;
-               }
-       };
+       private Callable<Integer> taskReload = () -> {
+        try {
+            if (!msoPropertiesFactory.reloadMsoProperties()) {
+                return 1;
+            }
+        } catch (Exception e) {
+            e.printStackTrace ();
+            return 1;
+        }
+        return 0;
+    };
+
+       private Callable<Integer> taskRead = () -> {
+        try {
+            MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_ID);
+            String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue");
+            String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue");
+            String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue");
+            String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue");
+            String property5 = msoProperties.getProperty("does.not.exist", "defaultValue");
+            String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue");
+            String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue");
+
+            assertEquals(property1, "MT");
+            assertEquals(property2, "http://localhost:5000/v2.0");
+            assertEquals(property3, "John");
+            assertEquals(property4, "FD205490A48D48475607C36B9AD902BF");
+            assertEquals(property5, "defaultValue");
+            assertEquals(property6, "1234");
+            assertEquals(property7, "true");
+
+        } catch (MsoPropertiesException e) {
+e.printStackTrace ();
+            return 1;
+        }
+        return 0;
+    };
+
+       private Callable<Integer> taskReadAll = () -> {
+        try {
+            List<AbstractMsoProperties> msoPropertiesList =  msoPropertiesFactory.getAllMsoProperties();
+            String property1 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue");
+            String property2 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue");
+            String property3 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.msoId", "defaultValue");
+            String property4 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue");
+            String property5 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("does.not.exist", "defaultValue");
+            String property6 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.test", "defaultValue");
+            String property7 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.boolean", "defaultValue");
+
+            assertEquals(property1, "MT");
+            assertEquals(property2, "http://localhost:5000/v2.0");
+            assertEquals(property3, "John");
+            assertEquals(property4, "FD205490A48D48475607C36B9AD902BF");
+            assertEquals(property5, "defaultValue");
+            assertEquals(property6, "1234");
+            assertEquals(property7, "true");
+        } catch (Exception e) {
+e.printStackTrace ();
+            return 1;
+        }
+        return 0;
+    };
 
        @Test
        public final void testGetMsoProperties()