/root> #-------------------------------------------------------------------------------
/root> # ============LICENSE_START=======================================================
/root> #  Copyright (C) 2019 Nordix Foundation.
/root> # ================================================================================
/root> # Licensed under the Apache License, Version 2.0 (the "License");
/root> # you may not use this file except in compliance with the License.
/root> # You may obtain a copy of the License at
/root> #
/root> #      http://www.apache.org/licenses/LICENSE-2.0
/root> #
/root> # Unless required by applicable law or agreed to in writing, software
/root> # distributed under the License is distributed on an "AS IS" BASIS,
/root> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/root> # See the License for the specific language governing permissions and
/root> # limitations under the License.
/root> #
/root> # SPDX-License-Identifier: Apache-2.0
/root> # ============LICENSE_END=========================================================
/root> #-------------------------------------------------------------------------------
/root> 
/root> model create name=ExecutionPropertiesTestPolicyModel
result: SUCCESS

/root> 
/root> schema create name=SimpleStringType  flavour=Java schema=java.lang.String
result: SUCCESS

/root> schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer
result: SUCCESS

/root> 
/root> event create name=RunTestEvent nameSpace=org.onap.policy.apex.domains.test source=JUNIT target=apex
result: SUCCESS

/root> event parameter create name=RunTestEvent parName=testToRun schemaName=SimpleStringType
result: SUCCESS

/root> 
/root> task create name=ReadOnlyTask
result: SUCCESS

/root> 
/root> task inputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=ReadOnlyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());
executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToDefinedTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToDefinedTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("hello", "world");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=DefinedToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=DefinedToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().clear();

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=AddPropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=AddPropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("goodbye", "mars");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=RemovePropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=RemovePropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().remove("hello");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> policy create name=ExecutionPropertiesTestPolicy template=freestyle firstState=RunTestState
result: SUCCESS

/root> 
/root> policy state create name=ExecutionPropertiesTestPolicy stateName=RunTestState triggerName=RunTestEvent defaultTaskName=ReadOnlyTask
result: SUCCESS

/root> policy state output create name=ExecutionPropertiesTestPolicy stateName=RunTestState outputName=TestFinalOutput eventName=RunTestEvent
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=ReadOnlyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToDefinedTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=DefinedToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=AddPropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=RemovePropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> 
/root> policy state selecttasklogic create name=ExecutionPropertiesTestPolicy stateName=RunTestState logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug("testToRun:" +  executor.getInFields().get("testToRun"));

var returnValue = true;

// Convert Java string to a Javascript variable
var testToRun = String(executor.getInFields().get("testToRun")).valueOf();

