CodeCoverage improvement for dcaegen2-services-mapper
[dcaegen2/services/mapper.git] / UniversalVesAdapter / src / main / java / org / onap / universalvesadapter / configs / DMaaPMRPublisherConfig.java
index 4b15f55..8b3e52e 100644 (file)
@@ -3,6 +3,7 @@
  *  dcae-analytics\r
  * ================================================================================\r
  *    Copyright Â© 2017 AT&T Intellectual Property. All rights reserved.\r
+ *    Copyright (C) 2022 Huawei. All rights reserved.\r
  * ================================================================================\r
  *  Licensed under the Apache License, Version 2.0 (the "License");\r
  *  you may not use this file except in compliance with the License.\r
@@ -43,23 +44,22 @@ import com.google.common.base.Objects;
 @ComponentScan\r
 public class DMaaPMRPublisherConfig extends DMaaPMRBaseConfig {\r
 \r
+    /**\r
+     * Publisher batching queue size\r
+     */\r
+    private int maxBatchSize;\r
 \r
-       /**\r
-        * Publisher batching queue size\r
-        */\r
-       private int maxBatchSize;\r
+    /**\r
+     * Publisher Recovery Queue Size\r
+     */\r
+    private int maxRecoveryQueueSize;\r
 \r
-       /**\r
-        * Publisher Recovery Queue Size\r
-        */\r
-       private int maxRecoveryQueueSize;\r
-       \r
-       /**\r
-        * Default uri path prefix\r
-        */\r
-       private String dmaapUriPathPrefix ;\r
+    /**\r
+     * Default uri path prefix\r
+     */\r
+    private String dmaapUriPathPrefix ;\r
 \r
-    private DMaaPMRPublisherConfig(Builder builder) {\r
+    public DMaaPMRPublisherConfig(Builder builder) {\r
         this.hostName = builder.hostName;\r
         this.portNumber = builder.portNumber;\r
         this.topicName = builder.topicName;\r
@@ -72,182 +72,183 @@ public class DMaaPMRPublisherConfig extends DMaaPMRBaseConfig {
         this.dmaapUriPathPrefix = builder.dmaapUriPathPrefix;\r
     }\r
 \r
-       /**\r
-        * Builder to initialize immutable {@link DMaaPMRPublisherConfig} object\r
-        */\r
-       public static class Builder {\r
-\r
-               private String hostName;\r
-               private Integer portNumber;\r
-               private String topicName;\r
-               private String userName;\r
-               private String userPassword;\r
-               private String protocol;\r
-               private String contentType;\r
-               private int maxBatchSize;\r
-               private int maxRecoveryQueueSize;\r
-               private String dmaapUriPathPrefix ;\r
-               \r
-               \r
-\r
-               public Builder(@Nonnull String topicName, DmaapConfig dmaapConfig) throws IOException {\r
-this.topicName = topicName;\r
-this.hostName = dmaapConfig.getDmaaphost();\r
-               this.portNumber = dmaapConfig.getDEFAULT_PORT_NUMBER();\r
-                       // Default values\r
-       \r
-                       this.userName = dmaapConfig.getDEFAULT_USER_NAME();\r
-                       this.userPassword = dmaapConfig.getDEFAULT_USER_PASSWORD();\r
-                       this.protocol =dmaapConfig.getDEFAULT_PROTOCOL();\r
-                       this.contentType = dmaapConfig.getDEFAULT_CONTENT_TYPE();\r
-\r
-                       this.maxBatchSize =dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE();\r
-                       this.maxRecoveryQueueSize = dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE();\r
-                       this.dmaapUriPathPrefix=dmaapConfig.getDMAAP_URI_PATH_PREFIX();\r
-               }\r
-\r
-               /**\r
-                * Setup for custom host port number - Defaults to 80.\r
-                *\r
-                * @param portNumber\r
-                *            custom port number\r
-                * @return Builder object itself for chaining\r
-                */\r
-               public Builder setPortNumber(@Nonnull Integer portNumber) {\r
-                       this.portNumber = portNumber;\r
-                       return this;\r
-               }\r
-\r
-               /**\r
-                * Setup user name for authentication. If no username is provided authentication\r
-                * will be disabled\r
-                *\r
-                * @param userName\r
-                *            user name for DMaaP Topic Authentication\r
-                * @return Builder object itself for chaining\r
-                */\r
-               public Builder setUserName(@Nonnull String userName) {\r
-                       this.userName = userName;\r
-                       return this;\r
-               }\r
-\r
-               /**\r
-                * Setup user password for authentication. If no password is provided\r
-                * authentication will be disabled\r
-                *\r
-                * @param userPassword\r
-                *            user password for DMaaP Topic Authentication\r
-                * @return Builder object itself for chaining\r
-                */\r
-               public Builder setUserPassword(@Nonnull String userPassword) {\r
-                       this.userPassword = userPassword;\r
-                       return this;\r
-               }\r
-\r
-               /**\r
-                * Setup custom Publisher protocol - Defaults to https. Note: Only http and\r
-                * https are currently supported.\r
-                *\r
-                * @param protocol\r
-                *            protocol e.g. https\r
-                * @return Builder object itself for chaining\r
-                */\r
-               public Builder setProtocol(@Nonnull String protocol) {\r
-                       this.protocol = normalizeValidateProtocol(protocol);\r
-                       return this;\r
-               }\r
-\r
-               /**\r
-                * Setup custom Publisher content-type - Defaults to application/json\r
-                *\r
-                * @param contentType\r
-                *            content type e.g. application/json\r
-                * @return Builder object itself for chaining\r
-                */\r
-               public Builder setContentType(@Nonnull String contentType) {\r
-                       final String normalizedContentType = normalizeValidateContentType(contentType);\r
-                       this.contentType = normalizedContentType;\r
-                       return this;\r
-               }\r
-\r
-               /**\r
-                * Setup custom Publisher Max Batch Size - Defaults to 100\r
-                *\r
-                * @param maxBatchSize\r
-                *            max Batch Size\r
-                * @return Builder object itself for chaining\r
-                */\r
-               public Builder setMaxBatchSize(int maxBatchSize) {\r
-                       this.maxBatchSize = maxBatchSize;\r
-                       return this;\r
-               }\r
-\r
-               /**\r
-                * Setup custom Maximum Recovery Queue Size. Recovery Queue is used to hold\r
-                * messages temporarily in case DMaaP MR Publisher topic is not responding for\r
-                * any reason. Defaults to 100,000\r
-                *\r
-                * @param maxRecoveryQueueSize\r
-                *            max recovery queue size\r
-                * @return Builder object itself for chaining\r
-                */\r
-               public Builder setMaxRecoveryQueueSize(int maxRecoveryQueueSize) {\r
-                       this.maxRecoveryQueueSize = maxRecoveryQueueSize;\r
-                       return this;\r
-               }\r
-               \r
-\r
-               /**\r
-                * Creates immutable instance of {@link DMaaPMRPublisherConfig}\r
-                *\r
-                * @return Builds and returns thread safe, immutable\r
-                *         {@link DMaaPMRPublisherConfig} object\r
-                */\r
+    /**\r
+     * Builder to initialize immutable {@link DMaaPMRPublisherConfig} object\r
+     */\r
+    public static class Builder {\r
+\r
+        private String hostName;\r
+        private Integer portNumber;\r
+        private String topicName;\r
+        private String userName;\r
+        private String userPassword;\r
+        private String protocol;\r
+        private String contentType;\r
+        private int maxBatchSize;\r
+        private int maxRecoveryQueueSize;\r
+        private String dmaapUriPathPrefix ;\r
+\r
+\r
+\r
+        public Builder(@Nonnull String topicName, DmaapConfig dmaapConfig) throws IOException {\r
+            this.topicName = topicName;\r
+            this.hostName = dmaapConfig.getDmaaphost();\r
+            this.portNumber = dmaapConfig.getDEFAULT_PORT_NUMBER();\r
+            // Default values\r
+\r
+            this.userName = dmaapConfig.getDEFAULT_USER_NAME();\r
+            this.userPassword = dmaapConfig.getDEFAULT_USER_PASSWORD();\r
+            this.protocol =dmaapConfig.getDEFAULT_PROTOCOL();\r
+            this.contentType = dmaapConfig.getDEFAULT_CONTENT_TYPE();\r
+\r
+            this.maxBatchSize =dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE();\r
+            this.maxRecoveryQueueSize = dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE();\r
+            this.dmaapUriPathPrefix=dmaapConfig.getDMAAP_URI_PATH_PREFIX();\r
+        }\r
+\r
+        /**\r
+         * Setup for custom host port number - Defaults to 80.\r
+         *\r
+         * @param portNumber\r
+         *            custom port number\r
+         * @return Builder object itself for chaining\r
+         */\r
+        public Builder setPortNumber(@Nonnull Integer portNumber) {\r
+            this.portNumber = portNumber;\r
+            return this;\r
+        }\r
+\r
+        /**\r
+         * Setup user name for authentication. If no username is provided authentication\r
+         * will be disabled\r
+         *\r
+         * @param userName\r
+         *            user name for DMaaP Topic Authentication\r
+         * @return Builder object itself for chaining\r
+         */\r
+        public Builder setUserName(@Nonnull String userName) {\r
+            this.userName = userName;\r
+            return this;\r
+        }\r
+\r
+        /**\r
+         * Setup user password for authentication. If no password is provided\r
+         * authentication will be disabled\r
+         *\r
+         * @param userPassword\r
+         *            user password for DMaaP Topic Authentication\r
+         * @return Builder object itself for chaining\r
+         */\r
+        public Builder setUserPassword(@Nonnull String userPassword) {\r
+            this.userPassword = userPassword;\r
+            return this;\r
+        }\r
+\r
+        /**\r
+         * Setup custom Publisher protocol - Defaults to https. Note: Only http and\r
+         * https are currently supported.\r
+         *\r
+         * @param protocol\r
+         *            protocol e.g. https\r
+         * @return Builder object itself for chaining\r
+         */\r
+        public Builder setProtocol(@Nonnull String protocol) {\r
+            this.protocol = normalizeValidateProtocol(protocol);\r
+            return this;\r
+        }\r
+\r
+        /**\r
+         * Setup custom Publisher content-type - Defaults to application/json\r
+         *\r
+         * @param contentType\r
+         *            content type e.g. application/json\r
+         * @return Builder object itself for chaining\r
+         */\r
+        public Builder setContentType(@Nonnull String contentType) {\r
+            final String normalizedContentType = normalizeValidateContentType(contentType);\r
+            this.contentType = normalizedContentType;\r
+            return this;\r
+        }\r
+\r
+        /**\r
+         * Setup custom Publisher Max Batch Size - Defaults to 100\r
+         *\r
+         * @param maxBatchSize\r
+         *            max Batch Size\r
+         * @return Builder object itself for chaining\r
+         */\r
+        public Builder setMaxBatchSize(int maxBatchSize) {\r
+            this.maxBatchSize = maxBatchSize;\r
+            return this;\r
+        }\r
+\r
+        /**\r
+         * Setup custom Maximum Recovery Queue Size. Recovery Queue is used to hold\r
+         * messages temporarily in case DMaaP MR Publisher topic is not responding for\r
+         * any reason. Defaults to 100,000\r
+         *\r
+         * @param maxRecoveryQueueSize\r
+         *            max recovery queue size\r
+         * @return Builder object itself for chaining\r
+         */\r
+        public Builder setMaxRecoveryQueueSize(int maxRecoveryQueueSize) {\r
+            this.maxRecoveryQueueSize = maxRecoveryQueueSize;\r
+            return this;\r
+        }\r
+\r
+\r
+        /**\r
+         * Creates immutable instance of {@link DMaaPMRPublisherConfig}\r
+         *\r
+         * @return Builds and returns thread safe, immutable\r
+         *         {@link DMaaPMRPublisherConfig} object\r
+         */\r
         public DMaaPMRPublisherConfig build() {\r
             return new DMaaPMRPublisherConfig(this);\r
         }\r
 \r
-       }\r
-       public String getDmaapUriPathPrefix() {\r
-               return dmaapUriPathPrefix;\r
-       }\r
-\r
-       /**\r
-        * Returns max Publisher Batch Queue Size\r
-        *\r
-        * @return max Publisher Batch Queue size\r
-        */\r
-       public int getMaxBatchSize() {\r
-               return maxBatchSize;\r
-       }\r
-\r
-       /**\r
-        * Returns max Publisher Recovery Queue Size\r
-        *\r
-        * @return max Recovery Queue size\r
-        */\r
-       public int getMaxRecoveryQueueSize() {\r
-               return maxRecoveryQueueSize;\r
-       }\r
-\r
-       @Override\r
-       public boolean equals(Object o) {\r
-               if (this == o) {\r
-                       return true;\r
-               }\r
-               if (o == null || getClass() != o.getClass()) {\r
-                       return false;\r
-               }\r
-               if (!super.equals(o)) {\r
-                       return false;\r
-               }\r
-               DMaaPMRPublisherConfig that = (DMaaPMRPublisherConfig) o;\r
-               return maxBatchSize == that.maxBatchSize && maxRecoveryQueueSize == that.maxRecoveryQueueSize;\r
-       }\r
-\r
-       @Override\r
-       public int hashCode() {\r
-               return Objects.hashCode(super.hashCode(), maxBatchSize, maxRecoveryQueueSize);\r
-       }\r
-\r
-}
\ No newline at end of file
+    }\r
+    public String getDmaapUriPathPrefix() {\r
+        return dmaapUriPathPrefix;\r
+    }\r
+\r
+    /**\r
+     * Returns max Publisher Batch Queue Size\r
+     *\r
+     * @return max Publisher Batch Queue size\r
+     */\r
+    public int getMaxBatchSize() {\r
+        return maxBatchSize;\r
+    }\r
+\r
+    /**\r
+     * Returns max Publisher Recovery Queue Size\r
+     *\r
+     * @return max Recovery Queue size\r
+     */\r
+    public int getMaxRecoveryQueueSize() {\r
+        return maxRecoveryQueueSize;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object o) {\r
+        if (this == o) {\r
+            return true;\r
+        }\r
+        if (o == null || getClass() != o.getClass()) {\r
+            return false;\r
+        }\r
+        if (!super.equals(o)) {\r
+            return false;\r
+        }\r
+        DMaaPMRPublisherConfig that = (DMaaPMRPublisherConfig) o;\r
+        return maxBatchSize == that.maxBatchSize && maxRecoveryQueueSize == that.maxRecoveryQueueSize;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        return Objects.hashCode(super.hashCode(), maxBatchSize, maxRecoveryQueueSize);\r
+    }\r
+\r
+}\r
+\r