jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1847975 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java
Date Sun, 02 Dec 2018 11:17:26 GMT
Author: fschumacher
Date: Sun Dec  2 11:17:25 2018
New Revision: 1847975

URL: http://svn.apache.org/viewvc?rev=1847975&view=rev
Log:
Extract code into private methods to make intent clearer

Part of #435 and Bugzilla Id: 62972

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java?rev=1847975&r1=1847974&r2=1847975&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListenerGui.java
Sun Dec  2 11:17:25 2018
@@ -177,39 +177,8 @@ public class BackendListenerGui extends
                 Map<String, String> currArgsMap = currArgs.getArgumentsAsMap();
                 Map<String, String> userArgMap = new HashMap<>();
                 userArgMap.putAll(currArgsMap);
-                Arguments newArgs = new Arguments();
-                Arguments defaultArgs = null;
-                try {
-                    defaultArgs = client.getDefaultParameters();
-                    Arguments currentUserArgs = oldClient.getDefaultParameters();
-                    if(currentUserArgs != null) {
-                        userArgMap.keySet().removeAll(currentUserArgs.getArgumentsAsMap().keySet());
-                    }
-                } catch (AbstractMethodError e) {
-                    log.warn("BackendListenerClient doesn't implement "
-                            + "getDefaultParameters.  Default parameters won't "
-                            + "be shown.  Please update your client class: {}", newClassName);
-                }
-
-                if (defaultArgs != null) {
-                    for (JMeterProperty jMeterProperty : defaultArgs.getArguments()) {
-                        Argument arg = (Argument) jMeterProperty.getObjectValue();
-                        String name = arg.getName();
-                        String value = arg.getValue();
-
-                        // If a user has set parameters in one test, and then
-                        // selects a different test which supports the same
-                        // parameters, those parameters should have the same
-                        // values that they did in the original test.
-                        if (currArgsMap.containsKey(name)) {
-                            String newVal = currArgsMap.get(name);
-                            if (newVal != null && newVal.length() > 0) {
-                                value = newVal;
-                            }
-                        }
-                        newArgs.addArgument(name, value);
-                    }
-                }
+                Arguments defaultArgs = extractDefaultArguments(client, userArgMap, oldClient.getDefaultParameters());
+                Arguments newArgs = copyDefaultArguments(currArgsMap, defaultArgs);
                 userArgMap.forEach(newArgs::addArgument);
 
                 className = newClassName;
@@ -221,6 +190,48 @@ public class BackendListenerGui extends
     }
 
 
+    private Arguments copyDefaultArguments(Map<String, String> currArgsMap, Arguments
defaultArgs) {
+        Arguments newArgs = new Arguments();
+        if (defaultArgs != null) {
+            for (JMeterProperty jMeterProperty : defaultArgs.getArguments()) {
+                Argument arg = (Argument) jMeterProperty.getObjectValue();
+                String name = arg.getName();
+                String value = arg.getValue();
+
+                // If a user has set parameters in one test, and then
+                // selects a different test which supports the same
+                // parameters, those parameters should have the same
+                // values that they did in the original test.
+                if (currArgsMap.containsKey(name)) {
+                    String newVal = currArgsMap.get(name);
+                    if (newVal != null && newVal.length() > 0) {
+                        value = newVal;
+                    }
+                }
+                newArgs.addArgument(name, value);
+            }
+        }
+        return newArgs;
+    }
+
+
+    private Arguments extractDefaultArguments(BackendListenerClient client, Map<String,
String> userArgMap,
+            Arguments currentUserArguments) {
+        Arguments defaultArgs = null;
+        try {
+            defaultArgs = client.getDefaultParameters();
+            if(currentUserArguments != null) {
+                userArgMap.keySet().removeAll(currentUserArguments.getArgumentsAsMap().keySet());
+            }
+        } catch (AbstractMethodError e) {
+            log.warn("BackendListenerClient doesn't implement "
+                    + "getDefaultParameters.  Default parameters won't "
+                    + "be shown.  Please update your client class: {}", client.getClass().getName());
+        }
+        return defaultArgs;
+    }
+
+
     private BackendListenerClient createBackendListenerClient(String newClassName)
             throws ReflectiveOperationException {
         return (BackendListenerClient) Class.forName(newClassName, true,



Mime
View raw message