switch (testToRun) {
    case "ReadOnly":
        executor.subject.getTaskKey("ReadOnlyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToEmpty":
        executor.subject.getTaskKey("EmptyToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToDefined":
        executor.subject.getTaskKey("EmptyToDefinedTask").copyTo(executor.selectedTask);
        break;

    case "DefinedToEmpty":
        executor.subject.getTaskKey("DefinedToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "RemoveProperty":
        executor.subject.getTaskKey("RemovePropertyTask").copyTo(executor.selectedTask);
        break;

    case "AddProperty":
        executor.subject.getTaskKey("AddPropertyTask").copyTo(executor.selectedTask);
        break;

    default:
        executor.logger.debug("invalid value for testToRun:" +  executor.getInFields().get("testToRun"));
        returnValue = false;
}

executor.logger.debug("Selected Task:" + executor.selectedTask);

returnValue;


LE
result: SUCCESS

/root> 
/root> validate
result: SUCCESS
{
  "name": "ExecutionPropertiesTestPolicyModel",
  "version": "0.0.1"
}

***observations noted during validation of model***
AxArtifactKey:(name=ExecutionPropertiesTestPolicyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty
********************************

/root> 
/root> /root> #-------------------------------------------------------------------------------
/root> # ============LICENSE_START=======================================================
/root> #  Copyright (C) 2019 Nordix Foundation.
/root> # ================================================================================
/root> # Licensed under the Apache License, Version 2.0 (the "License");
/root> # you may not use this file except in compliance with the License.
/root> # You may obtain a copy of the License at
/root> #
/root> #      http://www.apache.org/licenses/LICENSE-2.0
/root> #
/root> # Unless required by applicable law or agreed to in writing, software
/root> # distributed under the License is distributed on an "AS IS" BASIS,
/root> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/root> # See the License for the specific language governing permissions and
/root> # limitations under the License.
/root> #
/root> # SPDX-License-Identifier: Apache-2.0
/root> # ============LICENSE_END=========================================================
/root> #-------------------------------------------------------------------------------
/root> 
/root> model create name=ExecutionPropertiesTestPolicyModel
result: SUCCESS

/root> 
/root> schema create name=SimpleStringType  flavour=Java schema=java.lang.String
result: SUCCESS

/root> schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer
result: SUCCESS

/root> 
/root> event create name=RunTestEvent nameSpace=org.onap.policy.apex.domains.test source=JUNIT target=apex
result: SUCCESS

/root> event parameter create name=RunTestEvent parName=testToRun schemaName=SimpleStringType
result: SUCCESS

/root> 
/root> task create name=ReadOnlyTask
result: SUCCESS

/root> 
/root> task inputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=ReadOnlyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());
executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToDefinedTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToDefinedTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("hello", "world");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=DefinedToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=DefinedToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().clear();

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=AddPropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=AddPropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("goodbye", "mars");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=RemovePropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=RemovePropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().remove("hello");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> policy create name=ExecutionPropertiesTestPolicy template=freestyle firstState=RunTestState
result: SUCCESS

/root> 
/root> policy state create name=ExecutionPropertiesTestPolicy stateName=RunTestState triggerName=RunTestEvent defaultTaskName=ReadOnlyTask
result: SUCCESS

/root> policy state output create name=ExecutionPropertiesTestPolicy stateName=RunTestState outputName=TestFinalOutput eventName=RunTestEvent
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=ReadOnlyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToDefinedTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=DefinedToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=AddPropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=RemovePropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> 
/root> policy state selecttasklogic create name=ExecutionPropertiesTestPolicy stateName=RunTestState logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug("testToRun:" +  executor.getInFields().get("testToRun"));

var returnValue = true;

// Convert Java string to a Javascript variable
var testToRun = String(executor.getInFields().get("testToRun")).valueOf();

switch (testToRun) {
    case "ReadOnly":
        executor.subject.getTaskKey("ReadOnlyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToEmpty":
        executor.subject.getTaskKey("EmptyToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToDefined":
        executor.subject.getTaskKey("EmptyToDefinedTask").copyTo(executor.selectedTask);
        break;

    case "DefinedToEmpty":
        executor.subject.getTaskKey("DefinedToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "RemoveProperty":
        executor.subject.getTaskKey("RemovePropertyTask").copyTo(executor.selectedTask);
        break;

    case "AddProperty":
        executor.subject.getTaskKey("AddPropertyTask").copyTo(executor.selectedTask);
        break;

    default:
        executor.logger.debug("invalid value for testToRun:" +  executor.getInFields().get("testToRun"));
        returnValue = false;
}

executor.logger.debug("Selected Task:" + executor.selectedTask);

returnValue;


LE
result: SUCCESS

/root> 
/root> validate
result: SUCCESS
{
  "name": "ExecutionPropertiesTestPolicyModel",
  "version": "0.0.1"
}

***observations noted during validation of model***
AxArtifactKey:(name=ExecutionPropertiesTestPolicyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty
********************************

/root> 
/root> /root> #-------------------------------------------------------------------------------
/root> # ============LICENSE_START=======================================================
/root> #  Copyright (C) 2019 Nordix Foundation.
/root> # ================================================================================
/root> # Licensed under the Apache License, Version 2.0 (the "License");
/root> # you may not use this file except in compliance with the License.
/root> # You may obtain a copy of the License at
/root> #
/root> #      http://www.apache.org/licenses/LICENSE-2.0
/root> #
/root> # Unless required by applicable law or agreed to in writing, software
/root> # distributed under the License is distributed on an "AS IS" BASIS,
/root> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/root> # See the License for the specific language governing permissions and
/root> # limitations under the License.
/root> #
/root> # SPDX-License-Identifier: Apache-2.0
/root> # ============LICENSE_END=========================================================
/root> #-------------------------------------------------------------------------------
/root> 
/root> model create name=ExecutionPropertiesTestPolicyModel
result: SUCCESS

/root> 
/root> schema create name=SimpleStringType  flavour=Java schema=java.lang.String
result: SUCCESS

/root> schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer
result: SUCCESS

/root> 
/root> event create name=RunTestEvent nameSpace=org.onap.policy.apex.domains.test source=JUNIT target=apex
result: SUCCESS

/root> event parameter create name=RunTestEvent parName=testToRun schemaName=SimpleStringType
result: SUCCESS

/root> 
/root> task create name=ReadOnlyTask
result: SUCCESS

/root> 
/root> task inputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=ReadOnlyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());
executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToDefinedTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToDefinedTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("hello", "world");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=DefinedToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=DefinedToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().clear();

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=AddPropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=AddPropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("goodbye", "mars");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=RemovePropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=RemovePropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().remove("hello");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> policy create name=ExecutionPropertiesTestPolicy template=freestyle firstState=RunTestState
result: SUCCESS

/root> 
/root> policy state create name=ExecutionPropertiesTestPolicy stateName=RunTestState triggerName=RunTestEvent defaultTaskName=ReadOnlyTask
result: SUCCESS

/root> policy state output create name=ExecutionPropertiesTestPolicy stateName=RunTestState outputName=TestFinalOutput eventName=RunTestEvent
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=ReadOnlyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToDefinedTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=DefinedToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=AddPropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=RemovePropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> 
/root> policy state selecttasklogic create name=ExecutionPropertiesTestPolicy stateName=RunTestState logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug("testToRun:" +  executor.getInFields().get("testToRun"));

var returnValue = true;

// Convert Java string to a Javascript variable
var testToRun = String(executor.getInFields().get("testToRun")).valueOf();

switch (testToRun) {
    case "ReadOnly":
        executor.subject.getTaskKey("ReadOnlyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToEmpty":
        executor.subject.getTaskKey("EmptyToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToDefined":
        executor.subject.getTaskKey("EmptyToDefinedTask").copyTo(executor.selectedTask);
        break;

    case "DefinedToEmpty":
        executor.subject.getTaskKey("DefinedToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "RemoveProperty":
        executor.subject.getTaskKey("RemovePropertyTask").copyTo(executor.selectedTask);
        break;

    case "AddProperty":
        executor.subject.getTaskKey("AddPropertyTask").copyTo(executor.selectedTask);
        break;

    default:
        executor.logger.debug("invalid value for testToRun:" +  executor.getInFields().get("testToRun"));
        returnValue = false;
}

executor.logger.debug("Selected Task:" + executor.selectedTask);

returnValue;


LE
result: SUCCESS

/root> 
/root> validate
result: SUCCESS
{
  "name": "ExecutionPropertiesTestPolicyModel",
  "version": "0.0.1"
}

***observations noted during validation of model***
AxArtifactKey:(name=ExecutionPropertiesTestPolicyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty
********************************

/root> 
/root> /root> #-------------------------------------------------------------------------------
/root> # ============LICENSE_START=======================================================
/root> #  Copyright (C) 2019 Nordix Foundation.
/root> # ================================================================================
/root> # Licensed under the Apache License, Version 2.0 (the "License");
/root> # you may not use this file except in compliance with the License.
/root> # You may obtain a copy of the License at
/root> #
/root> #      http://www.apache.org/licenses/LICENSE-2.0
/root> #
/root> # Unless required by applicable law or agreed to in writing, software
/root> # distributed under the License is distributed on an "AS IS" BASIS,
/root> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/root> # See the License for the specific language governing permissions and
/root> # limitations under the License.
/root> #
/root> # SPDX-License-Identifier: Apache-2.0
/root> # ============LICENSE_END=========================================================
/root> #-------------------------------------------------------------------------------
/root> 
/root> model create name=ExecutionPropertiesTestPolicyModel
result: SUCCESS

/root> 
/root> schema create name=SimpleStringType  flavour=Java schema=java.lang.String
result: SUCCESS

/root> schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer
result: SUCCESS

/root> 
/root> event create name=RunTestEvent nameSpace=org.onap.policy.apex.domains.test source=JUNIT target=apex
result: SUCCESS

/root> event parameter create name=RunTestEvent parName=testToRun schemaName=SimpleStringType
result: SUCCESS

/root> 
/root> task create name=ReadOnlyTask
result: SUCCESS

/root> 
/root> task inputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=ReadOnlyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());
executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToDefinedTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToDefinedTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("hello", "world");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=DefinedToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=DefinedToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().clear();

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=AddPropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=AddPropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("goodbye", "mars");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=RemovePropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=RemovePropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().remove("hello");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> policy create name=ExecutionPropertiesTestPolicy template=freestyle firstState=RunTestState
result: SUCCESS

/root> 
/root> policy state create name=ExecutionPropertiesTestPolicy stateName=RunTestState triggerName=RunTestEvent defaultTaskName=ReadOnlyTask
result: SUCCESS

/root> policy state output create name=ExecutionPropertiesTestPolicy stateName=RunTestState outputName=TestFinalOutput eventName=RunTestEvent
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=ReadOnlyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToDefinedTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=DefinedToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=AddPropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=RemovePropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> 
/root> policy state selecttasklogic create name=ExecutionPropertiesTestPolicy stateName=RunTestState logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug("testToRun:" +  executor.getInFields().get("testToRun"));

var returnValue = true;

// Convert Java string to a Javascript variable
var testToRun = String(executor.getInFields().get("testToRun")).valueOf();

switch (testToRun) {
    case "ReadOnly":
        executor.subject.getTaskKey("ReadOnlyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToEmpty":
        executor.subject.getTaskKey("EmptyToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToDefined":
        executor.subject.getTaskKey("EmptyToDefinedTask").copyTo(executor.selectedTask);
        break;

    case "DefinedToEmpty":
        executor.subject.getTaskKey("DefinedToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "RemoveProperty":
        executor.subject.getTaskKey("RemovePropertyTask").copyTo(executor.selectedTask);
        break;

    case "AddProperty":
        executor.subject.getTaskKey("AddPropertyTask").copyTo(executor.selectedTask);
        break;

    default:
        executor.logger.debug("invalid value for testToRun:" +  executor.getInFields().get("testToRun"));
        returnValue = false;
}

executor.logger.debug("Selected Task:" + executor.selectedTask);

returnValue;


LE
result: SUCCESS

/root> 
/root> validate
result: SUCCESS
{
  "name": "ExecutionPropertiesTestPolicyModel",
  "version": "0.0.1"
}

***observations noted during validation of model***
AxArtifactKey:(name=ExecutionPropertiesTestPolicyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty
********************************

/root> 
/root> /root> #-------------------------------------------------------------------------------
/root> # ============LICENSE_START=======================================================
/root> #  Copyright (C) 2019 Nordix Foundation.
/root> # ================================================================================
/root> # Licensed under the Apache License, Version 2.0 (the "License");
/root> # you may not use this file except in compliance with the License.
/root> # You may obtain a copy of the License at
/root> #
/root> #      http://www.apache.org/licenses/LICENSE-2.0
/root> #
/root> # Unless required by applicable law or agreed to in writing, software
/root> # distributed under the License is distributed on an "AS IS" BASIS,
/root> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/root> # See the License for the specific language governing permissions and
/root> # limitations under the License.
/root> #
/root> # SPDX-License-Identifier: Apache-2.0
/root> # ============LICENSE_END=========================================================
/root> #-------------------------------------------------------------------------------
/root> 
/root> model create name=ExecutionPropertiesTestPolicyModel
result: SUCCESS

/root> 
/root> schema create name=SimpleStringType  flavour=Java schema=java.lang.String
result: SUCCESS

/root> schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer
result: SUCCESS

/root> 
/root> event create name=RunTestEvent nameSpace=org.onap.policy.apex.domains.test source=JUNIT target=apex
result: SUCCESS

/root> event parameter create name=RunTestEvent parName=testToRun schemaName=SimpleStringType
result: SUCCESS

/root> 
/root> task create name=ReadOnlyTask
result: SUCCESS

/root> 
/root> task inputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=ReadOnlyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());
executor.logger.debug(executor.getOutFields().toString());

true;

LE
result: SUCCESS

/root> 
/root> task create name=EmptyToDefinedTask
result: SUCCESS

/root> 
/root> task inputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=EmptyToDefinedTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("hello", "world");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=DefinedToEmptyTask
result: SUCCESS

/root> 
/root> task inputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=DefinedToEmptyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().clear();

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=AddPropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=AddPropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().setProperty("goodbye", "mars");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> task create name=RemovePropertyTask
result: SUCCESS

/root> 
/root> task inputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> task outputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
result: SUCCESS
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

/root> 
/root> task logic create name=RemovePropertyTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());

executor.logger.debug("executionProperties in:" + executor.getExecutionProperties());

var executionProperties = new java.util.Properties();

executor.getExecutionProperties().remove("hello");

executor.logger.debug("executionProperties out:" + executor.getExecutionProperties());

true;

LE
result: SUCCESS

/root> 
/root> policy create name=ExecutionPropertiesTestPolicy template=freestyle firstState=RunTestState
result: SUCCESS

/root> 
/root> policy state create name=ExecutionPropertiesTestPolicy stateName=RunTestState triggerName=RunTestEvent defaultTaskName=ReadOnlyTask
result: SUCCESS

/root> policy state output create name=ExecutionPropertiesTestPolicy stateName=RunTestState outputName=TestFinalOutput eventName=RunTestEvent
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=ReadOnlyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToDefinedTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=DefinedToEmptyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=AddPropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=RemovePropertyTask outputType=DIRECT outputName=TestFinalOutput
result: SUCCESS

/root> 
/root> policy state selecttasklogic create name=ExecutionPropertiesTestPolicy stateName=RunTestState logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2020 Nordix Foundation.
 * ================================================================================
 * 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=========================================================
 */

executor.logger.debug(executor.getSubject().getId());
executor.logger.debug(executor.getInFields().toString());
executor.logger.debug("executionProperties:" + executor.getExecutionProperties());

executor.logger.debug("testToRun:" +  executor.getInFields().get("testToRun"));

var returnValue = true;

// Convert Java string to a Javascript variable
var testToRun = String(executor.getInFields().get("testToRun")).valueOf();

switch (testToRun) {
    case "ReadOnly":
        executor.subject.getTaskKey("ReadOnlyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToEmpty":
        executor.subject.getTaskKey("EmptyToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "EmptyToDefined":
        executor.subject.getTaskKey("EmptyToDefinedTask").copyTo(executor.selectedTask);
        break;

    case "DefinedToEmpty":
        executor.subject.getTaskKey("DefinedToEmptyTask").copyTo(executor.selectedTask);
        break;

    case "RemoveProperty":
        executor.subject.getTaskKey("RemovePropertyTask").copyTo(executor.selectedTask);
        break;

    case "AddProperty":
        executor.subject.getTaskKey("AddPropertyTask").copyTo(executor.selectedTask);
        break;

    default:
        executor.logger.debug("invalid value for testToRun:" +  executor.getInFields().get("testToRun"));
        returnValue = false;
}

executor.logger.debug("Selected Task:" + executor.selectedTask);

returnValue;


LE
result: SUCCESS

/root> 
/root> validate
result: SUCCESS
{
  "name": "ExecutionPropertiesTestPolicyModel",
  "version": "0.0.1"
}

***observations noted during validation of model***
AxArtifactKey:(name=ExecutionPropertiesTestPolicyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty
********************************

/root> 
/root>