summaryrefslogtreecommitdiffstats
path: root/model/model-api
diff options
context:
space:
mode:
Diffstat (limited to 'model/model-api')
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java61
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java48
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java17
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java276
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java122
-rw-r--r--model/model-api/src/test/resources/models/PolicyModel.xml64
6 files changed, 33 insertions, 555 deletions
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
index 741fbdc90..fab6ba163 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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=========================================================
*/
@@ -456,7 +457,7 @@ public interface ApexEditorApi {
ApexApiResult deleteTaskLogic(final String name, final String version);
/**
- * Create a task input field.
+ * Create a task field.
*
* @param name name of the task
* @param version version of the task, set to null to use the latest version
@@ -467,11 +468,11 @@ public interface ApexEditorApi {
* @param optional true if the task field is optional, false otherwise
* @return result of the operation
*/
- ApexApiResult createTaskInputField(final String name, final String version, final String fieldName,
+ ApexApiResult createTaskField(final String name, final String version, final String fieldName,
final String contextSchemaName, final String contextSchemaVersion, boolean optional);
/**
- * List task input fields.
+ * Handle a task field.
*
* @param name name of the task
* @param version version of the task, set to null to use the latest version
@@ -479,53 +480,7 @@ public interface ApexEditorApi {
* task
* @return result of the operation
*/
- ApexApiResult listTaskInputField(final String name, final String version, final String fieldName);
-
- /**
- * Delete a task input field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the input field, set to null to delete all input fields
- * @return result of the operation
- */
- ApexApiResult deleteTaskInputField(final String name, final String version, final String fieldName);
-
- /**
- * Create a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field
- * @param contextSchemaName name of the output field context schema
- * @param contextSchemaVersion version of the output field context schema, set to null to use
- * the latest version
- * @param optional true if the task field is optional, false otherwise
- * @return result of the operation
- */
- ApexApiResult createTaskOutputField(final String name, final String version, final String fieldName,
- final String contextSchemaName, final String contextSchemaVersion, boolean optional);
-
- /**
- * List task output fields.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName field name of the output field, set to null to list all output fields of the
- * task
- * @return result of the operation
- */
- ApexApiResult listTaskOutputField(final String name, final String version, final String fieldName);
-
- /**
- * Delete a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field, set to null to delete all output fields
- * @return result of the operation
- */
- ApexApiResult deleteTaskOutputField(final String name, final String version, final String fieldName);
+ ApexApiResult handleTaskField(final String name, final String version, final String fieldName);
/**
* Create a task parameter.
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
index 5e8d1a5c7..67083bfe8 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
@@ -26,6 +26,7 @@ package org.onap.policy.apex.model.modelapi.impl;
import java.util.Properties;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
+import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
import org.onap.policy.apex.model.modelapi.ApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.slf4j.Logger;
@@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory;
*/
public final class ApexModelImpl implements ApexModel {
- private static final String FIELDS_DEPRECATED_WARN_MSG =
+ public static final String FIELDS_DEPRECATED_WARN_MSG =
"inputFields and outputFields are deprecated from Task definition and will be removed. "
+ "Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition";
@@ -444,56 +445,19 @@ public final class ApexModelImpl implements ApexModel {
* {@inheritDoc}.
*/
@Override
- public ApexApiResult createTaskInputField(final String name, final String version, final String fieldName,
+ public ApexApiResult createTaskField(final String name, final String version, final String fieldName,
final String dataTypeName, final String dataTypeVersion, final boolean optional) {
LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.createTaskInputField(name, version, fieldName, dataTypeName, dataTypeVersion, optional);
+ return new ApexApiResult(Result.SUCCESS, FIELDS_DEPRECATED_WARN_MSG);
}
/**
* {@inheritDoc}.
*/
@Override
- public ApexApiResult listTaskInputField(final String name, final String version, final String fieldName) {
+ public ApexApiResult handleTaskField(final String name, final String version, final String fieldName) {
LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.listTaskInputField(name, version, fieldName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult deleteTaskInputField(final String name, final String version, final String fieldName) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.deleteTaskInputField(name, version, fieldName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult createTaskOutputField(final String name, final String version, final String fieldName,
- final String dataTypeName, final String dataTypeVersion, final boolean optional) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.createTaskOutputField(name, version, fieldName, dataTypeName, dataTypeVersion, optional);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult listTaskOutputField(final String name, final String version, final String fieldName) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.listTaskOutputField(name, version, fieldName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult deleteTaskOutputField(final String name, final String version, final String fieldName) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.deleteTaskOutputField(name, version, fieldName);
+ return new ApexApiResult(Result.SUCCESS, FIELDS_DEPRECATED_WARN_MSG);
}
/**
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
index 9480702ac..c36e7e8a5 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
@@ -1112,10 +1112,17 @@ public class PolicyFacade {
ApexApiResult.Result.FAILED, "output type " + builder.getOutputType() + " invalid");
}
+ String outputRefName = outputRefKey.getLocalName();
+ // in case of SFL, outgoing event will be same for all state outputs that are part of SFL.So, take any entry
+ if (AxStateTaskOutputType.LOGIC.equals(stateTaskOutputType)) {
+ outputRefName = state.getStateOutputs().keySet().iterator().next();
+ }
+
// add input and output events to the task based on state definition
- if (state.getStateOutputs().containsKey(outputRefKey.getLocalName())) {
- populateIoEventsToTask(state, task, outputRefKey);
+ if (state.getStateOutputs().containsKey(outputRefName)) {
+ populateIoEventsToTask(state, task, outputRefName);
}
+
state.getTaskReferences().put(task.getKey(),
new AxStateTaskReference(refKey, stateTaskOutputType, outputRefKey));
return new ApexApiResult();
@@ -1124,18 +1131,18 @@ public class PolicyFacade {
}
}
- private void populateIoEventsToTask(final AxState state, final AxTask task, final AxReferenceKey outputRefKey) {
+ private void populateIoEventsToTask(final AxState state, final AxTask task, final String outputRefName) {
AxEvent triggerEvent = apexModel.getPolicyModel().getEvents().get(state.getTrigger());
task.setInputEvent(triggerEvent);
Map<String, AxEvent> outputEvents = new TreeMap<>();
if (state.getNextStateSet().isEmpty()
|| state.getNextStateSet().contains(AxReferenceKey.getNullKey().getLocalName())) {
- state.getStateOutputs().get(outputRefKey.getLocalName()).getOutgoingEventSet()
+ state.getStateOutputs().get(outputRefName).getOutgoingEventSet()
.forEach(outgoingEventKey -> outputEvents.put(outgoingEventKey.getName(),
apexModel.getPolicyModel().getEvents().get(outgoingEventKey)));
} else {
AxArtifactKey outgoingEventKey =
- state.getStateOutputs().get(outputRefKey.getLocalName()).getOutgoingEvent();
+ state.getStateOutputs().get(outputRefName).getOutgoingEvent();
outputEvents.put(outgoingEventKey.getName(),
apexModel.getPolicyModel().getEvents().get(outgoingEventKey));
}
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
index a6f4a87cb..ad1edd72e 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -30,9 +31,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelStringWriter;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import org.onap.policy.apex.model.eventmodel.concepts.AxInputField;
-import org.onap.policy.apex.model.eventmodel.concepts.AxOutputField;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
import org.onap.policy.apex.model.modelapi.ApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
@@ -356,278 +354,6 @@ public class TaskFacade {
}
/**
- * Create a task input field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the input field
- * @param contextSchemaName name of the input field context schema
- * @param contextSchemaVersion version of the input field context schema, set to null to use the
- * latest version
- * @param optional true if the task field is optional, false otherwise
- * @return result of the operation
- */
- public ApexApiResult createTaskInputField(final String name, final String version, final String fieldName,
- final String contextSchemaName, final String contextSchemaVersion, final boolean optional) {
- try {
- Assertions.argumentNotNull(fieldName, "fieldName may not be null");
-
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final AxReferenceKey refKey =
- new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(), "inputFields", fieldName);
-
- if (task.getInputFields().containsKey(refKey.getLocalName())) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
- }
-
- final AxContextSchema schema =
- apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
- if (schema == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
- }
-
- task.getInputFields().put(refKey.getLocalName(), new AxInputField(refKey, schema.getKey(), optional));
- return new ApexApiResult();
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
- * List task input fields.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName field name of the input field, set to null to list all input fields of the
- * task
- * @return result of the operation
- */
- public ApexApiResult listTaskInputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- if (fieldName != null) {
- final AxInputField inputField = task.getInputFields().get(fieldName);
- if (inputField != null) {
- return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxInputField>(false).writeString(inputField, AxInputField.class,
- jsonMode));
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + inputField + DOES_NOT_EXIST);
- }
- } else {
- if (task.getInputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no input fields defined on task " + task.getKey().getId());
- }
-
- final ApexApiResult result = new ApexApiResult();
- for (final AxInputField field : task.getInputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxInputField>(false).writeString(field,
- AxInputField.class, jsonMode));
- }
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
-
- }
-
- /**
- * Delete a task input field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the input field, set to null to delete all input fields
- * @return result of the operation
- */
- public ApexApiResult deleteTaskInputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final ApexApiResult result = new ApexApiResult();
- if (fieldName != null) {
- if (task.getInputFields().containsKey(fieldName)) {
- result.addMessage(new ApexModelStringWriter<AxInputField>(false)
- .writeString(task.getInputFields().get(fieldName), AxInputField.class, jsonMode));
- task.getInputFields().remove(fieldName);
- return result;
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + fieldName + DOES_NOT_EXIST);
- }
- } else {
- if (task.getInputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no input fields defined on task " + task.getKey().getId());
- }
-
- for (final AxInputField field : task.getInputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxInputField>(false).writeString(field,
- AxInputField.class, jsonMode));
- }
- task.getInputFields().clear();
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
-
- }
-
- /**
- * Create a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field
- * @param contextSchemaName name of the output field context schema
- * @param contextSchemaVersion version of the output field context schema, set to null to use
- * the latest version
- * @param optional true if the task field is optional, false otherwise
- * @return result of the operation
- */
- public ApexApiResult createTaskOutputField(final String name, final String version, final String fieldName,
- final String contextSchemaName, final String contextSchemaVersion, final boolean optional) {
- try {
- Assertions.argumentNotNull(fieldName, "fieldName may not be null");
-
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final AxReferenceKey refKey =
- new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(), "outputFields", fieldName);
-
- if (task.getOutputFields().containsKey(refKey.getLocalName())) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
- }
-
- final AxContextSchema schema =
- apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
- if (schema == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
- }
-
- task.getOutputFields().put(refKey.getLocalName(), new AxOutputField(refKey, schema.getKey(), optional));
- return new ApexApiResult();
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
- * List task output fields.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName field name of the output field, set to null to list all output fields of the
- * task
- * @return result of the operation
- */
- public ApexApiResult listTaskOutputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- if (fieldName != null) {
- final AxOutputField outputField = task.getOutputFields().get(fieldName);
- if (outputField != null) {
- return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxOutputField>(false).writeString(outputField,
- AxOutputField.class, jsonMode));
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + outputField + DOES_NOT_EXIST);
- }
- } else {
- if (task.getOutputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no output fields defined on task " + task.getKey().getId());
- }
-
- final ApexApiResult result = new ApexApiResult();
- for (final AxOutputField field : task.getOutputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxOutputField>(false).writeString(field,
- AxOutputField.class, jsonMode));
- }
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
- * Delete a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field, set to null to delete all output fields
- * @return result of the operation
- */
- public ApexApiResult deleteTaskOutputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final ApexApiResult result = new ApexApiResult();
- if (fieldName != null) {
- if (task.getOutputFields().containsKey(fieldName)) {
- result.addMessage(new ApexModelStringWriter<AxOutputField>(false)
- .writeString(task.getOutputFields().get(fieldName), AxOutputField.class, jsonMode));
- task.getOutputFields().remove(fieldName);
- return result;
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + fieldName + DOES_NOT_EXIST);
- }
- } else {
- if (task.getOutputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no output fields defined on task " + task.getKey().getId());
- }
-
- for (final AxOutputField field : task.getOutputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxOutputField>(false).writeString(field,
- AxOutputField.class, jsonMode));
- }
- task.getOutputFields().clear();
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
* Create a task parameter.
*
* @param name name of the task
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
index f2c41318c..026f67c29 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -24,6 +25,7 @@ package org.onap.policy.apex.model.modelapi;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl;
/**
* Test tasks for API tests.
@@ -214,124 +216,12 @@ public class ApexEditorApiTaskTest {
result = apexModel.deleteTaskLogic("MyTask002", "0.0.2");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createTaskInputField("MyTask123", null, "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "4.5.6", "NewField00", null, null, true);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "0.1.4", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", null, null, true);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, true);
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1",
- false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2", true);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", null, "NewField02", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", null, "NewField03", "eventContextItem0", null, true);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.listTaskInputField("@£$%", null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.1", null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField01");
+ result = apexModel.createTaskField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField02");
+ assertEquals(ApexModelImpl.FIELDS_DEPRECATED_WARN_MSG, result.getMessage().trim());
+ result = apexModel.handleTaskField("MyTask002", "0.0.2", "NewField01");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.deleteTaskInputField("@£$%", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.deleteTaskInputField("NonExistantTask", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskInputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskInputField("MyTask002", null, "NewField02");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(3, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.deleteTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask123", null, "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "4.5.6", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "0.1.4", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1",
- false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2",
- false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", null, "NewField02", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", null, "NewField03", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.listTaskOutputField("@£$%", null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.1", null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField01");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField02");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.deleteTaskOutputField("@£$%", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.deleteTaskOutputField("NonExistantTask", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskOutputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskOutputField("MyTask002", null, "NewField02");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(3, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.deleteTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ assertEquals(ApexModelImpl.FIELDS_DEPRECATED_WARN_MSG, result.getMessage().trim());
result = apexModel.createTaskParameter("MyTask123", null, "NewPar00", null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
diff --git a/model/model-api/src/test/resources/models/PolicyModel.xml b/model/model-api/src/test/resources/models/PolicyModel.xml
index e3bf59f29..e47e21afc 100644
--- a/model/model-api/src/test/resources/models/PolicyModel.xml
+++ b/model/model-api/src/test/resources/models/PolicyModel.xml
@@ -402,70 +402,6 @@
<name>task</name>
<version>0.0.1</version>
</key>
- <inputFields>
- <entry>
- <key>IEPAR0</key>
- <value>
- <key>IEPAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>IEPAR1</key>
- <value>
- <key>IEPAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- </inputFields>
- <outputFields>
- <entry>
- <key>OE0PAR0</key>
- <value>
- <key>OE0PAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE0PAR1</key>
- <value>
- <key>OE0PAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE1PAR0</key>
- <value>
- <key>OE1PAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE1PAR1</key>
- <value>
- <key>OE1PAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- </outputFields>
<taskParameters>
<entry>
<key>taskParameter0</key>