Author: fschumacher
Date: Mon Feb 12 17:48:12 2018
New Revision: 1824045

URL: http://svn.apache.org/viewvc?rev=1824045&view=rev
Log:
Extract duplicate code in helper method

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java

Modified: 
jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java?rev=1824045&r1=1824044&r2=1824045&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java 
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java 
Mon Feb 12 17:48:12 2018
@@ -264,6 +264,13 @@ public class HTMLAssertion extends Abstr
         setProperty(new BooleanProperty(ERRORS_ONLY_KEY, inErrorsOnly));
     }
 
+    private long capToZero(long value) {
+        if (value == Long.MAX_VALUE) {
+            return 0;
+        }
+        return value;
+    }
+
     /**
      * Sets the threshold on error level
      * 
@@ -276,11 +283,7 @@ public class HTMLAssertion extends Abstr
         if (inErrorThreshold < 0L) {
             throw new 
IllegalArgumentException(JMeterUtils.getResString("argument_must_not_be_negative"));
 //$NON-NLS-1$
         }
-        if (inErrorThreshold == Long.MAX_VALUE) {
-            setProperty(new LongProperty(ERROR_THRESHOLD_KEY, 0));
-        } else {
-            setProperty(new LongProperty(ERROR_THRESHOLD_KEY, 
inErrorThreshold));
-        }
+        setProperty(new LongProperty(ERROR_THRESHOLD_KEY, 
capToZero(inErrorThreshold)));
     }
 
     /**
@@ -295,11 +298,7 @@ public class HTMLAssertion extends Abstr
         if (inWarningThreshold < 0L) {
             throw new 
IllegalArgumentException(JMeterUtils.getResString("argument_must_not_be_negative"));
 //$NON-NLS-1$
         }
-        if (inWarningThreshold == Long.MAX_VALUE) {
-            setProperty(new LongProperty(WARNING_THRESHOLD_KEY, 0));
-        } else {
-            setProperty(new LongProperty(WARNING_THRESHOLD_KEY, 
inWarningThreshold));
-        }
+        setProperty(new LongProperty(WARNING_THRESHOLD_KEY, 
capToZero(inWarningThreshold)));
     }
 
     /**


Reply via email to