jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1832777 - in /jmeter/trunk: src/core/org/apache/jmeter/testelement/property/MapProperty.java test/src/org/apache/jmeter/testelement/property/MapPropertyTest.java
Date Sun, 03 Jun 2018 16:21:26 GMT
Author: fschumacher
Date: Sun Jun  3 16:21:25 2018
New Revision: 1832777

URL: http://svn.apache.org/viewvc?rev=1832777&view=rev
Log:
Use HashMap#isEmpty instead of size>0

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/testelement/property/MapProperty.java
    jmeter/trunk/test/src/org/apache/jmeter/testelement/property/MapPropertyTest.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/property/MapProperty.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/MapProperty.java?rev=1832777&r1=1832776&r2=1832777&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testelement/property/MapProperty.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testelement/property/MapProperty.java Sun Jun
 3 16:21:25 2018
@@ -89,7 +89,7 @@ public class MapProperty extends MultiPr
      */
     @Override
     protected Class<? extends JMeterProperty> getPropertyType() {
-        if (value.size() > 0) {
+        if (!value.isEmpty()) {
             return valueIterator().next().getClass();
         }
         return NullProperty.class;

Modified: jmeter/trunk/test/src/org/apache/jmeter/testelement/property/MapPropertyTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testelement/property/MapPropertyTest.java?rev=1832777&r1=1832776&r2=1832777&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testelement/property/MapPropertyTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/testelement/property/MapPropertyTest.java Sun
Jun  3 16:21:25 2018
@@ -1,5 +1,11 @@
 package org.apache.jmeter.testelement.property;
 
+import static org.junit.Assert.assertThat;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 
 public class MapPropertyTest {
@@ -10,4 +16,16 @@ public class MapPropertyTest {
         props.addProperty("Foo", new BooleanProperty());
     }
 
+    @Test
+    public void testGetPropertyTypeOfEmptyMap() {
+        MapProperty props = new MapProperty("foo", new HashMap<Object, Object>());
+        assertThat(props.getPropertyType(), CoreMatchers.equalTo(NullProperty.class));
+    }
+    
+    public void testGetPropertyTypeOfStringElements() {
+        Map<String, Integer> numberMap = new HashMap<>();
+        numberMap.put("One", Integer.valueOf(1));
+        MapProperty props = new MapProperty("foo", numberMap);
+        assertThat(props.getPropertyType(), CoreMatchers.equalTo(IntegerProperty.class));
+    }
 }



Mime
View raw message