jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: Extract common logic into private method to make code more clear
Date Thu, 29 Oct 2020 18:38:53 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new ef26478  Extract common logic into private method to make code more clear
ef26478 is described below

commit ef264788dee00e328f9d698caf76a3cdfb5c4f87
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Thu Oct 29 19:38:38 2020 +0100

    Extract common logic into private method to make code more clear
---
 .../org/apache/jmeter/util/SecurityProviderLoaderTest.java  | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
b/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
index 694b527..83d31c6 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
@@ -103,7 +103,14 @@ public class SecurityProviderLoaderTest {
         Assert.assertEquals(providersCountBefore + 1, providersAfter.length);
         Assert.assertNotNull(provider);
         Assert.assertEquals(DummyProvider.class, provider.getClass());
-        Assert.assertEquals(provider, providersAfter[position == 0 ? providersAfter.length
- 1 : position - 1]);
+        Assert.assertEquals(provider, providersAfter[expectedInsertPosition(position, providersAfter)]);
+    }
+
+    private int expectedInsertPosition(int position, Provider[] providersAfter) {
+        if (position == 0) {
+            return providersAfter.length - 1;
+        }
+        return position - 1;
     }
 
     @ParameterizedTest
@@ -120,10 +127,8 @@ public class SecurityProviderLoaderTest {
         Assert.assertNotNull("Provider not installed.", provider);
         Assert.assertEquals(providersCountBefore + 1, providersAfter.length);
         Assert.assertEquals(DummyProviderWithConfig.class, provider.getClass());
-        Assert.assertEquals(provider, providersAfter[position == 0 ? providersAfter.length
- 1 : position - 1]);
+        Assert.assertEquals(provider, providersAfter[expectedInsertPosition(position, providersAfter)]);
         Assert.assertEquals(config.substring(config.lastIndexOf(":") + 1), ((DummyProviderWithConfig)
provider).getConfig());
-
-
     }
 
     @Test


Mime
View raw message