aboutsummaryrefslogtreecommitdiffstats
path: root/auth/cli-codegen/src
diff options
context:
space:
mode:
Diffstat (limited to 'auth/cli-codegen/src')
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java11
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java38
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java144
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java126
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java40
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java107
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java45
-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/PolicyStateTask.java39
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java106
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java42
-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.java74
13 files changed, 309 insertions, 730 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
index b123d9186..f2b4cbeea 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -20,7 +21,11 @@
package org.onap.policy.apex.auth.clicodegen;
-public class CliEditorContants {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CliEditorContants {
public static final String FINALIZER_LOGIC_NAME = "finalizerLogicName";
@@ -127,8 +132,4 @@ public class CliEditorContants {
public static final String SCOPE = "scope";
public static final String DEFINITIONS = "definitions";
-
- private CliEditorContants() {
- // Private constructor to prevent subclassing
- }
}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java
new file mode 100644
index 000000000..c889ac474
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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 lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+public class CodeGenCliEditor {
+ private String name;
+ private String version;
+ private String uuid;
+ private String description;
+ private String scope;
+ private boolean writable;
+ private String schemaName;
+ private String schemaVersion;
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java
deleted file mode 100644
index 933ecd56f..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 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 CodeGenCliEditorBuilder {
- private String name;
- private String version;
- private String uuid;
- private String description;
- private String scope;
- private boolean writable;
- private String schemaName;
- private String schemaVersion;
-
- /**
- * Set name.
- * @param name the name of the context album
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setName(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * Set version.
- * @param version the version of the context album
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /**
- * Set uuid.
- * @param uuid a UUID for the declaration
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- /**
- * Set description.
- * @param description a description for the context album
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * Set scope.
- * @param scope the scope
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setScope(String scope) {
- this.scope = scope;
- return this;
- }
-
- /**
- * Set writable.
- * @param writable a flag for writable context
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setWritable(boolean writable) {
- this.writable = writable;
- return this;
- }
-
- /**
- * Set schemaname.
- * @param schemaName the name of the schema
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- return this;
- }
-
- /**
- * Set schema version.
- * @param schemaVersion the version of the declaration
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setSchemaVersion(String schemaVersion) {
- this.schemaVersion = schemaVersion;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getScope() {
- return scope;
- }
-
- public boolean isWritable() {
- return writable;
- }
-
- public String getSchemaName() {
- return schemaName;
- }
-
- public String getSchemaVersion() {
- return schemaVersion;
- }
-}
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 6ad5fbc3c..87124cb8b 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
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -77,6 +78,7 @@ import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.VERSION;
import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.WRITABLE;
import java.util.List;
+import lombok.Getter;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroupFile;
@@ -102,6 +104,7 @@ public class CodeGeneratorCliEditor {
/**
* The ST for the model, loaded from the STG.
*/
+ @Getter
private final ST model;
/**
@@ -141,15 +144,6 @@ public class CodeGeneratorCliEditor {
}
/**
- * Returns the model.
- *
- * @return the model
- */
- public ST getModel() {
- return model;
- }
-
- /**
* Sets the default name space.
*
* @param nameSpace new name space, ignored if blank
@@ -185,18 +179,18 @@ public class CodeGeneratorCliEditor {
/**
* Adds a new context album declaration to the model.
*
- * @param codeGenCliEditorBuilder The parameters for the context album
+ * @param codeGenCliEditor The parameters for the context album
*/
- public void addContextAlbumDeclaration(CodeGenCliEditorBuilder codeGenCliEditorBuilder) {
+ public void addContextAlbumDeclaration(CodeGenCliEditor codeGenCliEditor) {
final var st = stg.getInstanceOf("ctxAlbumDecl");
- st.add(NAME, codeGenCliEditorBuilder.getName());
- st.add(VERSION, codeGenCliEditorBuilder.getVersion());
- st.add(UUID, codeGenCliEditorBuilder.getUuid());
- st.add(DESCRIPTION, codeGenCliEditorBuilder.getDescription());
- st.add(SCOPE, codeGenCliEditorBuilder.getScope());
- st.add(WRITABLE, codeGenCliEditorBuilder.isWritable());
- st.add(SCHEMA_NAME, codeGenCliEditorBuilder.getSchemaName());
- st.add(SCHEMA_VERSION, codeGenCliEditorBuilder.getSchemaVersion());
+ st.add(NAME, codeGenCliEditor.getName());
+ st.add(VERSION, codeGenCliEditor.getVersion());
+ st.add(UUID, codeGenCliEditor.getUuid());
+ st.add(DESCRIPTION, codeGenCliEditor.getDescription());
+ st.add(SCOPE, codeGenCliEditor.getScope());
+ st.add(WRITABLE, codeGenCliEditor.isWritable());
+ st.add(SCHEMA_NAME, codeGenCliEditor.getSchemaName());
+ st.add(SCHEMA_VERSION, codeGenCliEditor.getSchemaVersion());
model.add(DECLARATION, st);
}
@@ -245,20 +239,20 @@ public class CodeGeneratorCliEditor {
/**
* Adds a new event declaration to the model.
*
- * @param eventDeclarationBuilder param object for event declaration
+ * @param eventDeclaration param object for event declaration
*/
- public void addEventDeclaration(EventDeclarationBuilder eventDeclarationBuilder) {
+ public void addEventDeclaration(EventDeclaration eventDeclaration) {
final var st = stg.getInstanceOf("eventDecl");
- st.add(NAME, eventDeclarationBuilder.getName());
- st.add(VERSION, eventDeclarationBuilder.getVersion());
- st.add(UUID, eventDeclarationBuilder.getUuid());
- st.add(DESCRIPTION, eventDeclarationBuilder.getDescription());
- st.add(SOURCE, eventDeclarationBuilder.getSource());
- st.add(TARGET, eventDeclarationBuilder.getTarget());
- st.add(FIELDS, eventDeclarationBuilder.getFields());
-
- if (eventDeclarationBuilder.getNameSpace() != null) {
- st.add(NAME_SPACE, eventDeclarationBuilder.getNameSpace());
+ st.add(NAME, eventDeclaration.getName());
+ st.add(VERSION, eventDeclaration.getVersion());
+ st.add(UUID, eventDeclaration.getUuid());
+ st.add(DESCRIPTION, eventDeclaration.getDescription());
+ st.add(SOURCE, eventDeclaration.getSource());
+ st.add(TARGET, eventDeclaration.getTarget());
+ st.add(FIELDS, eventDeclaration.getFields());
+
+ if (eventDeclaration.getNameSpace() != null) {
+ st.add(NAME_SPACE, eventDeclaration.getNameSpace());
} else if (defaultNamespace != null) {
st.add(NAME_SPACE, defaultNamespace);
}
@@ -269,19 +263,19 @@ public class CodeGeneratorCliEditor {
/**
* Adds a new task declaration to the model.
*
- * @param taskDeclarationBuilder builder for the task declaration parameters
+ * @param taskDeclaration task declaration parameters
*/
- public void addTaskDeclaration(TaskDeclarationBuilder taskDeclarationBuilder) {
+ public void addTaskDeclaration(TaskDeclaration taskDeclaration) {
final var st = stg.getInstanceOf("taskDecl");
- 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());
+ st.add(NAME, taskDeclaration.getName());
+ st.add(VERSION, taskDeclaration.getVersion());
+ st.add(UUID, taskDeclaration.getUuid());
+ st.add(DESCRIPTION, taskDeclaration.getDescription());
+ st.add(INFIELDS, taskDeclaration.getInfields());
+ st.add(OUTFIELDS, taskDeclaration.getOutfields());
+ st.add(LOGIC, taskDeclaration.getLogic());
+ st.add(PARAMS, taskDeclaration.getParameters());
+ st.add(CONTEXT_REFS, taskDeclaration.getContextRefs());
model.add(DECLARATION, st);
}
@@ -392,19 +386,19 @@ public class CodeGeneratorCliEditor {
/**
* Creates a new policy state task definition for a task which belongs to a state which belongs to a policy.
*
- * @param policyStateTaskBuilder builder for the state task parameters
+ * @param policyStateTask state task parameters
* @return a CLI command for a policy state task definition
*/
- public ST createPolicyStateTask(PolicyStateTaskBuilder policyStateTaskBuilder) {
+ public ST createPolicyStateTask(PolicyStateTask policyStateTask) {
final var st = stg.getInstanceOf("policyStateTask");
- 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());
+ st.add(POLICY_NAME, policyStateTask.getPolicyName());
+ st.add(VERSION, policyStateTask.getVersion());
+ st.add(STATE_NAME, policyStateTask.getStateName());
+ st.add(TASK_LOCAL_NAME, policyStateTask.getTaskLocalName());
+ st.add(TASK_NAME, policyStateTask.getTaskName());
+ st.add(TASK_VERSION, policyStateTask.getTaskVersion());
+ st.add(OUTPUT_TYPE, policyStateTask.getOutputType());
+ st.add(OUTPUT_NAME, policyStateTask.getOutputName());
return st;
}
@@ -437,23 +431,23 @@ public class CodeGeneratorCliEditor {
/**
* Creates a new policy state definition for a state which belongs to a policy.
*
- * @param policyStateDefBuilder builder for the state definition parameters
+ * @param policyStateDef state definition parameters
* @return a CLI command for a policy state definition
*/
- public ST createPolicyStateDef(PolicyStateDefBuilder policyStateDefBuilder) {
+ public ST createPolicyStateDef(PolicyStateDef policyStateDef) {
final var st = stg.getInstanceOf("policyStateDef");
- 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());
+ st.add(POLICY_NAME, policyStateDef.getPolicyName());
+ st.add(VERSION, policyStateDef.getVersion());
+ st.add(STATE_NAME, policyStateDef.getStateName());
+ st.add(TRIGGER_NAME, policyStateDef.getTriggerName());
+ st.add(TRIGGER_VERSION, policyStateDef.getTriggerVersion());
+ st.add(DEFAULT_TASK, policyStateDef.getDefaultTask());
+ st.add(DEFAULT_TASK_VERSION, policyStateDef.getDefaultTaskVersion());
+ st.add(OUTPUTS, policyStateDef.getOutputs());
+ st.add(TASKS, policyStateDef.getTasks());
+ st.add(TS_LOGIC, policyStateDef.getTsLogic());
+ st.add(FINALIZER_LOGICS, policyStateDef.getFinalizerLogics());
+ st.add(CTX_REFS, policyStateDef.getCtxRefs());
return st;
}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java
new file mode 100644
index 000000000..55d649205
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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 lombok.Builder;
+import lombok.Getter;
+import org.stringtemplate.v4.ST;
+
+@Getter
+@Builder
+public class EventDeclaration {
+ private String name;
+ private String version;
+ private String uuid;
+ private String description;
+ private String nameSpace;
+ private String source;
+ private String target;
+ private List<ST> fields;
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java
deleted file mode 100644
index 93b5a406e..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 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 EventDeclarationBuilder {
- private String name;
- private String version;
- private String uuid;
- private String description;
- private String nameSpace;
- private String source;
- private String target;
- private List<ST> fields;
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getNameSpace() {
- return nameSpace;
- }
-
- public String getSource() {
- return source;
- }
-
- public String getTarget() {
- return target;
- }
-
- public List<ST> getFields() {
- return fields;
- }
-
- public EventDeclarationBuilder setName(String name) {
- this.name = name;
- return this;
- }
-
- public EventDeclarationBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- public EventDeclarationBuilder setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- public EventDeclarationBuilder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- public EventDeclarationBuilder setNameSpace(String nameSpace) {
- this.nameSpace = nameSpace;
- return this;
- }
-
- public EventDeclarationBuilder setSource(String source) {
- this.source = source;
- return this;
- }
-
- public EventDeclarationBuilder setTarget(String target) {
- this.target = target;
- return this;
- }
-
- public EventDeclarationBuilder setFields(List<ST> fields) {
- this.fields = fields;
- return this;
- }
-}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java
new file mode 100644
index 000000000..5edf92b70
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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 lombok.Builder;
+import lombok.Getter;
+import org.stringtemplate.v4.ST;
+
+@Getter
+@Builder
+public class PolicyStateDef {
+
+ 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;
+}
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
deleted file mode 100644
index ea5cc6610..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*-
- * ============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/PolicyStateTask.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTask.java
new file mode 100644
index 000000000..414a2f277
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTask.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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 lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+public class PolicyStateTask {
+
+ private String policyName;
+ private String version;
+ private String stateName;
+ private String taskLocalName;
+ private String taskName;
+ private String taskVersion;
+ private String outputType;
+ private String outputName;
+}
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
deleted file mode 100644
index 0ac7a3e98..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============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/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java
new file mode 100644
index 000000000..ed03d4c5f
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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 lombok.Builder;
+import lombok.Getter;
+import org.stringtemplate.v4.ST;
+
+@Getter
+@Builder
+public class TaskDeclaration {
+
+ 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;
+}
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
deleted file mode 100644
index 566fa03d8..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*-
- * ============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 d6cf1686b..8ad8b0213 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
@@ -4,6 +4,7 @@
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2020 Nordix Foundation
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -111,9 +112,9 @@ public class CodeGeneratorCliEditorTest {
final List<ST> parameters = getParametersForTask(codeGen, t);
final List<ST> contextRefs = getCtxtRefsForTask(codeGen, t);
- codeGen.addTaskDeclaration(new TaskDeclarationBuilder().setName(kig.getName(key))
- .setVersion(kig.getVersion(key)).setUuid(kig.getUuid(key)).setDescription(kig.getDesc(key))
- .setLogic(logic).setParameters(parameters).setContextRefs(contextRefs));
+ codeGen.addTaskDeclaration(TaskDeclaration.builder().name(kig.getName(key))
+ .version(kig.getVersion(key)).uuid(kig.getUuid(key)).description(kig.getDesc(key))
+ .logic(logic).parameters(parameters).contextRefs(contextRefs).build());
}
// 3: events
@@ -122,15 +123,16 @@ public class CodeGeneratorCliEditorTest {
final List<ST> fields = getParametersForEvent(codeGen, e);
codeGen.addEventDeclaration(
- new EventDeclarationBuilder()
- .setName(kig.getName(key))
- .setVersion(kig.getVersion(key))
- .setUuid(kig.getUuid(key))
- .setDescription(kig.getDesc(key))
- .setNameSpace(e.getNameSpace())
- .setSource(e.getSource())
- .setTarget(e.getTarget())
- .setFields(fields));
+ EventDeclaration.builder()
+ .name(kig.getName(key))
+ .version(kig.getVersion(key))
+ .uuid(kig.getUuid(key))
+ .description(kig.getDesc(key))
+ .nameSpace(e.getNameSpace())
+ .source(e.getSource())
+ .target(e.getTarget())
+ .fields(fields)
+ .build());
}
// 4: context albums
@@ -138,15 +140,16 @@ public class CodeGeneratorCliEditorTest {
final AxArtifactKey key = a.getKey();
codeGen.addContextAlbumDeclaration(
- new CodeGenCliEditorBuilder()
- .setName(kig.getName(key))
- .setVersion(kig.getVersion(key))
- .setUuid(kig.getUuid(key))
- .setDescription(kig.getDesc(key))
- .setScope(a.getScope())
- .setWritable(a.isWritable())
- .setSchemaName(kig.getName(a.getItemSchema()))
- .setSchemaVersion(kig.getVersion(a.getItemSchema())));
+ CodeGenCliEditor.builder()
+ .name(kig.getName(key))
+ .version(kig.getVersion(key))
+ .uuid(kig.getUuid(key))
+ .description(kig.getDesc(key))
+ .scope(a.getScope())
+ .writable(a.isWritable())
+ .schemaName(kig.getName(a.getItemSchema()))
+ .schemaVersion(kig.getVersion(a.getItemSchema()))
+ .build());
}
// 5: policies
@@ -261,14 +264,14 @@ public class CodeGeneratorCliEditorTest {
final List<ST> tsLogic = getTslForState(cg, st);
final List<ST> ctxRefs = getCtxtRefsForState(cg, st);
- 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));
+ final ST val = cg.createPolicyStateDef(PolicyStateDef.builder()
+ .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
+ .stateName(kig.getLName(skey)).triggerName(kig.getName(st.getTrigger()))
+ .triggerVersion(kig.getVersion(st.getTrigger()))
+ .defaultTask(kig.getName(st.getDefaultTask()))
+ .defaultTaskVersion(kig.getVersion(st.getDefaultTask())).outputs(outputs)
+ .tasks(tasks).tsLogic(tsLogic).finalizerLogics(finalizerLogics)
+ .ctxRefs(ctxRefs).build());
ret.add(val);
}
@@ -353,12 +356,13 @@ public class CodeGeneratorCliEditorTest {
final AxStateTaskReference tr = e.getValue();
final AxReferenceKey trkey = tr.getKey();
- 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())));
+ final ST val = cg.createPolicyStateTask(PolicyStateTask.builder()
+ .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
+ .stateName(kig.getLName(skey)).taskLocalName(kig.getLName(trkey))
+ .taskName(kig.getName(tkey)).taskVersion(kig.getVersion(tkey))
+ .outputType(tr.getStateTaskOutputType().name())
+ .outputName(kig.getLName(tr.getOutput()))
+ .build());
ret.add(val);
}