summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-03-11 16:55:06 +0900
committerParshad Patel <pars.patel@samsung.com>2019-03-11 17:07:36 +0900
commit88f2318a04c7769a4dabec9b2adb5291117166ed (patch)
treed900a38b2f406aa1e7484f2a6e1b87d4a2a3ec77
parentd0870f118020464467dd34a980445792a30127d4 (diff)
Fix sonar code smell issues in apex-pdp
Fix method has more than 7 parameters issues Issue-ID: POLICY-1535 Change-Id: I12d995e323bbdbe3762c903fcb116dfe81bf7b54 Signed-off-by: Parshad Patel <pars.patel@samsung.com>
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java49
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java149
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java106
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java21
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java22
5 files changed, 307 insertions, 40 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
index 0636bbef6..4c3583e46 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
@@ -410,18 +410,16 @@ public class CodeGeneratorCliEditor {
* @param outputName the output name
* @return a CLI command for a policy state task definition
*/
- public ST createPolicyStateTask(final String policyName, final String version, final String stateName,
- final String taskLocalName, final String taskName, final String taskVersion,
- final String outputType, final String outputName) {
+ public ST createPolicyStateTask(PolicyStateTaskBuilder policyStateTaskBuilder) {
final ST st = stg.getInstanceOf("policyStateTask");
- st.add(POLICY_NAME, policyName);
- st.add(VERSION, version);
- st.add(STATE_NAME, stateName);
- st.add(TASK_LOCAL_NAME, taskLocalName);
- st.add(TASK_NAME, taskName);
- st.add(TASK_VERSION, taskVersion);
- st.add(OUTPUT_TYPE, outputType);
- st.add(OUTPUT_NAME, outputName);
+ st.add(POLICY_NAME, policyStateTaskBuilder.getPolicyName());
+ st.add(VERSION, policyStateTaskBuilder.getVersion());
+ st.add(STATE_NAME, policyStateTaskBuilder.getStateName());
+ st.add(TASK_LOCAL_NAME, policyStateTaskBuilder.getTaskLocalName());
+ st.add(TASK_NAME, policyStateTaskBuilder.getTaskName());
+ st.add(TASK_VERSION, policyStateTaskBuilder.getTaskVersion());
+ st.add(OUTPUT_TYPE, policyStateTaskBuilder.getOutputType());
+ st.add(OUTPUT_NAME, policyStateTaskBuilder.getOutputName());
return st;
}
@@ -468,23 +466,20 @@ public class CodeGeneratorCliEditor {
* @param ctxRefs any context reference for the state
* @return a CLI command for a policy state definition
*/
- public ST createPolicyStateDef(final String policyName, final String version, final String stateName,
- final String triggerName, final String triggerVersion, final String defaultTask,
- final String defaultTaskVersion, final List<ST> outputs, final List<ST> tasks,
- final List<ST> tsLogic, final List<ST> finalizerLogics, final List<ST> ctxRefs) {
+ public ST createPolicyStateDef(PolicyStateDefBuilder policyStateDefBuilder) {
final ST st = stg.getInstanceOf("policyStateDef");
- st.add(POLICY_NAME, policyName);
- st.add(VERSION, version);
- st.add(STATE_NAME, stateName);
- st.add(TRIGGER_NAME, triggerName);
- st.add(TRIGGER_VERSION, triggerVersion);
- st.add(DEFAULT_TASK, defaultTask);
- st.add(DEFAULT_TASK_VERSION, defaultTaskVersion);
- st.add(OUTPUTS, outputs);
- st.add(TASKS, tasks);
- st.add(TS_LOGIC, tsLogic);
- st.add(FINALIZER_LOGICS, finalizerLogics);
- st.add(CTX_REFS, ctxRefs);
+ st.add(POLICY_NAME, policyStateDefBuilder.getPolicyName());
+ st.add(VERSION, policyStateDefBuilder.getVersion());
+ st.add(STATE_NAME, policyStateDefBuilder.getStateName());
+ st.add(TRIGGER_NAME, policyStateDefBuilder.getTriggerName());
+ st.add(TRIGGER_VERSION, policyStateDefBuilder.getTriggerVersion());
+ st.add(DEFAULT_TASK, policyStateDefBuilder.getDefaultTask());
+ st.add(DEFAULT_TASK_VERSION, policyStateDefBuilder.getDefaultTaskVersion());
+ st.add(OUTPUTS, policyStateDefBuilder.getOutputs());
+ st.add(TASKS, policyStateDefBuilder.getTasks());
+ st.add(TS_LOGIC, policyStateDefBuilder.getTsLogic());
+ st.add(FINALIZER_LOGICS, policyStateDefBuilder.getFinalizerLogics());
+ st.add(CTX_REFS, policyStateDefBuilder.getCtxRefs());
return st;
}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java
new file mode 100644
index 000000000..ea5cc6610
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+import java.util.List;
+import org.stringtemplate.v4.ST;
+
+public class PolicyStateDefBuilder {
+
+ private String policyName;
+ private String version;
+ private String stateName;
+ private String triggerName;
+ private String triggerVersion;
+ private String defaultTask;
+ private String defaultTaskVersion;
+ private List<ST> outputs;
+ private List<ST> tasks;
+ private List<ST> tsLogic;
+ private List<ST> finalizerLogics;
+ private List<ST> ctxRefs;
+
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getStateName() {
+ return stateName;
+ }
+
+ public String getTriggerName() {
+ return triggerName;
+ }
+
+ public String getTriggerVersion() {
+ return triggerVersion;
+ }
+
+ public String getDefaultTask() {
+ return defaultTask;
+ }
+
+ public String getDefaultTaskVersion() {
+ return defaultTaskVersion;
+ }
+
+ public List<ST> getOutputs() {
+ return outputs;
+ }
+
+ public List<ST> getTasks() {
+ return tasks;
+ }
+
+ public List<ST> getTsLogic() {
+ return tsLogic;
+ }
+
+ public List<ST> getFinalizerLogics() {
+ return finalizerLogics;
+ }
+
+ public List<ST> getCtxRefs() {
+ return ctxRefs;
+ }
+
+ public PolicyStateDefBuilder setPolicyName(String policyName) {
+ this.policyName = policyName;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setStateName(String stateName) {
+ this.stateName = stateName;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setTriggerName(String triggerName) {
+ this.triggerName = triggerName;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setTriggerVersion(String triggerVersion) {
+ this.triggerVersion = triggerVersion;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setDefaultTask(String defaultTask) {
+ this.defaultTask = defaultTask;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setDefaultTaskVersion(String defaultTaskVersion) {
+ this.defaultTaskVersion = defaultTaskVersion;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setOutputs(List<ST> outputs) {
+ this.outputs = outputs;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setTasks(List<ST> tasks) {
+ this.tasks = tasks;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setTsLogic(List<ST> tsLogic) {
+ this.tsLogic = tsLogic;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setFinalizerLogics(List<ST> finalizerLogics) {
+ this.finalizerLogics = finalizerLogics;
+ return this;
+ }
+
+ public PolicyStateDefBuilder setCtxRefs(List<ST> ctxRefs) {
+ this.ctxRefs = ctxRefs;
+ return this;
+ }
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java
new file mode 100644
index 000000000..0ac7a3e98
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+public class PolicyStateTaskBuilder {
+
+ private String policyName;
+ private String version;
+ private String stateName;
+ private String taskLocalName;
+ private String taskName;
+ private String taskVersion;
+ private String outputType;
+ private String outputName;
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getStateName() {
+ return stateName;
+ }
+
+ public String getTaskLocalName() {
+ return taskLocalName;
+ }
+
+ public String getTaskName() {
+ return taskName;
+ }
+
+ public String getTaskVersion() {
+ return taskVersion;
+ }
+
+ public String getOutputType() {
+ return outputType;
+ }
+
+ public String getOutputName() {
+ return outputName;
+ }
+
+ public PolicyStateTaskBuilder setPolicyName(String policyName) {
+ this.policyName = policyName;
+ return this;
+ }
+
+ public PolicyStateTaskBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ public PolicyStateTaskBuilder setStateName(String stateName) {
+ this.stateName = stateName;
+ return this;
+ }
+
+ public PolicyStateTaskBuilder setTaskLocalName(String taskLocalName) {
+ this.taskLocalName = taskLocalName;
+ return this;
+ }
+
+ public PolicyStateTaskBuilder setTaskName(String taskName) {
+ this.taskName = taskName;
+ return this;
+ }
+
+ public PolicyStateTaskBuilder setTaskVersion(String taskVersion) {
+ this.taskVersion = taskVersion;
+ return this;
+ }
+
+ public PolicyStateTaskBuilder setOutputType(String outputType) {
+ this.outputType = outputType;
+ return this;
+ }
+
+ public PolicyStateTaskBuilder setOutputName(String outputName) {
+ this.outputName = outputName;
+ return this;
+ }
+
+}
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
index 615f2e903..e1f84e45e 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
@@ -315,10 +315,14 @@ public class CodeGeneratorCliEditorTest {
final List<ST> tsLogic = getTslForState(cg, st);
final List<ST> ctxRefs = getCtxtRefsForState(cg, st);
- final ST val = cg.createPolicyStateDef(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getName(st.getTrigger()), kig.getVersion(st.getTrigger()),
- kig.getName(st.getDefaultTask()), kig.getVersion(st.getDefaultTask()), outputs, tasks,
- tsLogic, finalizerLogics, ctxRefs);
+ final ST val = cg.createPolicyStateDef(new PolicyStateDefBuilder()
+ .setPolicyName(kig.getPName(skey)).setVersion(kig.getPVersion(skey))
+ .setStateName(kig.getLName(skey)).setTriggerName(kig.getName(st.getTrigger()))
+ .setTriggerVersion(kig.getVersion(st.getTrigger()))
+ .setDefaultTask(kig.getName(st.getDefaultTask()))
+ .setDefaultTaskVersion(kig.getVersion(st.getDefaultTask())).setOutputs(outputs)
+ .setTasks(tasks).setTsLogic(tsLogic).setFinalizerLogics(finalizerLogics)
+ .setCtxRefs(ctxRefs));
ret.add(val);
}
@@ -403,9 +407,12 @@ public class CodeGeneratorCliEditorTest {
final AxStateTaskReference tr = e.getValue();
final AxReferenceKey trkey = tr.getKey();
- final ST val = cg.createPolicyStateTask(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getLName(trkey), kig.getName(tkey), kig.getVersion(tkey),
- tr.getStateTaskOutputType().name(), kig.getLName(tr.getOutput()));
+ final ST val = cg.createPolicyStateTask(new PolicyStateTaskBuilder()
+ .setPolicyName(kig.getPName(skey)).setVersion(kig.getPVersion(skey))
+ .setStateName(kig.getLName(skey)).setTaskLocalName(kig.getLName(trkey))
+ .setTaskName(kig.getName(tkey)).setTaskVersion(kig.getVersion(tkey))
+ .setOutputType(tr.getStateTaskOutputType().name())
+ .setOutputName(kig.getLName(tr.getOutput())));
ret.add(val);
}
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
index f5f0d6625..d9616fda0 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
@@ -35,6 +35,8 @@ import org.apache.commons.lang3.Validate;
import org.onap.policy.apex.auth.clicodegen.CodeGenCliEditorBuilder;
import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor;
import org.onap.policy.apex.auth.clicodegen.EventDeclarationBuilder;
+import org.onap.policy.apex.auth.clicodegen.PolicyStateDefBuilder;
+import org.onap.policy.apex.auth.clicodegen.PolicyStateTaskBuilder;
import org.onap.policy.apex.auth.clicodegen.TaskDeclarationBuilder;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -370,9 +372,14 @@ public class Model2Cli {
final List<ST> tsLogic = getTslForState(cg, st);
final List<ST> ctxRefs = getCtxtRefsForState(cg, st);
- final ST val = cg.createPolicyStateDef(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getName(st.getTrigger()), kig.getVersion(st.getTrigger()), kig.getName(st.getDefaultTask()),
- kig.getVersion(st.getDefaultTask()), outputs, tasks, tsLogic, finalizerLogics, ctxRefs);
+ final ST val = cg.createPolicyStateDef(new PolicyStateDefBuilder()
+ .setPolicyName(kig.getPName(skey)).setVersion(kig.getPVersion(skey))
+ .setStateName(kig.getLName(skey)).setTriggerName(kig.getName(st.getTrigger()))
+ .setTriggerVersion(kig.getVersion(st.getTrigger()))
+ .setDefaultTask(kig.getName(st.getDefaultTask()))
+ .setDefaultTaskVersion(kig.getVersion(st.getDefaultTask())).setOutputs(outputs)
+ .setTasks(tasks).setTsLogic(tsLogic).setFinalizerLogics(finalizerLogics)
+ .setCtxRefs(ctxRefs));
ret.add(val);
}
@@ -457,9 +464,12 @@ public class Model2Cli {
final AxStateTaskReference tr = e.getValue();
final AxReferenceKey trkey = tr.getKey();
- final ST val = cg.createPolicyStateTask(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getLName(trkey), kig.getName(tkey), kig.getVersion(tkey), tr.getStateTaskOutputType().name(),
- kig.getLName(tr.getOutput()));
+ final ST val = cg.createPolicyStateTask(new PolicyStateTaskBuilder()
+ .setPolicyName(kig.getPName(skey)).setVersion(kig.getPVersion(skey))
+ .setStateName(kig.getLName(skey)).setTaskLocalName(kig.getLName(trkey))
+ .setTaskName(kig.getName(tkey)).setTaskVersion(kig.getVersion(tkey))
+ .setOutputType(tr.getStateTaskOutputType().name())
+ .setOutputName(kig.getLName(tr.getOutput())));
ret.add(val);
}