// Event related properties used during processing of this event
@Getter
@Setter
- private Properties executionProperties;
+ private Properties executionProperties = new Properties();
// A string holding a message that indicates why processing of this event threw an exception
@Getter
import java.util.Map;
import java.util.Properties;
+import lombok.NonNull;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
* {@inheritDoc}.
*/
@Override
- public final void executePre(final long executionId, final Properties executionProperties,
+ public final void executePre(final long executionId, @NonNull final Properties executionProperties,
final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
LOGGER.debug("execute-pre:" + finalizerLogic.getLogicFlavour() + "," + getSubject().getId() + ","
+ finalizerLogic.getLogic());
import java.util.TreeMap;
import java.util.TreeSet;
+import lombok.NonNull;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
* {@inheritDoc}.
*/
@Override
- public final void executePre(final long executionId, final Properties executionProperties,
+ public final void executePre(final long executionId, @NonNull final Properties executionProperties,
final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
LOGGER.debug("execute-pre:" + getSubject().getTaskLogic().getLogicFlavour() + ","
+ getSubject().getKey().getId() + "," + getSubject().getTaskLogic().getLogic());
import java.util.Properties;
+import lombok.NonNull;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
* {@inheritDoc}.
*/
@Override
- public final void executePre(final long executionId, final Properties executionProperties,
+ public final void executePre(final long executionId, @NonNull final Properties executionProperties,
final EnEvent newIncomingEvent) throws StateMachineException {
LOGGER.debug("execute-pre:" + axState.getKey().getId() + "," + axState.getTaskSelectionLogic().getLogicFlavour()
+ "," + axState.getTaskSelectionLogic().getLogic());
import java.util.Set;
import java.util.TreeMap;
+import lombok.Getter;
+import lombok.Setter;
+
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
- /** the execution properties the current APEX policy execution instance. */
- public final Properties executionProperties;
-
/**
* The list of state outputs for this state finalizer. The purpose of a state finalizer is to select a state output
* for a state from this list of state output names.
*/
public final Map<String, Object> fields;
- // A message specified in the logic
- private String message;
-
/**
* The state output that the state finalizer logic has selected for a state. The state finalizer logic sets this
* field in its logic after executing and the Apex engine uses this state output for this state.
// All available context albums
private final Map<String, ContextAlbum> context;
+ // A message specified in the logic
+ @Getter
+ @Setter
+ private String message;
+
+ // Execution properties for a policy execution
+ @Getter
+ private Properties executionProperties;
+
/**
* Instantiates a new state finalizer execution context.
*
public void setSelectedStateOutputName(final String selectedStateOutputName) {
this.selectedStateOutputName = selectedStateOutputName;
}
-
- /**
- * Gets the user message.
- *
- * @return the user message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the user message.
- *
- * @param message the message
- */
- public void setMessage(final String message) {
- this.message = message;
- }
}
import java.util.Properties;
import java.util.TreeMap;
+import lombok.Getter;
+import lombok.Setter;
+
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
- /** the execution properties the current APEX policy execution instance. */
- public final Properties executionProperties;
-
/**
* The incoming fields from the trigger event for the task. The task logic can access these fields when executing
* its logic.
private final List<AxConcept> usedArtifactStack;
// A message specified in the logic
+ @Getter
+ @Setter
private String message;
+ // Execution properties for a policy execution
+ @Getter
+ private Properties executionProperties;
+
/**
* Instantiates a new task execution context.
*
+ "\" on task \"" + subject.getId() + "\"");
}
}
-
- /**
- * Get the user message.
- *
- * @return the user message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the user message.
- *
- * @param message the message
- */
- public void setMessage(final String message) {
- this.message = message;
- }
}
import java.util.Properties;
import java.util.TreeMap;
+import lombok.Getter;
+import lombok.Setter;
+
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
- /** the execution properties the current APEX policy execution instance. */
- public final Properties executionProperties;
-
/**
* The incoming fields from the trigger event for the state. The task selection logic can access
* these fields to decide what task to select for the state.
private final Map<String, ContextAlbum> context;
// A message specified in the logic
+ @Getter
+ @Setter
private String message;
+ // Execution properties for a policy execution
+ @Getter
+ private Properties executionProperties;
+
/**
* Instantiates a new task selection execution context.
*
+ "\" on state \"" + subject.getId() + "\"");
}
}
-
- /**
- * Gets the user message.
- *
- * @return the user message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the user message.
- *
- * @param message the message
- */
- public void setMessage(final String message) {
- this.message = message;
- }
}
import static org.junit.Assert.fail;
import java.util.Map;
+import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception ex) {
assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage());
}
try {
executor.executePre(0, null, incomingEvent);
+ } catch (Exception ex) {
+ assertEquals("executionProperties is marked @NonNull but is null", ex.getMessage());
+ }
+
+ try {
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
try {
- executor.execute(0, null, incomingEvent);
+ executor.execute(0, new Properties(), incomingEvent);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute() not implemented on abstract StateFinalizerExecutionContext class, "
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception ex) {
fail("test should not throw an exception");
}
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception ex) {
fail("test should not throw an exception");
}
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception ex) {
fail("test should not throw an exception");
}
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
Map<String, Object> incomingFields = new LinkedHashMap<>();
try {
- executor.executePre(0, null, incomingFields);
+ executor.executePre(0, new Properties(), incomingFields);
} catch (Exception ex) {
assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage());
}
incomingFields.put("InField0", "A Value");
try {
- executor.executePre(0, null, incomingFields);
+ executor.executePre(0, new Properties(), incomingFields);
} catch (Exception e) {
fail("test should not throw an exception");
}
try {
- executor.execute(0, null, incomingFields);
+ executor.execute(0, new Properties(), incomingFields);
+ fail("test should throw an exception");
+ } catch (Exception ex) {
+ assertEquals("execute() not implemented on abstract TaskExecutor class, only on its subclasses",
+ ex.getMessage());
+ }
+
+ try {
+ executor.execute(0, new Properties(), incomingFields);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute() not implemented on abstract TaskExecutor class, only on its subclasses",
- ex.getMessage());
+ ex.getMessage());
}
try {
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute-post: task logic execution failure on task \"Task0\" in model Context:0.0.1",
- ex.getMessage());
+ ex.getMessage());
}
executor.getExecutionContext().setMessage("Execution message");
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute-post: task logic execution failure on task \"Task0\" in model Context:0.0.1, "
- + "user message: Execution message", ex.getMessage());
+ + "user message: Execution message", ex.getMessage());
}
try {
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("task output fields \"[BadExtraField]\" are unwanted for task \"Task0:0.0.1\"",
- ex.getMessage());
+ ex.getMessage());
}
executor.getExecutionContext().outFields.remove("BadExtraField");
} catch (Exception ex) {
fail("test should not throw an exception");
}
+
+ try {
+ executor.executePre(0, null, incomingFields);
+ fail("test should throw an exception");
+ } catch (Exception ex) {
+ assertEquals("executionProperties is marked @NonNull but is null", ex.getMessage());
+ }
}
}
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception ex) {
assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage());
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
try {
- executor.execute(0, null, incomingEvent);
+ executor.execute(0, new Properties(), incomingEvent);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute() not implemented on class", ex.getMessage());
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute-post: task selection logic failed on state \"State0Parent:0.0.1:Parent:State0\"",
- ex.getMessage());
+ ex.getMessage());
}
executor.getExecutionContext().setMessage("Execution message");
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute-post: task selection logic failed on state \"State0Parent:0.0.1:Parent:State0\", "
- + "user message: Execution message", ex.getMessage());
+ + "user message: Execution message", ex.getMessage());
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("task \"IDontExist:0.0.0\" returned by task selection logic not defined "
- + "on state \"State0Parent:0.0.1:Parent:State0\"", ex.getMessage());
+ + "on state \"State0Parent:0.0.1:Parent:State0\"", ex.getMessage());
}
try {
- executor.executePre(0, null, incomingEvent);
+ executor.executePre(0, new Properties(), incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
} catch (Exception e) {
fail("test should not throw an exception");
}
+
+ try {
+ executor.executePre(0, null, incomingEvent);
+ fail("test should throw an exception");
+ } catch (Exception ex) {
+ assertEquals("executionProperties is marked @NonNull but is null", ex.getMessage());
+ }
}
}
@BeforeClass
public static void beforeTest() {
schemaParameters = new SchemaParameters();
-
+
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
ParameterService.register(schemaParameters);
-
+
contextParameters = new ContextParameters();
contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
ParameterService.register(contextParameters.getDistributorParameters());
ParameterService.register(contextParameters.getLockManagerParameters());
ParameterService.register(contextParameters.getPersistorParameters());
-
+
engineParameters = new EngineParameters();
engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters());
engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
@AfterClass
public static void afterTest() {
ParameterService.deregister(engineParameters);
-
+
ParameterService.deregister(contextParameters.getDistributorParameters());
ParameterService.deregister(contextParameters.getLockManagerParameters());
ParameterService.deregister(contextParameters.getPersistorParameters());
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
jmsMessage.getJMSType());
}
- eventReceiver.receiveEvent(null, jmsMessage);
+ eventReceiver.receiveEvent(new Properties(), jmsMessage);
} catch (final Exception e) {
final String errorMessage = "failed to receive message from JMS";
LOGGER.warn(errorMessage, e);
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
kafkaConsumer.poll(kafkaConsumerProperties.getConsumerPollDuration().toMillis());
for (final ConsumerRecord<String, String> record : records) {
traceIfTraceEnabled(record);
- eventReceiver.receiveEvent(null, record.value());
+ eventReceiver.receiveEvent(new Properties(), record.value());
}
} catch (final Exception e) {
LOGGER.warn("error receiving events on thread {}", consumerThread.getName(), e);
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
}
// Send the event into Apex
- eventReceiver.receiveEvent(null, eventJsonString);
+ eventReceiver.receiveEvent(new Properties(), eventJsonString);
} catch (final Exception e) {
LOGGER.warn("error receiving events on thread {}", consumerThread.getName(), e);
}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
}
// Send the event into Apex
- eventReceiver.receiveEvent(request.getExecutionId(), null, eventJsonString);
+ eventReceiver.receiveEvent(request.getExecutionId(), new Properties(), eventJsonString);
synchronized (eventsReceivedLock) {
eventsReceived++;
import java.net.URI;
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
import javax.ws.rs.core.Response;
try {
// Send the event into Apex
- eventReceiver.receiveEvent(executionId, null, event);
+ eventReceiver.receiveEvent(executionId, new Properties(), event);
} catch (final Exception e) {
final String errorMessage = "error receiving events on event consumer " + name + ", " + e.getMessage();
LOGGER.warn(errorMessage, e);
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient;
@Override
public void receiveString(final String eventString) {
try {
- eventReceiver.receiveEvent(null, eventString);
+ eventReceiver.receiveEvent(new Properties(), eventString);
eventsRead++;
} catch (final Exception e) {
final String errorMessage = "Error sending event " + name + '_' + eventsRead + ", " + e.getMessage()
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
}
try {
- jsfe.execute(-1, null, null);
+ jsfe.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jsfe.execute(-1, null, event);
+ jsfe.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
stateFinalizerLogic.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaStateFinalizerLogic");
try {
jsfe.prepare();
- jsfe.execute(-1, null, event);
+ jsfe.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" "
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
jsfe.prepare();
- String stateOutput = jsfe.execute(0, null, event);
+ String stateOutput = jsfe.execute(0, new Properties(), event);
assertEquals("SelectedOutputIsMe", stateOutput);
jsfe.cleanUp();
} catch (Exception jtseException) {
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
}
try {
- jte.execute(-1, null, null);
+ jte.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals(java.lang.NullPointerException.class, jteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- jte.execute(-1, null, incomingParameters);
+ jte.execute(-1, new Properties(), incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("task logic failed to run for task \"NULL:0.0.0\"", jteException.getMessage());
task.getTaskLogic().setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaTaskLogic");
try {
jte.prepare();
- jte.execute(-1, null, incomingParameters);
+ jte.execute(-1, new Properties(), incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
} catch (Exception jteException) {
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
}
try {
- jtse.execute(-1, null, null);
+ jtse.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(java.lang.NullPointerException.class, jtseException.getClass());
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jtse.execute(-1, null, event);
+ jtse.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("task selection logic failed to run for state \"NULL:0.0.0:NULL:NULL\"",
.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaTaskSelectionLogic");
try {
jtse.prepare();
- jtse.execute(-1, null, event);
+ jtse.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
try {
jtse.prepare();
- AxArtifactKey taskKey = jtse.execute(0, null, event);
+ AxArtifactKey taskKey = jtse.execute(0, new Properties(), event);
assertEquals("NULL:0.0.0", taskKey.getId());
jtse.cleanUp();
} catch (Exception jtseException) {
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Map<String, Object> incomingParameters1 = new HashMap<>();
try {
- jsfe.execute(-1, null, incomingParameters1);
+ jsfe.execute(-1, new Properties(), incomingParameters1);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
+ "var returnValue = new returnValueType(true);}");
try {
jsfe.prepare();
- jsfe.execute(-1, null, event);
+ jsfe.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
jsfe.prepare();
- String stateOutput = jsfe.execute(0, null, event);
+ String stateOutput = jsfe.execute(0, new Properties(), event);
assertEquals("SelectedOutputIsMe", stateOutput);
jsfe.cleanUp();
} catch (Exception jtseException) {
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Map<String, Object> incomingParameters2 = new HashMap<>();
try {
- jte.execute(-1, null, incomingParameters2);
+ jte.execute(-1, new Properties(), incomingParameters2);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("task logic failed to run for task \"NULL:0.0.0\"", jteException.getMessage());
}
try {
- jte.execute(-1, null, null);
+ jte.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals(java.lang.NullPointerException.class, jteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- jte.execute(-1, null, incomingParameters);
+ jte.execute(-1, new Properties(), incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute: task logic failed to set a return value for task \"NULL:0.0.0\"",
+ "var returnValue = new returnValueType(false); ");
try {
jte.prepare();
- jte.execute(-1, null, incomingParameters);
+ jte.execute(-1, new Properties(), incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
+ "var returnValue = new returnValueType(true); ");
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
} catch (Exception jteException) {
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
AxEvent axEvent1 = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event1 = new EnEvent(axEvent1);
try {
- jtse.execute(-1, null, event1);
+ jtse.execute(-1, new Properties(), event1);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
}
try {
- jtse.execute(-1, null, null);
+ jtse.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(java.lang.NullPointerException.class, jtseException.getClass());
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jtse.execute(-1, null, event);
+ jtse.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
+ "var returnValue = new returnValueType(false); ");
try {
jtse.prepare();
- jtse.execute(-1, null, event);
+ jtse.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
+ "var returnValue = new returnValueType(true); ");
try {
jtse.prepare();
- AxArtifactKey taskKey = jtse.execute(0, null, event);
+ AxArtifactKey taskKey = jtse.execute(0, new Properties(), event);
assertEquals("NULL:0.0.0", taskKey.getId());
jtse.cleanUp();
} catch (Exception jtseException) {
import static org.junit.Assert.fail;\r
\r
import java.lang.reflect.Field;\r
+import java.util.Properties;\r
+\r
import org.junit.After;\r
import org.junit.Before;\r
import org.junit.Test;\r
}\r
\r
try {\r
- jsfe.execute(-1, null, null);\r
+ jsfe.execute(-1, new Properties(), null);\r
fail("test should throw an exception here");\r
} catch (Exception jtseException) {\r
assertEquals("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" on "\r
state.getStateOutputs().put("SelectedOutputIsMe", null);\r
try {\r
jsfe.prepare();\r
- String stateOutput = jsfe.execute(0, null, event);\r
+ String stateOutput = jsfe.execute(0, new Properties(), event);\r
assertEquals("SelectedOutputIsMe", stateOutput);\r
jsfe.cleanUp();\r
} catch (Exception jtseException) {\r
import java.lang.reflect.Field;\r
import java.util.HashMap;\r
import java.util.Map;\r
+import java.util.Properties;\r
+\r
import org.junit.After;\r
import org.junit.Before;\r
import org.junit.Test;\r
\r
Map<String, Object> incomingParameters = new HashMap<>();\r
try {\r
- jte.execute(-1, null, incomingParameters);\r
+ jte.execute(-1, new Properties(), incomingParameters);\r
fail("test should throw an exception here");\r
} catch (Exception jteException) {\r
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",\r
\r
try {\r
jte.prepare();\r
- Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);\r
+ Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);\r
assertEquals(0, returnMap.size());\r
jte.cleanUp();\r
} catch (Exception jteException) {\r
import static org.junit.Assert.fail;\r
\r
import java.lang.reflect.Field;\r
+import java.util.Properties;\r
+\r
import org.junit.After;\r
import org.junit.Before;\r
import org.junit.Test;\r
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));\r
EnEvent event = new EnEvent(axEvent);\r
try {\r
- jtse.execute(-1, null, event);\r
+ jtse.execute(-1, new Properties(), event);\r
fail("test should throw an exception here");\r
} catch (Exception jtseException) {\r
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",\r
\r
try {\r
jtse.prepare();\r
- AxArtifactKey taskKey = jtse.execute(0, null, event);\r
+ AxArtifactKey taskKey = jtse.execute(0, new Properties(), event);\r
assertEquals("NULL:0.0.0", taskKey.getId());\r
jtse.cleanUp();\r
} catch (Exception jtseException) {\r
import static org.junit.Assert.fail;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
stateFinalizerLogic.setLogic(scriptSource);
try {
jsfe.prepare();
- jsfe.execute(-1, null, null);
+ jsfe.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jsfe.execute(0, null, event);
+ jsfe.execute(0, new Properties(), event);
} catch (Exception jtseException) {
jtseException.printStackTrace();
fail("test should not throw an exception here");
try {
jsfe.prepare();
- String stateOutput = jsfe.execute(0, null, event);
+ String stateOutput = jsfe.execute(0, new Properties(), event);
assertEquals("SelectedOutputIsMe", stateOutput);
jsfe.cleanUp();
} catch (Exception jtseException) {
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
}
try {
- jte.execute(-1, null, null);
+ jte.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals(java.lang.NullPointerException.class, jteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- jte.execute(-1, null, incomingParameters);
+ jte.execute(-1, new Properties(), incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("failed to execute Jython code for task NULL:0.0.0", jteException.getMessage());
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(-1, null, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(-1, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
fail("test should throw an exception here");
task.getTaskLogic().setLogic(scriptSource);
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
} catch (Exception jteException) {
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
state.getTaskSelectionLogic().setLogic(scriptSource);
try {
jtse.prepare();
- jtse.execute(-1, null, null);
+ jtse.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(java.lang.NullPointerException.class, jtseException.getClass());
EnEvent event = new EnEvent(axEvent);
try {
jtse.prepare();
- jtse.execute(-1, null, event);
+ jtse.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("failed to execute Jython code for task selection logic in NULL:0.0.0:NULL:NULL",
state.getTaskSelectionLogic().setLogic(scriptSource);
try {
jtse.prepare();
- jtse.execute(-1, null, event);
+ jtse.execute(-1, new Properties(), event);
jtse.cleanUp();
} catch (Exception jtseException) {
fail("test should not throw an exception here");
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
}
try {
- msfe.execute(-1, null, null);
+ msfe.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- msfe.execute(-1, null, event);
+ msfe.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
stateFinalizerLogic.setLogic("executionId !=-1");
try {
msfe.prepare();
- msfe.execute(-1, null, event);
+ msfe.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals(
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
msfe.prepare();
- String stateOutput = msfe.execute(0, null, event);
+ String stateOutput = msfe.execute(0, new Properties(), event);
assertEquals("SelectedOutputIsMe", stateOutput);
} catch (Exception msfeException) {
LOGGER.warn("Unexpected exception happened here.", msfeException);
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
}
try {
- mte.execute(-1, null, null);
+ mte.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals(java.lang.NullPointerException.class, mteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- mte.execute(-1, null, incomingParameters);
+ mte.execute(-1, new Properties(), incomingParameters);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals("failed to execute MVEL code for task NULL:0.0.0", mteException.getMessage());
task.getTaskLogic().setLogic("executionId != -1");
try {
mte.prepare();
- mte.execute(-1, null, incomingParameters);
+ mte.execute(-1, new Properties(), incomingParameters);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
try {
mte.prepare();
- Map<String, Object> returnMap = mte.execute(0, null, incomingParameters);
+ Map<String, Object> returnMap = mte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
mte.cleanUp();
} catch (Exception mteException) {
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.util.Properties;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
}
try {
- mtse.execute(-1, null, null);
+ mtse.execute(-1, new Properties(), null);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals(java.lang.NullPointerException.class, mtseException.getClass());
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- mtse.execute(-1, null, event);
+ mtse.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
state.getTaskSelectionLogic().setLogic("executionId != -1");
try {
mtse.prepare();
- mtse.execute(-1, null, event);
+ mtse.execute(-1, new Properties(), event);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
try {
mtse.prepare();
- AxArtifactKey taskKey = mtse.execute(0, null, event);
+ AxArtifactKey taskKey = mtse.execute(0, new Properties(), event);
assertEquals("NULL:0.0.0", taskKey.getId());
mtse.cleanUp();
} catch (Exception mtseException) {
private long executionId = ApexEvent.getNextExecutionId();
// Event related properties used during processing of this event
- private Properties executionProperties;
+ private Properties executionProperties = new Properties();
// A string holding a message that indicates why processing of this event threw an exception
private String exceptionMessage;
* 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=========================================================
*/
final ApexEvent apexEvent = new ApexEvent(axEvent.getKey().getName(), axEvent.getKey().getVersion(),
axEvent.getNameSpace(), axEvent.getSource(), axEvent.getTarget());
- // Copy the ExecutionID from the EnEvent into the ApexEvent
apexEvent.setExecutionId(enEvent.getExecutionId());
+ apexEvent.setExecutionProperties(enEvent.getExecutionProperties());
// Copy he exception message to the Apex event if it is set
if (enEvent.getExceptionMessage() != null) {
// Set the data on the engine event
enEvent.putAll(apexEvent);
- // copy the ExecutionID from the ApexEvent into the EnEvent
enEvent.setExecutionId(apexEvent.getExecutionId());
+ enEvent.setExecutionProperties(apexEvent.getExecutionProperties());
return enEvent;
}
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
}
// Send the event into Apex
- eventReceiver.receiveEvent(null, eventObject);
+ eventReceiver.receiveEvent(new Properties(), eventObject);
eventsReceived++;
} catch (final InterruptedException e) {
import java.io.InputStream;
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
// Process the event from the text block if there is one there
if (textBlock.getText() != null) {
- eventReceiver.receiveEvent(getNextExecutionId(), null, textBlock.getText());
+ eventReceiver.receiveEvent(getNextExecutionId(), new Properties(), textBlock.getText());
}
}
while (!textBlock.isEndOfText());
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
+import lombok.NonNull;
+
import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
* {@inheritDoc}.
*/
@Override
- public void receiveEvent(final Properties executionProperties, final Object event) throws ApexEventException {
+ public void receiveEvent(@NonNull final Properties executionProperties, final Object event)
+ throws ApexEventException {
receiveEvent(0, executionProperties, event, true);
}
* {@inheritDoc}.
*/
@Override
- public void receiveEvent(final long executionId, final Properties executionProperties, final Object event)
+ public void receiveEvent(final long executionId, @NonNull final Properties executionProperties, final Object event)
throws ApexEventException {
receiveEvent(executionId, executionProperties, event, false);
}
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>kafka_2.12</artifactId>
<version>${version.kafka}</version>
<scope>test</scope>
- <exclusions>
+ <exclusions>
<!-- The default Zookeeper version in Kafka has vulnerabilities -->
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<version>${version.jersey}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>3.0.0</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</build>
<profiles>
- <profile>
+ <profile>
<id>only-eclipse</id>
<activation>
<property>
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.executionproperties;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.EnumMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
+import org.onap.policy.apex.service.engine.event.ApexEventException;
+import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
+import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
+import org.onap.policy.apex.service.engine.event.PeeredReference;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dummy Apex event consumer for testing event properties.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class DummyApexEventConsumer implements ApexEventConsumer {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(DummyApexEventConsumer.class);
+
+ // The event receiver that will receive events from this consumer
+ private ApexEventReceiver eventReceiver;
+
+ // The name for this consumer
+ private String name = null;
+
+ // The peer references for this event handler
+ private Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class);
+
+ private DummyCarrierTechnologyParameters dummyConsumerProperties = null;
+
+ @Override
+ public void init(final String consumerName, final EventHandlerParameters consumerParameters,
+ final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
+ this.eventReceiver = incomingEventReceiver;
+ this.name = consumerName;
+
+
+ // Check and get the properties
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof DummyCarrierTechnologyParameters)) {
+ String message = "specified consumer properties of type \""
+ + consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
+ + "\" are not applicable to a dummy consumer";
+ LOGGER.warn(message);
+ throw new ApexEventException(message);
+ }
+
+ dummyConsumerProperties =
+ (DummyCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+ }
+
+ @Override
+ public void start() {
+ new Thread(new RunTestEventSender()).start();
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
+ return peerReferenceMap.get(peeredMode);
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
+ peerReferenceMap.put(peeredMode, peeredReference);
+ }
+
+ @Override
+ public void stop() {}
+
+ private class RunTestEventSender implements Runnable {
+ @Override
+ public void run() {
+ Properties executionProperties = new Properties();
+ try {
+ executionProperties.load(new FileInputStream(new File(dummyConsumerProperties.getPropertyFileName())));
+ } catch (IOException e1) {
+ String message = "reading of executor properties for testing failed from file: "
+ + dummyConsumerProperties.getPropertyFileName();
+ LOGGER.warn(message);
+ throw new ApexEventRuntimeException(message);
+ }
+
+ RunTestEvent event = new RunTestEvent();
+ event.setTestToRun(dummyConsumerProperties.getTestToRun());
+ try {
+ eventReceiver.receiveEvent(executionProperties, event.toJson());
+ } catch (Exception e) {
+ String message = "event processing for executor properties testing failed: " + e.getMessage();
+ LOGGER.warn(message, e);
+ throw new ApexEventRuntimeException(message, e);
+ }
+ }
+ }
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.executionproperties;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.EnumMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.onap.policy.apex.service.engine.event.ApexEventException;
+import org.onap.policy.apex.service.engine.event.ApexEventProducer;
+import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
+import org.onap.policy.apex.service.engine.event.PeeredReference;
+import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dummy Apex event producer for testing event properties.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class DummyApexEventProducer implements ApexEventProducer {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(DummyApexEventProducer.class);
+
+ // The parameters read from the parameter service
+ private DummyCarrierTechnologyParameters dummyProducerProperties;
+
+ // The name for this producer
+ private String name = null;
+
+ // The peer references for this event handler
+ private Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class);
+
+ @Override
+ public void init(final String producerName, final EventHandlerParameters producerParameters)
+ throws ApexEventException {
+ this.name = producerName;
+
+ // Check and get the Properties
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof DummyCarrierTechnologyParameters)) {
+ String message = "specified producer properties are not applicable to a dummy producer (" + this.name + ")";
+ LOGGER.warn(message);
+ throw new ApexEventException(message);
+ }
+ dummyProducerProperties =
+ (DummyCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+
+ new File(dummyProducerProperties.getPropertyFileName()).delete();
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
+ return peerReferenceMap.get(peeredMode);
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
+ peerReferenceMap.put(peeredMode, peeredReference);
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object eventAsJsonString) {
+ // Check if this is a synchronized event, if so we have received a reply
+ final SynchronousEventCache synchronousEventCache =
+ (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
+ if (synchronousEventCache != null) {
+ synchronousEventCache.removeCachedEventToApexIfExists(executionId);
+ }
+
+ RunTestEvent testEvent = new RunTestEvent();
+ try {
+ testEvent.fromJson((String) eventAsJsonString);
+ } catch (CoderException ce) {
+ String message = "could not decode event from JSON";
+ LOGGER.warn(message, ce);
+ throw new ApexEventRuntimeException(message, ce);
+ }
+ if (!dummyProducerProperties.getTestToRun().equals(testEvent.getTestToRun())) {
+ String message = "tests in received test event and parameters do not match " + testEvent.getTestToRun()
+ + ":" + dummyProducerProperties.getTestToRun();
+ LOGGER.warn(message);
+ throw new ApexEventRuntimeException(message);
+ }
+
+
+ try {
+ executionProperties.store(new FileOutputStream(new File(dummyProducerProperties.getPropertyFileName())),
+ "");
+ } catch (IOException ioe) {
+ String message = "writing of executor properties for testing failed from file: "
+ + dummyProducerProperties.getPropertyFileName();
+ LOGGER.warn(message, ioe);
+ throw new ApexEventRuntimeException(message, ioe);
+ }
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void stop() {}
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.executionproperties;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
+
+/**
+ * Dummy carrier technology parameters.
+ *
+ * <p>The parameters for this plugin are:
+ * <ol>
+ * <li>testToRun: The name of the test to run.
+ * </ol>
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class DummyCarrierTechnologyParameters extends CarrierTechnologyParameters {
+
+ /** The label of this carrier technology. */
+ public static final String DUMMY_CARRIER_TECHNOLOGY_LABEL = "DUMMY";
+
+ /** The producer plugin class for the dummy carrier technology. */
+ public static final String DUMMY_EVENT_PRODUCER_PLUGIN_CLASS = DummyApexEventProducer.class.getName();
+
+ /** The consumer plugin class for the dummy carrier technology. */
+ public static final String DUMMY_EVENT_CONSUMER_PLUGIN_CLASS = DummyApexEventConsumer.class.getName();
+
+ private String testToRun = null;
+ private String propertyFileName = null;
+
+ /**
+ * Constructor to create a dummy carrier technology parameters instance and register the instance with the parameter
+ * service.
+ */
+ public DummyCarrierTechnologyParameters() {
+ super();
+
+ // Set the carrier technology properties for the web socket carrier technology
+ this.setLabel(DUMMY_CARRIER_TECHNOLOGY_LABEL);
+ this.setEventProducerPluginClass(DUMMY_EVENT_PRODUCER_PLUGIN_CLASS);
+ this.setEventConsumerPluginClass(DUMMY_EVENT_CONSUMER_PLUGIN_CLASS);
+
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
+
+ if (StringUtils.isEmpty(testToRun)) {
+ result.setResult("testToRun", ValidationStatus.INVALID,
+ "no test has been specified on the dummy carrier technology plugin");
+ }
+
+ if (StringUtils.isEmpty(propertyFileName)) {
+ result.setResult("propertyFileName", ValidationStatus.INVALID,
+ "no propertyFileName has been specified on the dummy carrier technology plugin");
+ }
+
+ return result;
+ }
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.executionproperties;
+
+import lombok.Data;
+
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+/**
+ * Test event fgor execution properties.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Data
+public class RunTestEvent {
+ private String testToRun;
+ private String propertyFileName;
+
+ public String toJson() throws CoderException {
+ return new StandardCoder().encode(this);
+ }
+
+ /**
+ * Set fields of this event from a JSON string.
+ *
+ * @param jsonString the JSON string
+ * @throws CoderException on JSON exceptions
+ */
+ public void fromJson(final String jsonString) throws CoderException {
+ RunTestEvent jsonTestEvent = new StandardCoder().decode(jsonString, RunTestEvent.class);
+ this.testToRun = jsonTestEvent.testToRun;
+ this.propertyFileName = jsonTestEvent.propertyFileName;
+ }
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.executionproperties;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain;
+import org.onap.policy.apex.service.engine.main.ApexMain;
+
+/**
+ * This class runs integration tests for execution properties.
+ */
+public class TestExecutionProperties {
+ /**
+ * Compile the policy.
+ */
+ @BeforeClass
+ public static void compilePolicy() {
+ // @formatter:off
+ final String[] cliArgs = {
+ "-c",
+ "src/test/resources/policies/executionproperties/policy/ExecutionPropertiesTestPolicyModel.apex",
+ "-l",
+ "target/ExecutionPropertiesTestPolicyModel.log",
+ "-o",
+ "target/ExecutionPropertiesTestPolicyModel.json"
+ };
+ // @formatter:on
+
+ new ApexCommandLineEditorMain(cliArgs);
+ }
+
+ /**
+ * Clear relative file root environment variable.
+ */
+ @Before
+ public void clearRelativeFileRoot() {
+ System.clearProperty("APEX_RELATIVE_FILE_ROOT");
+ }
+
+ /**
+ * Test read only execution properties are returned from policy.
+ */
+ @Test
+ public void testReadOnly() throws Exception {
+ testExecutionProperties("readOnly");
+ }
+
+ /**
+ * Test where execution properties set in task.
+ */
+ @Test
+ public void testEmptyToDefined() throws Exception {
+ testExecutionProperties("emptyToDefined");
+ }
+
+ /**
+ * Test where execution properties cleared in task.
+ */
+ @Test
+ public void testDefinedToEmpty() throws Exception {
+ testExecutionProperties("definedToEmpty");
+ }
+
+ /**
+ * Test where an execution properties added in task.
+ */
+ @Test
+ public void testAddProperty() throws Exception {
+ testExecutionProperties("addProperty");
+ }
+
+ /**
+ * Test empty properties are transferred correctly.
+ */
+ @Test
+ public void testEmptyToEmpty() throws Exception {
+ testExecutionProperties("emptyToEmpty");
+ }
+
+ private void testExecutionProperties(final String testName) throws Exception {
+ File compiledPolicyFile = new File("target/ExecutionPropertiesTestPolicyModel.json");
+ assertTrue(compiledPolicyFile.exists());
+
+ new File("target/" + testName + "_out.properties").delete();
+
+ // @formatter:off
+ final String[] args = {
+ "-rfr",
+ "target",
+ "-c",
+ "src/test/resources/testdata/executionproperties/" + testName + "_conf.json"
+ };
+ // @formatter:on
+ final ApexMain apexMain = new ApexMain(args);
+
+ // TODO: Set back to 10 seconds
+ await().atMost(10000, TimeUnit.SECONDS)
+ .until(() -> new File("target/" + testName + "_out.properties").exists());
+
+ apexMain.shutdown();
+
+ Properties expectedProperties = new Properties();
+ expectedProperties.load(new FileInputStream(
+ new File("src/test/resources/testdata/executionproperties/" + testName + "_out_expected.properties")));
+
+ Properties actualProperties = new Properties();
+ actualProperties.load(new FileInputStream(new File("target/" + testName + "_out.properties")));
+
+ assertEquals(expectedProperties, actualProperties);
+ }
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+executor.logger.info(executor.outFields);
+
+executor.logger.info("executionProperties in:" + executor.getExecutionProperties());
+
+var executionProperties = new java.util.Properties();
+
+executor.getExecutionProperties().setProperty("goodbye", "mars");
+
+executor.logger.info("executionProperties out:" + executor.getExecutionProperties());
+
+var returnValue = executor.isTrue;
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+executor.logger.info(executor.outFields);
+
+executor.logger.info("executionProperties in:" + executor.getExecutionProperties());
+
+var executionProperties = new java.util.Properties();
+
+executor.getExecutionProperties().clear();
+
+executor.logger.info("executionProperties out:" + executor.getExecutionProperties());
+
+var returnValue = executor.isTrue;
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+executor.logger.info(executor.outFields);
+
+executor.logger.info("executionProperties in:" + executor.getExecutionProperties());
+
+var executionProperties = new java.util.Properties();
+
+executor.getExecutionProperties().setProperty("hello", "world");
+
+executor.logger.info("executionProperties out:" + executor.getExecutionProperties());
+
+var returnValue = executor.isTrue;
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+executor.logger.info(executor.outFields);
+
+executor.logger.info("executionProperties:" + executor.getExecutionProperties());
+
+var returnValue = executor.isTrue;
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+executor.logger.info(executor.outFields);
+
+executor.logger.info("executionProperties:" + executor.getExecutionProperties());
+
+var returnValue = executor.isTrue;
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+executor.logger.info(executor.outFields);
+
+executor.logger.info("executionProperties in:" + executor.getExecutionProperties());
+
+var executionProperties = new java.util.Properties();
+
+executor.getExecutionProperties().remove("hello");
+
+executor.logger.info("executionProperties out:" + executor.getExecutionProperties());
+
+var returnValue = executor.isTrue;
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+var returnValue = executor.isTrue;
+
+executor.logger.info("executionProperties:" + executor.getExecutionProperties());
+
+switch (executor.inFields.get("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.subject.getTaskKey("ReadOnlyTask").copyTo(executor.selectedTask);
+}
+
+executor.logger.info("Selected Task:" + executor.selectedTask);
--- /dev/null
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 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=========================================================
+#-------------------------------------------------------------------------------
+
+model create name=ExecutionPropertiesTestPolicyModel
+
+schema create name=SimpleStringType flavour=Java schema=java.lang.String
+schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer
+
+event create name=RunTestEvent nameSpace=org.onap.policy.apex.domains.test source=JUNIT target=apex
+event parameter create name=RunTestEvent parName=testToRun schemaName=SimpleStringType
+
+task create name=ReadOnlyTask
+
+task inputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
+task outputfield create name=ReadOnlyTask fieldName=testToRun schemaName=SimpleStringType
+
+task logic create name=ReadOnlyTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/executionproperties/logic/ReadOnlyTask.js"
+LE
+
+task create name=EmptyToEmptyTask
+
+task inputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
+task outputfield create name=EmptyToEmptyTask fieldName=testToRun schemaName=SimpleStringType
+
+task logic create name=EmptyToEmptyTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/executionproperties/logic/EmptyToEmptyTask.js"
+LE
+
+task create name=EmptyToDefinedTask
+
+task inputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
+task outputfield create name=EmptyToDefinedTask fieldName=testToRun schemaName=SimpleStringType
+
+task logic create name=EmptyToDefinedTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/executionproperties/logic/EmptyToDefinedTask.js"
+LE
+
+task create name=DefinedToEmptyTask
+
+task inputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
+task outputfield create name=DefinedToEmptyTask fieldName=testToRun schemaName=SimpleStringType
+
+task logic create name=DefinedToEmptyTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/executionproperties/logic/DefinedToEmptyTask.js"
+LE
+
+task create name=AddPropertyTask
+
+task inputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
+task outputfield create name=AddPropertyTask fieldName=testToRun schemaName=SimpleStringType
+
+task logic create name=AddPropertyTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/executionproperties/logic/AddPropertyTask.js"
+LE
+
+task create name=RemovePropertyTask
+
+task inputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
+task outputfield create name=RemovePropertyTask fieldName=testToRun schemaName=SimpleStringType
+
+task logic create name=RemovePropertyTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/executionproperties/logic/RemovePropertyTask.js"
+LE
+
+policy create name=ExecutionPropertiesTestPolicy template=freestyle firstState=RunTestState
+
+policy state create name=ExecutionPropertiesTestPolicy stateName=RunTestState triggerName=RunTestEvent defaultTaskName=ReadOnlyTask
+policy state output create name=ExecutionPropertiesTestPolicy stateName=RunTestState outputName=TestFinalOutput eventName=RunTestEvent
+policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=ReadOnlyTask outputType=DIRECT outputName=TestFinalOutput
+policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToEmptyTask outputType=DIRECT outputName=TestFinalOutput
+policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=EmptyToDefinedTask outputType=DIRECT outputName=TestFinalOutput
+policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=DefinedToEmptyTask outputType=DIRECT outputName=TestFinalOutput
+policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=AddPropertyTask outputType=DIRECT outputName=TestFinalOutput
+policy state taskref create name=ExecutionPropertiesTestPolicy stateName=RunTestState taskName=RemovePropertyTask outputType=DIRECT outputName=TestFinalOutput
+
+policy state selecttasklogic create name=ExecutionPropertiesTestPolicy stateName=RunTestState logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/executionproperties/logic/RunTestStateTSL.js"
+LE
+
+validate
+
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "ExecutionPropertiesTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "AddProperty",
+ "propertyFileName": "src/test/resources/testdata/executionproperties/addProperty_in.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "RunTestEvent"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "AddProperty",
+ "propertyFileName": "target/addProperty_out.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+hello=world
\ No newline at end of file
--- /dev/null
+hello=world
+goodbye=mars
\ No newline at end of file
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "ExecutionPropertiesTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "DefinedToEmpty",
+ "propertyFileName": "src/test/resources/testdata/executionproperties/definedToEmpty_in.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "RunTestEvent"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "DefinedToEmpty",
+ "propertyFileName": "target/definedToEmpty_out.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+hello=world
\ No newline at end of file
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "ExecutionPropertiesTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "EmptyToDefined",
+ "propertyFileName": "src/test/resources/testdata/executionproperties/emptyToDefined_in.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "RunTestEvent"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "EmptyToDefined",
+ "propertyFileName": "target/emptyToDefined_out.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+hello=world
\ No newline at end of file
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "ExecutionPropertiesTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "EmptyToEmpty",
+ "propertyFileName": "src/test/resources/testdata/executionproperties/emptyToEmpty_in.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "RunTestEvent"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "EmptyToEmpty",
+ "propertyFileName": "target/emptyToEmpty_out.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+NULL
\ No newline at end of file
--- /dev/null
+NULL
\ No newline at end of file
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "ExecutionPropertiesTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "ReadOnly",
+ "propertyFileName": "src/test/resources/testdata/executionproperties/readOnly_in.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "RunTestEvent"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "ReadOnly",
+ "propertyFileName": "target/readOnly_out.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+hello=world
\ No newline at end of file
--- /dev/null
+hello=world
\ No newline at end of file
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "ExecutionPropertiesTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "RemoveProperty",
+ "propertyFileName": "src/test/resources/testdata/executionproperties/removeProperty_in.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "RunTestEvent"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "DUMMY",
+ "parameterClassName": "org.onap.policy.apex.testsuites.integration.uservice.executionproperties.DummyCarrierTechnologyParameters",
+ "parameters": {
+ "testToRun": "RemoveProperty",
+ "propertyFileName": "target/removeProperty_out.properties"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+hello=world
+goodbye=mars
\ No newline at end of file
--- /dev/null
+goodbye=mars
\ No newline at end of file