Fix Constructor has 9 parameters, which is greater than 7 authorized sonar issue.
Fix Constructor has 10 parameters, which is greater than 7 authorized sonar issue.
Issue-ID: DMAAP-894
Change-Id: If961a064edc165df9f96c6c5e5432ae136de4a2d
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
 
             if ( sfConsumerMock != null ) return sfConsumerMock;
             try {
-                return new MRConsumerImpl ( fHosts, fTopic, fGroup, fId, fTimeoutMs, fLimit, fFilter, fApiKey, fApiSecret );
+                return new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(fHosts)
+                        .setTopic(fTopic).setConsumerGroup(fGroup).setConsumerId(fId)
+                        .setTimeoutMs(fTimeoutMs).setLimit(fLimit).setFilter(fFilter)
+                        .setApiKey_username(fApiKey).setApiSecret_password(fApiSecret)
+                        .createMRConsumerImpl();
             } catch (MalformedURLException e) {
                 throw new IllegalArgumentException(e);
             }
 
 import java.util.Properties;
 import java.util.TreeSet;
 import java.util.UUID;
-
 import javax.ws.rs.core.MultivaluedMap;
-
 import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
 import org.onap.dmaap.mr.client.impl.MRMetaClient;
 import org.onap.dmaap.mr.client.impl.MRSimplerBatchPublisher;
         if (MRClientBuilders.sfConsumerMock != null)
             return MRClientBuilders.sfConsumerMock;
         try {
-            return new MRConsumerImpl(hostSet, topic, consumerGroup, consumerId, timeoutMs, limit, filter, apiKey,
-                    apiSecret);
+            return new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hostSet).setTopic(topic)
+                    .setConsumerGroup(consumerGroup).setConsumerId(consumerId)
+                    .setTimeoutMs(timeoutMs).setLimit(limit).setFilter(filter)
+                    .setApiKey_username(apiKey).setApiSecret_password(apiSecret)
+                    .createMRConsumerImpl();
         } catch (MalformedURLException e) {
             throw new IllegalArgumentException(e);
         }
 
         MRConsumerImpl sub;
         try {
-            sub = new MRConsumerImpl(MRConsumerImpl.stringToList(host), topic, group, id, i, j, null, null, null);
+            sub = new MRConsumerImpl.MRConsumerImplBuilder()
+                    .setHostPart(MRConsumerImpl.stringToList(host)).setTopic(topic)
+                    .setConsumerGroup(group).setConsumerId(id).setTimeoutMs(i).setLimit(j)
+                    .setFilter(null).setApiKey_username(null).setApiSecret_password(null)
+                    .createMRConsumerImpl();
         } catch (MalformedURLException e) {
             throw new IllegalArgumentException(e);
         }
 
         MRConsumerImpl sub;
         try {
-            sub = new MRConsumerImpl(MRConsumerImpl.stringToList(host), topic, group, id, i, j, null, null, null);
+            sub = new MRConsumerImpl.MRConsumerImplBuilder()
+                    .setHostPart(MRConsumerImpl.stringToList(host)).setTopic(topic)
+                    .setConsumerGroup(group).setConsumerId(id).setTimeoutMs(i).setLimit(j)
+                    .setFilter(null).setApiKey_username(null).setApiSecret_password(null)
+                    .createMRConsumerImpl();
         } catch (MalformedURLException e) {
             throw new IllegalArgumentException(e);
         }
             group = props.getProperty("group");
         MRConsumerImpl sub = null;
         if (props.getProperty(TRANSPORT_TYPE).equalsIgnoreCase(ProtocolTypeConstants.AUTH_KEY.getValue())) {
-            sub = new MRConsumerImpl(MRConsumerImpl.stringToList(props.getProperty("host")), props.getProperty(TOPIC),
-                    group, props.getProperty("id"), timeout, limit, props.getProperty("filter"),
-                    props.getProperty(AUTH_KEY), props.getProperty(AUTH_DATE));
+            sub = new MRConsumerImpl.MRConsumerImplBuilder()
+                    .setHostPart(MRConsumerImpl.stringToList(props.getProperty("host")))
+                    .setTopic(props.getProperty(TOPIC)).setConsumerGroup(group)
+                    .setConsumerId(props.getProperty("id")).setTimeoutMs(timeout).setLimit(limit)
+                    .setFilter(props.getProperty("filter"))
+                    .setApiKey_username(props.getProperty(AUTH_KEY))
+                    .setApiSecret_password(props.getProperty(AUTH_DATE)).createMRConsumerImpl();
             sub.setAuthKey(props.getProperty(AUTH_KEY));
             sub.setAuthDate(props.getProperty(AUTH_DATE));
             sub.setUsername(props.getProperty(USERNAME));
             sub.setPassword(props.getProperty(PASSWORD));
         } else {
-            sub = new MRConsumerImpl(MRConsumerImpl.stringToList(props.getProperty("host")), props.getProperty(TOPIC),
-                    group, props.getProperty("id"), timeout, limit, props.getProperty("filter"),
-                    props.getProperty(USERNAME), props.getProperty(PASSWORD));
+            sub = new MRConsumerImpl.MRConsumerImplBuilder()
+                    .setHostPart(MRConsumerImpl.stringToList(props.getProperty("host")))
+                    .setTopic(props.getProperty(TOPIC)).setConsumerGroup(group)
+                    .setConsumerId(props.getProperty("id")).setTimeoutMs(timeout).setLimit(limit)
+                    .setFilter(props.getProperty("filter"))
+                    .setApiKey_username(props.getProperty(USERNAME))
+                    .setApiSecret_password(props.getProperty(PASSWORD)).createMRConsumerImpl();
             sub.setUsername(props.getProperty(USERNAME));
             sub.setPassword(props.getProperty(PASSWORD));
         }
 
     private long dme2ReplyHandlerTimeoutMs;
     private long longPollingMs;
 
