aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-node/src
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2019-04-19 18:08:21 +0900
committerConor Ward <conor.ward@est.tech>2019-05-01 11:59:25 +0000
commit8d97ad4cf9b468d22e435537a8a9f2946205f35a (patch)
tree01e45dce5157fd4f80a1acba46b87b203162a621 /datarouter-node/src
parent359b6660ad7ec2ce1f458996d14f6e52edda5a4b (diff)
Sonar fix too many method param
+) https://sonar.onap.org/issues?projectUuids=AWHFaQXIWid2ybiDeOSb&resolved=false&rules=squid%3AS00107 ++) code format Issue-ID: DMAAP-1174 Change-Id: I162ed1400be2ac059b14f16500bc849f6b10f8be Signed-off-by: arind.mondal <arind.mondal@samsung.com>
Diffstat (limited to 'datarouter-node/src')
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java128
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java5
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java6
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java5
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java11
5 files changed, 118 insertions, 37 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java
index 8aa339f5..8890fe96 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java
@@ -41,35 +41,105 @@ public class DestInfo {
private boolean decompress;
private boolean followRedirects;
private String aafInstance;
- /**
- * Create a destination information object.
- *
- * @param name n:fqdn or s:subid
- * @param spool The directory where files are spooled.
- * @param subid The subscription ID (if applicable).
- * @param logdata Text to be included in log messages
- * @param url The URL to deliver to.
- * @param authuser The auth user for logging.
- * @param authentication The credentials.
- * @param metaonly Is this a metadata only delivery?
- * @param use100 Should I use expect 100-continue?
- * @param privilegedSubscriber Can we wait to receive a file processed acknowledgement before deleting file
- * @param followRedirects Is follow redirect of destination enabled?
- * @param decompress To see if the they want there information compressed or decompressed
- */
- public DestInfo(String name, String spool, String subid, String logdata, String url, String authuser, String authentication, boolean metaonly, boolean use100, boolean privilegedSubscriber, boolean followRedirects, boolean decompress) {
- this.name = name;
- this.spool = spool;
- this.subid = subid;
- this.logdata = logdata;
- this.url = url;
- this.authuser = authuser;
- this.authentication = authentication;
- this.metaonly = metaonly;
- this.use100 = use100;
- this.privilegedSubscriber = privilegedSubscriber;
- this.followRedirects = followRedirects;
- this.decompress = decompress;
+
+ public static class DestInfoBuilder {
+ private String name;
+ private String spool;
+ private String subid;
+ private String logdata;
+ private String url;
+ private String authuser;
+ private String authentication;
+ private boolean metaonly;
+ private boolean use100;
+ private boolean privilegedSubscriber;
+ private boolean followRedirects;
+ private boolean decompress;
+ private NodeConfig.ProvSubscription subscription;
+
+ public DestInfoBuilder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public DestInfoBuilder setSpool(String spool) {
+ this.spool = spool;
+ return this;
+ }
+
+ public DestInfoBuilder setSubid(String subid) {
+ this.subid = subid;
+ return this;
+ }
+
+ public DestInfoBuilder setLogdata(String logdata) {
+ this.logdata = logdata;
+ return this;
+ }
+
+ public DestInfoBuilder setUrl(String url) {
+ this.url = url;
+ return this;
+ }
+
+ public DestInfoBuilder setAuthuser(String authuser) {
+ this.authuser = authuser;
+ return this;
+ }
+
+ public DestInfoBuilder setAuthentication(String authentication) {
+ this.authentication = authentication;
+ return this;
+ }
+
+ public DestInfoBuilder setMetaonly(boolean metaonly) {
+ this.metaonly = metaonly;
+ return this;
+ }
+
+ public DestInfoBuilder setUse100(boolean use100) {
+ this.use100 = use100;
+ return this;
+ }
+
+ public DestInfoBuilder setPrivilegedSubscriber(boolean privilegedSubscriber) {
+ this.privilegedSubscriber = privilegedSubscriber;
+ return this;
+ }
+
+ public DestInfoBuilder setFollowRedirects(boolean followRedirects) {
+ this.followRedirects = followRedirects;
+ return this;
+ }
+
+ public DestInfoBuilder setDecompress(boolean decompress) {
+ this.decompress = decompress;
+ return this;
+ }
+
+ public DestInfoBuilder setSubscription(NodeConfig.ProvSubscription subscription) {
+ this.subscription = subscription;
+ return this;
+ }
+
+ public DestInfo createDestInfo() {
+ return new DestInfo(this);
+ }
+ }
+
+ public DestInfo(DestInfoBuilder destInfoBuilder) {
+ this.name = destInfoBuilder.name;
+ this.spool = destInfoBuilder.spool;
+ this.subid = destInfoBuilder.subid;
+ this.logdata = destInfoBuilder.logdata;
+ this.url = destInfoBuilder.url;
+ this.authuser = destInfoBuilder.authuser;
+ this.authentication = destInfoBuilder.authentication;
+ this.metaonly = destInfoBuilder.metaonly;
+ this.use100 = destInfoBuilder.use100;
+ this.privilegedSubscriber = destInfoBuilder.privilegedSubscriber;
+ this.followRedirects = destInfoBuilder.followRedirects;
+ this.decompress = destInfoBuilder.decompress;
}
/**
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java
index 3fa5dc29..78a195b1 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java
@@ -104,7 +104,10 @@ public class LogManager extends TimerTask {
public Uploader() {
dq = new DeliveryQueue(this,
- new DestInfo("LogUpload", uploaddir, null, null, null, config.getMyName(), config.getMyAuth(), false, false, false, false, false));
+ new DestInfo.DestInfoBuilder().setName("LogUpload").setSpool(uploaddir).setSubid(null).setLogdata(null)
+ .setUrl(null).setAuthuser(config.getMyName()).setAuthentication(config.getMyAuth())
+ .setMetaonly(false).setUse100(false).setPrivilegedSubscriber(false).setFollowRedirects(false)
+ .setDecompress(false).createDestInfo());
setDaemon(true);
setName("Log Uploader");
start();
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java
index 23512a14..d455f2d9 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfig.java
@@ -559,8 +559,10 @@ public class NodeConfig {
continue;
}
String auth = NodeUtils.getNodeAuthHdr(cName, nodeauthkey);
- DestInfo di = new DestInfo("n:" + cName, spooldir + "/n/" + cName, null, "n2n-" + cName,
- "https://" + cName + ":" + port + "/internal/publish", cName, myauth, false, true, false, false, false);
+ DestInfo di = new DestInfo.DestInfoBuilder().setName("n:" + cName).setSpool(spooldir + "/n/" + cName).setSubid(null)
+ .setLogdata("n2n-" + cName).setUrl("https://" + cName + ":" + port + "/internal/publish")
+ .setAuthuser(cName).setAuthentication(myauth).setMetaonly(false).setUse100(true)
+ .setPrivilegedSubscriber(false).setFollowRedirects(false).setDecompress(false).createDestInfo();
(new File(di.getSpool())).mkdirs();
destInfos.add(di);
nodeinfo.put(cName, di);
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java
index efa43e11..08120073 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java
@@ -97,7 +97,10 @@ public class DeliveryTest {
private DestInfo[] createDestInfoObjects() {
DestInfo[] destInfos = new DestInfo[1];
- DestInfo destInfo = new DestInfo("node.datarouternew.com", "spool/s/0/1", "1", "logs/", "/subs/1", "user1", "Basic dXNlcjE6cGFzc3dvcmQx", false, true, false, false, false);
+ DestInfo destInfo = new DestInfo.DestInfoBuilder().setName("node.datarouternew.com").setSpool("spool/s/0/1").setSubid("1")
+ .setLogdata("logs/").setUrl("/subs/1").setAuthuser("user1").setAuthentication("Basic dXNlcjE6cGFzc3dvcmQx")
+ .setMetaonly(false).setUse100(true).setPrivilegedSubscriber(false).setFollowRedirects(false)
+ .setDecompress(false).createDestInfo();
destInfos[0] = destInfo;
return destInfos;
}
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java
index 7dddd67a..5e357373 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java
@@ -36,7 +36,8 @@ import java.io.Reader;
import java.io.StringReader;
@RunWith(PowerMockRunner.class)
-@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.node.ProvData", "org.onap.dmaap.datarouter.node.NodeUtils"})
+@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.node.ProvData",
+ "org.onap.dmaap.datarouter.node.NodeUtils"})
public class NodeConfigTest {
private static NodeConfig nodeConfig;
@@ -72,7 +73,7 @@ public class NodeConfigTest {
}
@Test
- public void Given_SubId_Then_Get_Feed_Id_Returns_Correct_Id() {
+ public void Given_SubId_Then_Get_Feed_Id_Returns_Correct_Id(){
String feedId = nodeConfig.getFeedId("1");
Assert.assertEquals("1", feedId);
}
@@ -134,13 +135,15 @@ public class NodeConfigTest {
@Test
public void Given_Same_Ip_Then_Is_Another_Node_Returns_False() {
- Boolean isAnotherNode = nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.1");
+ Boolean isAnotherNode =
+ nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.1");
Assert.assertFalse(isAnotherNode);
}
@Test
public void Given_Different_Ip_Then_Is_Another_Node_Returns_True() {
- Boolean isAnotherNode = nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.4");
+ Boolean isAnotherNode =
+ nodeConfig.isAnotherNode("Basic MTcyLjAuMC40OmtCTmhkWVFvbzhXNUphZ2g4T1N4Zmp6Mzl1ND0=", "172.0.0.4");
Assert.assertTrue(isAnotherNode);
}