aboutsummaryrefslogtreecommitdiffstats
path: root/auth/cli-codegen/src
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2019-02-18 18:27:51 +0900
committerarindamm <arind.mondal@samsung.com>2019-02-20 10:59:42 +0900
commit517610a8a99a416ba4e81b333dea7deca10caed2 (patch)
treefb2c291ee1ca69a6f616efbc856fb294e2405c70 /auth/cli-codegen/src
parent05df038e0b09bfd5f0c9bfc1e8aa10f9c97f39a4 (diff)
Fix sonar code smell
Issue-ID: POLICY-1523 Change-Id: I24f9fe5811bb93597efe79c98572c5249e74026c Signed-off-by: arindamm <arind.mondal@samsung.com>
Diffstat (limited to 'auth/cli-codegen/src')
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java23
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java118
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java8
3 files changed, 135 insertions, 14 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 acfc087ac..0636bbef6 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -278,19 +279,17 @@ public class CodeGeneratorCliEditor {
* @param parameters any task parameter
* @param contextRefs any context reference
*/
- public void addTaskDeclaration(final String name, final String version, final String uuid, final String description,
- final List<ST> infields, final List<ST> outfields, final ST logic, final List<ST> parameters,
- final List<ST> contextRefs) {
+ public void addTaskDeclaration(TaskDeclarationBuilder taskDeclarationBuilder) {
final ST st = stg.getInstanceOf("taskDecl");
- st.add(NAME, name);
- st.add(VERSION, version);
- st.add(UUID, uuid);
- st.add(DESCRIPTION, description);
- st.add(INFIELDS, infields);
- st.add(OUTFIELDS, outfields);
- st.add(LOGIC, logic);
- st.add(PARAMS, parameters);
- st.add(CONTEXT_REFS, contextRefs);
+ st.add(NAME, taskDeclarationBuilder.getName());
+ st.add(VERSION, taskDeclarationBuilder.getVersion());
+ st.add(UUID, taskDeclarationBuilder.getUuid());
+ st.add(DESCRIPTION, taskDeclarationBuilder.getDescription());
+ st.add(INFIELDS, taskDeclarationBuilder.getInfields());
+ st.add(OUTFIELDS, taskDeclarationBuilder.getOutfields());
+ st.add(LOGIC, taskDeclarationBuilder.getLogic());
+ st.add(PARAMS, taskDeclarationBuilder.getParameters());
+ st.add(CONTEXT_REFS, taskDeclarationBuilder.getContextRefs());
model.add(DECLARATION, st);
}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java
new file mode 100644
index 000000000..566fa03d8
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java
@@ -0,0 +1,118 @@
+/*-
+ * ============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 TaskDeclarationBuilder {
+
+ private String name;
+ private String version;
+ private String uuid;
+ private String description;
+ private List<ST> infields;
+ private List<ST> outfields;
+ private ST logic;
+ private List<ST> parameters;
+ private List<ST> contextRefs;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public List<ST> getInfields() {
+ return infields;
+ }
+
+ public List<ST> getOutfields() {
+ return outfields;
+ }
+
+ public ST getLogic() {
+ return logic;
+ }
+
+ public List<ST> getParameters() {
+ return parameters;
+ }
+
+ public List<ST> getContextRefs() {
+ return contextRefs;
+ }
+
+ public TaskDeclarationBuilder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setUuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setInfields(List<ST> infields) {
+ this.infields = infields;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setOutfields(List<ST> outfields) {
+ this.outfields = outfields;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setLogic(ST logic) {
+ this.logic = logic;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setParameters(List<ST> parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+
+ public TaskDeclarationBuilder setContextRefs(List<ST> contextRefs) {
+ this.contextRefs = contextRefs;
+ 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 e1bf3b298..615f2e903 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -120,8 +121,11 @@ public class CodeGeneratorCliEditorTest {
final List<ST> parameters = getParametersForTask(codeGen, t);
final List<ST> contextRefs = getCtxtRefsForTask(codeGen, t);
- codeGen.addTaskDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- infields, outfields, logic, parameters, contextRefs);
+ codeGen.addTaskDeclaration(
+ new TaskDeclarationBuilder().setName(kig.getName(key)).setVersion(kig.getVersion(key))
+ .setUuid(kig.getUuid(key)).setDescription(kig.getDesc(key)).setInfields(infields)
+ .setOutfields(outfields).setLogic(logic).setParameters(parameters)
+ .setContextRefs(contextRefs));
}
// 3: events