-    public MRConsumerImpl(Collection<String> hostPart, final String topic, final String consumerGroup,
-            final String consumerId, int timeoutMs, int limit, String filter, String apiKey_username,
-            String apiSecret_password) throws MalformedURLException {
-        this(hostPart, topic, consumerGroup, consumerId, timeoutMs, limit, filter, apiKey_username, apiSecret_password,
-                false);
-    }
-
-    public MRConsumerImpl(Collection<String> hostPart, final String topic, final String consumerGroup,
-            final String consumerId, int timeoutMs, int limit, String filter, String apiKey, String apiSecret,
-            boolean allowSelfSignedCerts) throws MalformedURLException {
-        super(hostPart, topic + "::" + consumerGroup + "::" + consumerId);
-
-        fTopic = topic;
-        fGroup = consumerGroup;
-        fId = consumerId;
-        fTimeoutMs = timeoutMs;
-        fLimit = limit;
-        fFilter = filter;
-
-        fHostSelector = new HostSelector(hostPart);
+    public MRConsumerImpl(MRConsumerImplBuilder builder) throws MalformedURLException {
+        super(builder.hostPart,
+                builder.topic + "::" + builder.consumerGroup + "::" + builder.consumerId);
+
+        fTopic = builder.topic;
+        fGroup = builder.consumerGroup;
+        fId = builder.consumerId;
+        fTimeoutMs = builder.timeoutMs;
+        fLimit = builder.limit;
+        fFilter = builder.filter;
+
+        fHostSelector = new HostSelector(builder.hostPart);
+    }
+
+    public static class MRConsumerImplBuilder {
+        private Collection<String> hostPart;
+        private String topic;
+        private String consumerGroup;
+        private String consumerId;
+        private int timeoutMs;
+        private int limit;
+        private String filter;
+        private String apiKey_username;
+        private String apiSecret_password;
+        private String apiKey;
+        private String apiSecret;
+        private boolean allowSelfSignedCerts = false;
+
+        public MRConsumerImplBuilder setHostPart(Collection<String> hostPart) {
+            this.hostPart = hostPart;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setTopic(String topic) {
+            this.topic = topic;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setConsumerGroup(String consumerGroup) {
+            this.consumerGroup = consumerGroup;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setConsumerId(String consumerId) {
+            this.consumerId = consumerId;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setTimeoutMs(int timeoutMs) {
+            this.timeoutMs = timeoutMs;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setLimit(int limit) {
+            this.limit = limit;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setFilter(String filter) {
+            this.filter = filter;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setApiKey_username(String apiKey_username) {
+            this.apiKey_username = apiKey_username;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setApiSecret_password(String apiSecret_password) {
+            this.apiSecret_password = apiSecret_password;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setApiKey(String apiKey) {
+            this.apiKey = apiKey;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setApiSecret(String apiSecret) {
+            this.apiSecret = apiSecret;
+            return this;
+        }
+
+        public MRConsumerImplBuilder setAllowSelfSignedCerts(boolean allowSelfSignedCerts) {
+            this.allowSelfSignedCerts = allowSelfSignedCerts;
+            return this;
+        }
+
+        public MRConsumerImpl createMRConsumerImpl() throws MalformedURLException {
+            return new MRConsumerImpl(this);
+        }
     }
 
     @Override
 
 
 import org.junit.Test;
 import org.onap.dmaap.mr.client.MRClientFactory;
-import org.onap.dmaap.mr.client.impl.MRConstants;
-import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
 import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
 
 public class MRConsumerImplTest extends TestCase {
        public void testNullFilter() throws IOException {
                final LinkedList<String> hosts = new LinkedList<String>();
                hosts.add("localhost:8080");
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", -1, -1, null, null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(-1)
+                .setLimit(-1).setFilter(null).setApiKey_username(null).setApiSecret_password(null)
+                .createMRConsumerImpl();
                final String url = c.createUrlPath(MRConstants.makeConsumerUrl("localhost:8080", "topic", "cg", "cid", "http"),
                                -1, -1);
                assertEquals("http://localhost:8080/events/" + "topic/cg/cid", url);
        public void testFilterWithNoTimeoutOrLimit() throws IOException {
                final LinkedList<String> hosts = new LinkedList<String>();
                hosts.add("localhost:8080");
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", -1, -1, "filter", null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(-1)
+                .setLimit(-1).setFilter("filter").setApiKey_username(null)
+                .setApiSecret_password(null).createMRConsumerImpl();
                final String url = c.createUrlPath(MRConstants.makeConsumerUrl("localhost:8080", "topic", "cg", "cid", "http"),
                                -1, -1);
                assertEquals("http://localhost:8080/events/" + "topic/cg/cid?filter=filter", url);
        public void testTimeoutNoLimitNoFilter() throws IOException {
                final LinkedList<String> hosts = new LinkedList<String>();
                hosts.add("localhost:8080");
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", 30000, -1, null, null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(30000)
+                .setLimit(-1).setFilter(null).setApiKey_username(null).setApiSecret_password(null)
+                .createMRConsumerImpl();
                final String url = c.createUrlPath(MRConstants.makeConsumerUrl("localhost:8080", "topic", "cg", "cid", "http"),
                                30000, -1);
                assertEquals("http://localhost:8080/events/" + "topic/cg/cid?timeout=30000", url);
        public void testNoTimeoutWithLimitNoFilter() throws IOException {
                final LinkedList<String> hosts = new LinkedList<String>();
                hosts.add("localhost:8080");
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", -1, 100, null, null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(-1)
+                .setLimit(100).setFilter(null).setApiKey_username(null).setApiSecret_password(null)
+                .createMRConsumerImpl();
                final String url = c.createUrlPath(MRConstants.makeConsumerUrl("localhost:8080", "topic", "cg", "cid", "http"),
                                -1, 100);
                assertEquals("http://localhost:8080/events/" + "topic/cg/cid?limit=100", url);
        public void testWithTimeoutWithLimitWithFilter() throws IOException {
                final LinkedList<String> hosts = new LinkedList<String>();
                hosts.add("localhost:8080");
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", 1000, 400, "f", null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(1000)
+                .setLimit(400).setFilter("f").setApiKey_username(null).setApiSecret_password(null)
+                .createMRConsumerImpl();
                final String url = c.createUrlPath(MRConstants.makeConsumerUrl("localhost:8080", "topic", "cg", "cid", "http"),
                                1000, 400);
                assertEquals("http://localhost:8080/events/" + "topic/cg/cid?timeout=1000&limit=400&filter=f", url);
        public void testFilterEncoding() throws IOException {
                final LinkedList<String> hosts = new LinkedList<String>();
                hosts.add("localhost:8080");
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", -1, -1, "{ \"foo\"=\"bar\"bar\" }",
-                               null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(-1)
+                .setLimit(-1).setFilter("{ \"foo\"=\"bar\"bar\" }").setApiKey_username(null)
+                .setApiSecret_password(null).createMRConsumerImpl();
                final String url = c.createUrlPath(MRConstants.makeConsumerUrl("localhost:8080", "topic", "cg", "cid", "http"),
                                -1, -1);
                assertEquals("http://localhost:8080/events/" + "topic/cg/cid?filter=%7B+%22foo%22%3D%22bar%22bar%22+%7D", url);
 
                MRClientFactory.prop=properties;
 
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", -1, -1, "{ \"foo\"=\"bar\"bar\" }",
-                               null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(-1)
+                .setLimit(-1).setFilter("{ \"foo\"=\"bar\"bar\" }").setApiKey_username(null)
+                .setApiSecret_password(null).createMRConsumerImpl();
                c.setProps(properties);
                assertNotNull(c.fetchWithReturnConsumerResponse());
                c.setProtocolFlag(ProtocolTypeConstants.AAF_AUTH.getValue());
                properties.store(new FileOutputStream(outFile), "");
 
                MRClientFactory.prop=properties;
-               final MRConsumerImpl c = new MRConsumerImpl(hosts, "topic", "cg", "cid", -1, -1, "{ \"foo\"=\"bar\"bar\" }",
-                               null, null);
+        final MRConsumerImpl c = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
+                .setTopic("topic").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(-1)
+                .setLimit(-1).setFilter("{ \"foo\"=\"bar\"bar\" }").setApiKey_username(null)
+                .setApiSecret_password(null).createMRConsumerImpl();
                c.setProps(properties);
                try {
                        c.fetch();