diff options
257 files changed, 3481 insertions, 2276 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java index 30e883aae..75ac1fe03 100644 --- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java +++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java @@ -84,7 +84,7 @@ import org.stringtemplate.v4.STGroupFile; * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) */ -public class CGCliEditor { +public class CodeGeneratorCliEditor { // CHECKSTYLE:OFF: ParameterNumber @@ -103,7 +103,7 @@ public class CGCliEditor { /** * Creates a new code generator. */ - public CGCliEditor() { + public CodeGeneratorCliEditor() { stg = new STGroupFile(STG_FILE); stg.registerRenderer(String.class, new CgStringRenderer(), true); model = stg.getInstanceOf("policyModel"); diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestSTG.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java index 1fbc78de9..851c06631 100644 --- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestSTG.java +++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java @@ -30,7 +30,7 @@ import java.util.Set; import java.util.TreeSet; import org.junit.Test; -import org.onap.policy.apex.auth.clicodegen.CGCliEditor; +import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor; import org.stringtemplate.v4.STGroup; import org.stringtemplate.v4.STGroupFile; @@ -39,7 +39,7 @@ import org.stringtemplate.v4.STGroupFile; * * @author Sven van der Meer (sven.van.der.meer@ericsson.com) */ -public class TestSTG { +public class TestGeneration { /** * Get the chunks for the codegen. @@ -89,9 +89,9 @@ public class TestSTG { /** Test STG load. */ @Test - public void testSTGLoad() { + public void testGenerationLoad() { final StErrorListener errListener = new StErrorListener(); - final STGroupFile stg = new STGroupFile(CGCliEditor.STG_FILE); + final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE); stg.setListener(errListener); stg.getTemplateNames(); // dummy to compile group and get errors @@ -100,9 +100,9 @@ public class TestSTG { /** Test STG chunks. */ @Test - public void testSTGChunks() { + public void testGenerationChunks() { final StErrorListener errListener = new StErrorListener(); - final STGroupFile stg = new STGroupFile(CGCliEditor.STG_FILE); + final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE); stg.setListener(errListener); stg.getTemplateNames(); // dummy to compile group and get errors diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java index 718c75a96..0df8ac629 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java @@ -34,15 +34,15 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class ApexCLIEditorMain { +public class ApexCommandLineEditorMain { // Get a reference to the logger - private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexCLIEditorMain.class); + private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexCommandLineEditorMain.class); // The editor parameters - private CLIParameters parameters; + private CommandLineParameters parameters; // The CLI commands read in from JSON - private CLICommands commands; + private CommandLineCommands commands; // The Apex model properties read in from JSON private ApexModelProperties apexModelProperties; @@ -55,15 +55,16 @@ public class ApexCLIEditorMain { * * @param args the command line arguments */ - public ApexCLIEditorMain(final String[] args) { - LOGGER.info("Starting Apex CLI editor {} . . .", Arrays.toString(args)); + public ApexCommandLineEditorMain(final String[] args) { + String startMessage = "Starting Apex CLI editor " + Arrays.toString(args) + " . . ."; + LOGGER.info(startMessage); try { - final CLIParameterParser parser = new CLIParameterParser(); + final CommandLineParameterParser parser = new CommandLineParameterParser(); parameters = parser.parse(args); if (parameters.isHelpSet()) { - parser.help(ApexCLIEditorMain.class.getCanonicalName()); + parser.help(ApexCommandLineEditorMain.class.getCanonicalName()); return; } parameters.validate(); @@ -73,14 +74,16 @@ public class ApexCLIEditorMain { return; } - LOGGER.debug("parameters are: {}", parameters.toString()); + String message = "parameters are: " + parameters.toString(); + LOGGER.debug(message); // Read the command definitions try { - commands = new JsonHandler<CLICommands>().read(CLICommands.class, parameters.getMetadataStream()); + commands = new JsonHandler<CommandLineCommands>().read(CommandLineCommands.class, + parameters.getMetadataStream()); } catch (final Exception e) { LOGGER.error("start of Apex command line editor failed, error reading command metadata from {}", - parameters.getMetadataLocation(), e); + parameters.getMetadataLocation(), e); errorCount++; return; } @@ -88,7 +91,7 @@ public class ApexCLIEditorMain { // The JSON processing returns null if there is an empty file if (commands == null || commands.getCommandSet().isEmpty()) { LOGGER.error("start of Apex command line editor failed, no commands found in {}", - parameters.getApexPropertiesLocation()); + parameters.getApexPropertiesLocation()); errorCount++; return; } @@ -98,10 +101,10 @@ public class ApexCLIEditorMain { // Read the Apex properties try { apexModelProperties = new JsonHandler<ApexModelProperties>().read(ApexModelProperties.class, - parameters.getApexPropertiesStream()); + parameters.getApexPropertiesStream()); } catch (final Exception e) { LOGGER.error("start of Apex command line editor failed, error reading Apex model properties from " - + parameters.getApexPropertiesLocation()); + + parameters.getApexPropertiesLocation()); LOGGER.error(e.getMessage()); errorCount++; return; @@ -110,16 +113,17 @@ public class ApexCLIEditorMain { // The JSON processing returns null if there is an empty file if (apexModelProperties == null) { LOGGER.error("start of Apex command line editor failed, no Apex model properties found in {}", - parameters.getApexPropertiesLocation()); + parameters.getApexPropertiesLocation()); errorCount++; return; } - LOGGER.debug("model properties are: {}", apexModelProperties.toString()); + String modelPropertiesString = "model properties are: " + apexModelProperties.toString(); + LOGGER.debug(modelPropertiesString); // Find the system commands final Set<KeywordNode> systemCommandNodes = new TreeSet<>(); - for (final CLICommand command : commands.getCommandSet()) { + for (final CommandLineCommand command : commands.getCommandSet()) { if (command.isSystemCommand()) { systemCommandNodes.add(new KeywordNode(command.getName(), command)); } @@ -127,7 +131,7 @@ public class ApexCLIEditorMain { // Read in the command hierarchy, this builds a tree of commands final KeywordNode rootKeywordNode = new KeywordNode("root"); - for (final CLICommand command : commands.getCommandSet()) { + for (final CommandLineCommand command : commands.getCommandSet()) { rootKeywordNode.processKeywords(command.getKeywordlist(), command); } rootKeywordNode.addSystemCommandNodes(systemCommandNodes); @@ -135,25 +139,25 @@ public class ApexCLIEditorMain { // Create the model we will work towards ApexModelHandler modelHandler = null; try { - modelHandler = - new ApexModelHandler(apexModelProperties.getProperties(), parameters.getInputModelFileName()); + modelHandler = new ApexModelHandler(apexModelProperties.getProperties(), + parameters.getInputModelFileName()); } catch (final Exception e) { LOGGER.error("execution of Apex command line editor failed: ", e); errorCount++; return; } - final CLIEditorLoop cliEditorLoop = - new CLIEditorLoop(apexModelProperties.getProperties(), modelHandler, rootKeywordNode); + final CommandLineEditorLoop cliEditorLoop = new CommandLineEditorLoop(apexModelProperties.getProperties(), + modelHandler, rootKeywordNode); try { - errorCount = - cliEditorLoop.runLoop(parameters.getCommandInputStream(), parameters.getOutputStream(), parameters); + errorCount = cliEditorLoop.runLoop(parameters.getCommandInputStream(), parameters.getOutputStream(), + parameters); if (errorCount == 0) { LOGGER.info("Apex CLI editor completed execution"); } else { LOGGER.error("execution of Apex command line editor failed: {} command execution failure(s) occurred", - errorCount); + errorCount); } } catch (final IOException e) { LOGGER.error("execution of Apex command line editor failed: " + e.getMessage()); @@ -178,14 +182,13 @@ public class ApexCLIEditorMain { this.errorCount = errorCount; } - /** * The main method, kicks off the editor. * * @param args the arguments */ public static void main(final String[] args) { - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(args); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(args); // Only call system.exit on errors as it brings the JVM down if (cliEditor.getErrorCount() > 0) { diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java index 2cf2633b2..2e1a4732b 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java @@ -24,7 +24,7 @@ import java.io.PrintWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Properties; -import java.util.TreeMap; +import java.util.SortedMap; import org.onap.policy.apex.model.modelapi.ApexApiResult; import org.onap.policy.apex.model.modelapi.ApexModel; @@ -64,7 +64,7 @@ public class ApexModelHandler { final ApexApiResult result = apexModel.loadFromFile(modelFileName); if (result.isNok()) { - throw new CLIException(result.getMessages().get(0)); + throw new CommandLineException(result.getMessages().get(0)); } } @@ -76,8 +76,8 @@ public class ApexModelHandler { * @param writer A writer to which to write output * @return the result of the executed command */ - public ApexApiResult executeCommand(final CLICommand command, - final TreeMap<String, CLIArgumentValue> argumentValues, final PrintWriter writer) { + public ApexApiResult executeCommand(final CommandLineCommand command, + final SortedMap<String, CommandLineArgumentValue> argumentValues, final PrintWriter writer) { // Get the method final Method apiMethod = getCommandMethod(command); @@ -92,22 +92,22 @@ public class ApexModelHandler { writer.println(result); return result; } else { - throw new CLIException( - INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND - + command.getName() + "\" the returned object is not an instance of ApexAPIResult"); + throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + + FAILED_FOR_COMMAND + command.getName() + + "\" the returned object is not an instance of ApexAPIResult"); } } catch (IllegalAccessException | IllegalArgumentException e) { writer.println(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND - + command.getName() + "\""); + + command.getName() + "\""); e.printStackTrace(writer); - throw new CLIException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() - + FAILED_FOR_COMMAND + command.getName() + "\"", e); + throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND + + command.getName() + "\"", e); } catch (final InvocationTargetException e) { writer.println(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND - + command.getName() + "\""); + + command.getName() + "\""); e.getCause().printStackTrace(writer); - throw new CLIException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() - + FAILED_FOR_COMMAND + command.getName() + "\"", e); + throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND + + command.getName() + "\"", e); } } @@ -117,9 +117,9 @@ public class ApexModelHandler { * @param command The command * @return the API method */ - private Method getCommandMethod(final CLICommand command) { - final String className = command.getAPIClassName(); - final String methodName = command.getAPIMethodName(); + private Method getCommandMethod(final CommandLineCommand command) { + final String className = command.getApiClassName(); + final String methodName = command.getApiMethodName(); try { final Class<? extends Object> apiClass = Class.forName(className); @@ -128,11 +128,11 @@ public class ApexModelHandler { return apiMethod; } } - throw new CLIException("specified method \"" + command.getApiMethod() + "\" not found for command \"" - + command.getName() + "\""); + throw new CommandLineException("specified method \"" + command.getApiMethod() + + "\" not found for command \"" + command.getName() + "\""); } catch (final ClassNotFoundException e) { - throw new CLIException("specified class \"" + command.getApiMethod() + "\" not found for command \"" - + command.getName() + "\""); + throw new CommandLineException("specified class \"" + command.getApiMethod() + "\" not found for command \"" + + command.getName() + "\""); } } @@ -144,26 +144,26 @@ public class ApexModelHandler { * @param apiMethod the method itself * @return the argument list */ - private Object[] getParameterArray(final CLICommand command, final TreeMap<String, CLIArgumentValue> argumentValues, - final Method apiMethod) { + private Object[] getParameterArray(final CommandLineCommand command, + final SortedMap<String, CommandLineArgumentValue> argumentValues, final Method apiMethod) { final Object[] parameterArray = new Object[argumentValues.size()]; - int i = 0; + int item = 0; try { for (final Class<?> parametertype : apiMethod.getParameterTypes()) { - final String parameterValue = - argumentValues.get(command.getArgumentList().get(i).getArgumentName()).getValue(); + final String parameterValue = argumentValues.get(command.getArgumentList().get(item).getArgumentName()) + .getValue(); if (parametertype.equals(boolean.class)) { - parameterArray[i] = Boolean.valueOf(parameterValue); + parameterArray[item] = Boolean.valueOf(parameterValue); } else { - parameterArray[i] = parameterValue; + parameterArray[item] = parameterValue; } - i++; + item++; } } catch (final Exception e) { - throw new CLIException("number of argument mismatch on method \"" + command.getApiMethod() - + "\" for command \"" + command.getName() + "\""); + throw new CommandLineException("number of argument mismatch on method \"" + command.getApiMethod() + + "\" for command \"" + command.getName() + "\""); } return parameterArray; diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java index b215f69e4..f1a6e7867 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java @@ -27,7 +27,7 @@ import org.onap.policy.apex.model.utilities.Assertions; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLIArgument implements Comparable<CLIArgument> { +public class CommandLineArgument implements Comparable<CommandLineArgument> { private final String argumentName; private final boolean nullable; private final String description; @@ -36,7 +36,7 @@ public class CLIArgument implements Comparable<CLIArgument> { * This Constructor constructs a non nullable command line argument with a blank name and * description. */ - public CLIArgument() { + public CommandLineArgument() { this("", false, ""); } @@ -46,7 +46,7 @@ public class CLIArgument implements Comparable<CLIArgument> { * * @param incomingArgumentName the argument name */ - public CLIArgument(final String incomingArgumentName) { + public CommandLineArgument(final String incomingArgumentName) { this(incomingArgumentName, false, ""); } @@ -58,7 +58,7 @@ public class CLIArgument implements Comparable<CLIArgument> { * @param nullable the nullable * @param description the description */ - public CLIArgument(final String argumentName, final boolean nullable, final String description) { + public CommandLineArgument(final String argumentName, final boolean nullable, final String description) { this.argumentName = argumentName; this.nullable = nullable; this.description = description; @@ -121,7 +121,7 @@ public class CLIArgument implements Comparable<CLIArgument> { * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override - public int compareTo(final CLIArgument otherArgument) { + public int compareTo(final CommandLineArgument otherArgument) { Assertions.argumentNotNull(otherArgument, "comparison object may not be null"); if (this == otherArgument) { @@ -131,7 +131,7 @@ public class CLIArgument implements Comparable<CLIArgument> { return this.hashCode() - otherArgument.hashCode(); } - final CLIArgument other = otherArgument; + final CommandLineArgument other = otherArgument; if (!argumentName.equals(other.argumentName)) { return argumentName.compareTo(other.argumentName); diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java index d87a8dc5b..64059e31b 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java @@ -25,8 +25,8 @@ package org.onap.policy.apex.auth.clieditor; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLIArgumentValue { - private final CLIArgument cliArgument; +public class CommandLineArgumentValue { + private final CommandLineArgument cliArgument; private boolean specified; private String value; @@ -36,7 +36,7 @@ public class CLIArgumentValue { * * @param cliArgument the argument for which this object is a value */ - public CLIArgumentValue(final CLIArgument cliArgument) { + public CommandLineArgumentValue(final CommandLineArgument cliArgument) { this.cliArgument = cliArgument; specified = false; value = null; @@ -47,7 +47,7 @@ public class CLIArgumentValue { * * @return the argument for which this object is a value */ - public CLIArgument getCliArgument() { + public CommandLineArgument getCliArgument() { return cliArgument; } diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java index 40c0a40a5..6c651cb6b 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java @@ -31,10 +31,10 @@ import org.onap.policy.apex.model.utilities.Assertions; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLICommand implements Comparable<CLICommand> { +public class CommandLineCommand implements Comparable<CommandLineCommand> { private String name = ""; private final List<String> keywordlist = new ArrayList<>(); - private final List<CLIArgument> argumentList = new ArrayList<>(); + private final List<CommandLineArgument> argumentList = new ArrayList<>(); private String apiMethod = ""; private boolean systemCommand = false; private String description = ""; @@ -44,10 +44,10 @@ public class CLICommand implements Comparable<CLICommand> { * * @return the class name of the class that executes this command in the Java API */ - public String getAPIClassName() { + public String getApiClassName() { final int lastDotPos = apiMethod.lastIndexOf('.'); if (lastDotPos == -1) { - throw new CLIException("invalid API method name specified on command \"" + name + throw new CommandLineException("invalid API method name specified on command \"" + name + "\", class name not found: " + apiMethod); } return apiMethod.substring(0, lastDotPos); @@ -58,14 +58,14 @@ public class CLICommand implements Comparable<CLICommand> { * * @return the the method name of the method that executes this command in the Java API */ - public String getAPIMethodName() { + public String getApiMethodName() { final int lastDotPos = apiMethod.lastIndexOf('.'); if (lastDotPos == -1) { - throw new CLIException("invalid API method name specified on command \"" + name + throw new CommandLineException("invalid API method name specified on command \"" + name + "\", class name not found: " + apiMethod); } if (lastDotPos == apiMethod.length() - 1) { - throw new CLIException("no API method name specified on command \"" + name + "\": " + apiMethod); + throw new CommandLineException("no API method name specified on command \"" + name + "\": " + apiMethod); } return apiMethod.substring(lastDotPos + 1); } @@ -102,7 +102,7 @@ public class CLICommand implements Comparable<CLICommand> { * * @return the list of arguments for this command */ - public List<CLIArgument> getArgumentList() { + public List<CommandLineArgument> getArgumentList() { return argumentList; } @@ -176,7 +176,7 @@ public class CLICommand implements Comparable<CLICommand> { builder.append("}: "); builder.append(description); - for (final CLIArgument argument : argumentList) { + for (final CommandLineArgument argument : argumentList) { if (argument == null) { continue; } @@ -204,7 +204,7 @@ public class CLICommand implements Comparable<CLICommand> { * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override - public int compareTo(final CLICommand otherCommand) { + public int compareTo(final CommandLineCommand otherCommand) { Assertions.argumentNotNull(otherCommand, "comparison object may not be null"); if (this == otherCommand) { @@ -214,7 +214,7 @@ public class CLICommand implements Comparable<CLICommand> { return this.hashCode() - otherCommand.hashCode(); } - final CLICommand other = otherCommand; + final CommandLineCommand other = otherCommand; for (int i = 0, j = 0;; i++, j++) { if (i < keywordlist.size() && j < otherCommand.keywordlist.size()) { diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommands.java index 4c9bab045..45d8a4bd3 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommands.java @@ -28,15 +28,15 @@ import java.util.TreeSet; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLICommands { - private final Set<CLICommand> commandList = new TreeSet<>(); +public class CommandLineCommands { + private final Set<CommandLineCommand> commandList = new TreeSet<>(); /** * Gets the command set. * * @return the command set */ - public Set<CLICommand> getCommandSet() { + public Set<CommandLineCommand> getCommandSet() { return commandList; } } diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java index a574099bf..7a34ce7c1 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java @@ -45,12 +45,12 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.model.utilities.TreeMapUtils; /** - * This class implements the editor loop, the loop of execution that continuously executes commands - * until the quit command is issued or EOF is detected on input. + * This class implements the editor loop, the loop of execution that continuously executes commands until the quit + * command is issued or EOF is detected on input. * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLIEditorLoop { +public class CommandLineEditorLoop { // The model handler that is handling the API towards the Apex model being editied private final ApexModelHandler modelHandler; @@ -71,8 +71,8 @@ public class CLIEditorLoop { * @param modelHandler the model handler that will handle commands * @param rootKeywordNode The root keyword node tree */ - public CLIEditorLoop(final Properties properties, final ApexModelHandler modelHandler, - final KeywordNode rootKeywordNode) { + public CommandLineEditorLoop(final Properties properties, final ApexModelHandler modelHandler, + final KeywordNode rootKeywordNode) { this.modelHandler = modelHandler; keywordNodeDeque.push(rootKeywordNode); @@ -90,14 +90,14 @@ public class CLIEditorLoop { * @return the exit code from command processing * @throws IOException Thrown on exceptions on IO */ - public int runLoop(final InputStream inputStream, final OutputStream outputStream, final CLIParameters parameters) - throws IOException { + public int runLoop(final InputStream inputStream, final OutputStream outputStream, + final CommandLineParameters parameters) throws IOException { // Readers and writers for input and output final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); final PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream)); // The parser parses the input lines into commands and arguments - final CLILineParser parser = new CLILineParser(); + final CommandLineParser parser = new CommandLineParser(); // The main loop for command handing, it continues until EOF on the input stream or until a // quit command @@ -123,7 +123,7 @@ public class CLIEditorLoop { } } // Print any error messages from command parsing and finding - catch (final CLIException e) { + catch (final CommandLineException e) { writer.println(e.getMessage()); errorCount++; continue; @@ -151,7 +151,7 @@ public class CLIEditorLoop { } } // Print any error messages from command parsing and finding - catch (final CLIException e) { + catch (final CommandLineException e) { writer.println(e.getMessage()); errorCount++; continue; @@ -176,10 +176,11 @@ public class CLIEditorLoop { // Find the command, if the command is null, then we are simply changing position in // the hierarchy - final CLICommand command = findCommand(commandWords); + final CommandLineCommand command = findCommand(commandWords); if (command != null) { // Check the arguments of the command - final TreeMap<String, CLIArgumentValue> argumentValues = getArgumentValues(command, commandWords); + final TreeMap<String, CommandLineArgumentValue> argumentValues = getArgumentValues(command, + commandWords); // Execute the command, a FINISHED result means a command causes the loop to // leave execution @@ -190,7 +191,7 @@ public class CLIEditorLoop { } } // Print any error messages from command parsing and finding - catch (final CLIException e) { + catch (final CommandLineException e) { writer.println(e.getMessage()); errorCount++; } catch (final Exception e) { @@ -234,16 +235,15 @@ public class CLIEditorLoop { } /** - * Finds a command for the given input command words. Command words need only ne specified - * enough to uniquely identify them. Therefore, "p s o c" will find the command "policy state - * output create" + * Finds a command for the given input command words. Command words need only ne specified enough to uniquely + * identify them. Therefore, "p s o c" will find the command "policy state output create" * * @param commandWords The commands and arguments parsed from the command line by the parser * @return The found command */ - private CLICommand findCommand(final List<String> commandWords) { - CLICommand command = null; + private CommandLineCommand findCommand(final List<String> commandWords) { + CommandLineCommand command = null; final KeywordNode startKeywordNode = keywordNodeDeque.peek(); @@ -254,20 +254,20 @@ public class CLIEditorLoop { // We have got to the arguments, time to stop looking if (commandWords.get(i).indexOf('=') > 0) { unwindStack(startKeywordNode); - throw new CLIException("command not found: " + stringAL2String(commandWords)); + throw new CommandLineException("command not found: " + stringAL2String(commandWords)); } // If the node entries found is not equal to one, then we have either no command or more // than one command matching - final List<Entry<String, KeywordNode>> foundNodeEntries = - findMatchingEntries(searchKeywordNode.getChildren(), commandWords.get(i)); + final List<Entry<String, KeywordNode>> foundNodeEntries = findMatchingEntries( + searchKeywordNode.getChildren(), commandWords.get(i)); if (foundNodeEntries.isEmpty()) { unwindStack(startKeywordNode); - throw new CLIException("command not found: " + stringAL2String(commandWords)); + throw new CommandLineException("command not found: " + stringAL2String(commandWords)); } else if (foundNodeEntries.size() > 1) { unwindStack(startKeywordNode); - throw new CLIException("multiple commands matched: " + stringAL2String(commandWords) + " [" - + nodeAL2String(foundNodeEntries) + ']'); + throw new CommandLineException("multiple commands matched: " + stringAL2String(commandWords) + " [" + + nodeAL2String(foundNodeEntries) + ']'); } // Record the fully expanded command word @@ -312,25 +312,25 @@ public class CLIEditorLoop { * @param commandWords The command words entered * @return the argument values */ - private TreeMap<String, CLIArgumentValue> getArgumentValues(final CLICommand command, - final List<String> commandWords) { - final TreeMap<String, CLIArgumentValue> argumentValues = new TreeMap<>(); - for (final CLIArgument argument : command.getArgumentList()) { + private TreeMap<String, CommandLineArgumentValue> getArgumentValues(final CommandLineCommand command, + final List<String> commandWords) { + final TreeMap<String, CommandLineArgumentValue> argumentValues = new TreeMap<>(); + for (final CommandLineArgument argument : command.getArgumentList()) { if (argument != null) { - argumentValues.put(argument.getArgumentName(), new CLIArgumentValue(argument)); + argumentValues.put(argument.getArgumentName(), new CommandLineArgumentValue(argument)); } } // Set the value of the arguments for (final Entry<String, String> argument : getCommandArguments(commandWords)) { - final List<Entry<String, CLIArgumentValue>> foundArguments = - TreeMapUtils.findMatchingEntries(argumentValues, argument.getKey()); + final List<Entry<String, CommandLineArgumentValue>> foundArguments = TreeMapUtils + .findMatchingEntries(argumentValues, argument.getKey()); if (foundArguments.size() == 0) { - throw new CLIException("command " + stringAL2String(commandWords) + ": " + " argument \"" - + argument.getKey() + "\" not allowed on command"); + throw new CommandLineException("command " + stringAL2String(commandWords) + ": " + " argument \"" + + argument.getKey() + "\" not allowed on command"); } else if (foundArguments.size() > 1) { - throw new CLIException("command " + stringAL2String(commandWords) + ": " + " argument " + argument - + " matches multiple arguments [" + argumentAL2String(foundArguments) + ']'); + throw new CommandLineException("command " + stringAL2String(commandWords) + ": " + " argument " + + argument + " matches multiple arguments [" + argumentAL2String(foundArguments) + ']'); } // Set the value of the argument, stripping off any quotes @@ -339,12 +339,13 @@ public class CLIEditorLoop { } // Now check all mandatory arguments are set - for (final CLIArgumentValue argumentValue : argumentValues.values()) { + for (final CommandLineArgumentValue argumentValue : argumentValues.values()) { // Argument values are null by default so if this argument is not nullable it is // mandatory if (!argumentValue.isSpecified() && !argumentValue.getCliArgument().isNullable()) { - throw new CLIException("command " + stringAL2String(commandWords) + ": " + " mandatory argument \"" - + argumentValue.getCliArgument().getArgumentName() + "\" not specified"); + throw new CommandLineException("command " + stringAL2String(commandWords) + ": " + + " mandatory argument \"" + argumentValue.getCliArgument().getArgumentName() + + "\" not specified"); } } @@ -352,8 +353,8 @@ public class CLIEditorLoop { } /** - * Get the arguments of the command, the command words have already been conditioned into an - * array starting with the command words and ending with the arguments as name=value tuples. + * Get the arguments of the command, the command words have already been conditioned into an array starting with the + * command words and ending with the arguments as name=value tuples. * * @param commandWords The command words entered by the user * @return the arguments as an entry array list @@ -365,8 +366,8 @@ public class CLIEditorLoop { for (final String word : commandWords) { final int equalsPos = word.indexOf('='); if (equalsPos > 0) { - arguments.add( - new SimpleEntry<>(word.substring(0, equalsPos), word.substring(equalsPos + 1, word.length()))); + arguments.add(new SimpleEntry<>(word.substring(0, equalsPos), + word.substring(equalsPos + 1, word.length()))); } } @@ -381,8 +382,8 @@ public class CLIEditorLoop { * @param writer The writer to use for any output from the command * @return the result of execution of the command */ - private ApexApiResult executeCommand(final CLICommand command, - final TreeMap<String, CLIArgumentValue> argumentValues, final PrintWriter writer) { + private ApexApiResult executeCommand(final CommandLineCommand command, + final TreeMap<String, CommandLineArgumentValue> argumentValues, final PrintWriter writer) { if (command.isSystemCommand()) { return exceuteSystemCommand(command, writer); } else { @@ -397,7 +398,7 @@ public class CLIEditorLoop { * @param writer The writer to use for any output from the command * @return the result of execution of the command */ - private ApexApiResult exceuteSystemCommand(final CLICommand command, final PrintWriter writer) { + private ApexApiResult exceuteSystemCommand(final CommandLineCommand command, final PrintWriter writer) { if ("back".equals(command.getName())) { return executeBackCommand(); } else if ("help".equals(command.getName())) { @@ -437,7 +438,7 @@ public class CLIEditorLoop { * @return the result of execution of the command */ private ApexApiResult executeHelpCommand(final PrintWriter writer) { - for (final CLICommand command : keywordNodeDeque.peek().getCommands()) { + for (final CommandLineCommand command : keywordNodeDeque.peek().getCommands()) { writer.println(command.getHelp()); } return new ApexApiResult(Result.SUCCESS); @@ -464,9 +465,9 @@ public class CLIEditorLoop { * @param argumentArrayList the argument array list * @return the string */ - private String argumentAL2String(final List<Entry<String, CLIArgumentValue>> argumentArrayList) { + private String argumentAL2String(final List<Entry<String, CommandLineArgumentValue>> argumentArrayList) { final ArrayList<String> stringArrayList = new ArrayList<>(); - for (final Entry<String, CLIArgumentValue> argument : argumentArrayList) { + for (final Entry<String, CommandLineArgumentValue> argument : argumentArrayList) { stringArrayList.add(argument.getValue().getCliArgument().getArgumentName()); } @@ -495,14 +496,14 @@ public class CLIEditorLoop { } /** - * This method reads in the file from a file macro statement, expands the macro, and replaces - * the Macro tag in the line with the file contents. + * This method reads in the file from a file macro statement, expands the macro, and replaces the Macro tag in the + * line with the file contents. * * @param parameters The parameters for the CLI editor * @param line The line with the macro keyword in it * @return the expanded line */ - private String expandMacroFile(final CLIParameters parameters, final String line) { + private String expandMacroFile(final CommandLineParameters parameters, final String line) { final int macroTagPos = line.indexOf(macroFileTag); // Get the line before and after the macro tag @@ -513,7 +514,7 @@ public class CLIEditorLoop { final String[] lineWords = lineAfterMacroTag.split("\\s+"); if (lineWords.length == 0) { - throw new CLIException("no file name specified for Macro File Tag"); + throw new CommandLineException("no file name specified for Macro File Tag"); } // Get the macro file name and the remainder of the line after the file name @@ -523,8 +524,8 @@ public class CLIEditorLoop { if (macroFileName.length() > 2 && macroFileName.startsWith("\"") && macroFileName.endsWith("\"")) { macroFileName = macroFileName.substring(1, macroFileName.length() - 1); } else { - throw new CLIException( - "macro file name \"" + macroFileName + "\" must exist and be quoted with double quotes \"\""); + throw new CommandLineException("macro file name \"" + macroFileName + + "\" must exist and be quoted with double quotes \"\""); } // Append the working directory to the macro file name @@ -535,7 +536,7 @@ public class CLIEditorLoop { try { macroFileContents = TextFileUtils.getTextFileAsString(macroFileName); } catch (final IOException e) { - throw new CLIException("file \"" + macroFileName + "\" specified in Macro File Tag not found", e); + throw new CommandLineException("file \"" + macroFileName + "\" specified in Macro File Tag not found", e); } return lineBeforeMacroTag + macroFileContents + lineAfterMacroFileName; diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineException.java index 94b8c14a6..4ff17458e 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineException.java @@ -25,7 +25,7 @@ package org.onap.policy.apex.auth.clieditor; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLIException extends IllegalArgumentException { +public class CommandLineException extends IllegalArgumentException { private static final long serialVersionUID = 6520231162404452427L; /** @@ -33,7 +33,7 @@ public class CLIException extends IllegalArgumentException { * * @param message the message */ - public CLIException(final String message) { + public CommandLineException(final String message) { super(message); } @@ -43,7 +43,7 @@ public class CLIException extends IllegalArgumentException { * @param message the message * @param th the throwable */ - public CLIException(final String message, final Throwable th) { + public CommandLineException(final String message, final Throwable th) { super(message, th); } } diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameterParser.java index 8a0c6eff3..a37d07fab 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameterParser.java @@ -35,7 +35,7 @@ import org.apache.commons.cli.ParseException; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLIParameterParser { +public class CommandLineParameterParser { private static final int MAX_HELP_LINE_LENGTH = 120; // Apache Commons CLI options @@ -44,44 +44,45 @@ public class CLIParameterParser { /** * Construct the options for the CLI editor. */ - public CLIParameterParser() { + public CommandLineParameterParser() { options = new Options(); options.addOption(Option.builder("h").longOpt("help").desc("outputs the usage of this command").required(false) - .type(Boolean.class).build()); + .type(Boolean.class).build()); options.addOption(Option.builder("m").longOpt("metadata-file").desc("name of the command metadata file to use") - .hasArg().argName("CMD_METADATA_FILE").required(false).type(String.class).build()); - options.addOption( - Option.builder("a").longOpt("model-props-file").desc("name of the apex model properties file to use") - .hasArg().argName("MODEL_PROPS_FILE").required(false).type(String.class).build()); + .hasArg().argName("CMD_METADATA_FILE").required(false).type(String.class).build()); + options.addOption(Option.builder("a").longOpt("model-props-file") + .desc("name of the apex model properties file to use").hasArg().argName("MODEL_PROPS_FILE") + .required(false).type(String.class).build()); options.addOption(Option.builder("c").longOpt("command-file") - .desc("name of a file containing editor commands to run into the editor").hasArg() - .argName("COMMAND_FILE").required(false).type(String.class).build()); - options.addOption(Option.builder("l").longOpt("log-file") - .desc("name of a file that will contain command logs from the editor, will log to standard output " - + "if not specified or suppressed with \"-nl\" flag") - .hasArg().argName("LOG_FILE").required(false).type(String.class).build()); - options.addOption(Option.builder("nl").longOpt("no-log") - .desc("if specified, no logging or output of commands to standard output or log file is carried out") - .required(false).type(Boolean.class).build()); - options.addOption(Option.builder("nm").longOpt("no-model-output") - .desc("if specified, no output of a model to standard output or model output file is carried out, " - + "the user can use the \"save\" command in a script to save a model") - .required(false).type(Boolean.class).build()); + .desc("name of a file containing editor commands to run into the editor").hasArg() + .argName("COMMAND_FILE").required(false).type(String.class).build()); + options.addOption(Option.builder("l").longOpt("log-file").desc( + "name of a file that will contain command logs from the editor, will log to standard output " + + "if not specified or suppressed with \"-nl\" flag") + .hasArg().argName("LOG_FILE").required(false).type(String.class).build()); + options.addOption(Option.builder("nl").longOpt("no-log").desc( + "if specified, no logging or output of commands to standard output or log file is carried out") + .required(false).type(Boolean.class).build()); + options.addOption(Option.builder("nm").longOpt("no-model-output").desc( + "if specified, no output of a model to standard output or model output file is carried out, " + + "the user can use the \"save\" command in a script to save a model") + .required(false).type(Boolean.class).build()); options.addOption(Option.builder("i").longOpt("input-model-file") - .desc("name of a file that contains an input model for the editor").hasArg().argName("INPUT_MODEL_FILE") - .required(false).type(String.class).build()); + .desc("name of a file that contains an input model for the editor").hasArg() + .argName("INPUT_MODEL_FILE").required(false).type(String.class).build()); options.addOption(Option.builder("o").longOpt("output-model-file") - .desc("name of a file that will contain the output model for the editor, " - + "will output model to standard output if not specified or suppressed with \"-nm\" flag") - .hasArg().argName("OUTPUT_MODEL_FILE").required(false).type(String.class).build()); + .desc("name of a file that will contain the output model for the editor, " + + "will output model to standard output if not specified " + + "or suppressed with \"-nm\" flag") + .hasArg().argName("OUTPUT_MODEL_FILE").required(false).type(String.class).build()); options.addOption(Option.builder("if").longOpt("ignore-failures") - .desc("true or false, ignore failures of commands in command files and continue executing the " - + "command file") - .hasArg().argName("IGNORE_FAILURES_FLAG").required(false).type(Boolean.class).build()); + .desc("true or false, ignore failures of commands in command files and continue executing the " + + "command file") + .hasArg().argName("IGNORE_FAILURES_FLAG").required(false).type(Boolean.class).build()); options.addOption(Option.builder("wd").longOpt("working-directory") - .desc("the working directory that is the root for the CLI editor and is the root from which to " - + "look for included macro files") - .hasArg().argName("WORKING_DIRECTORY").required(false).type(String.class).build()); + .desc("the working directory that is the root for the CLI editor and is the root from which to " + + "look for included macro files") + .hasArg().argName("WORKING_DIRECTORY").required(false).type(String.class).build()); } /** @@ -90,19 +91,20 @@ public class CLIParameterParser { * @param args The arguments * @return the CLI parameters */ - public CLIParameters parse(final String[] args) { + public CommandLineParameters parse(final String[] args) { CommandLine commandLine = null; try { commandLine = new DefaultParser().parse(options, args); } catch (final ParseException e) { - throw new CLIException("invalid command line arguments specified : " + e.getMessage()); + throw new CommandLineException("invalid command line arguments specified : " + e.getMessage()); } - final CLIParameters parameters = new CLIParameters(); + final CommandLineParameters parameters = new CommandLineParameters(); final String[] remainingArgs = commandLine.getArgs(); if (remainingArgs.length > 0) { - throw new CLIException("too many command line arguments specified : " + Arrays.toString(remainingArgs)); + throw new CommandLineException( + "too many command line arguments specified : " + Arrays.toString(remainingArgs)); } if (commandLine.hasOption('h')) { diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java index 24356d128..9a03dcfde 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java @@ -35,7 +35,10 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLIParameters { +public class CommandLineParameters { + // Recurring string constants + private static final String OF_TYPE_TAG = "of type "; + // Default location of the command definition meta data in JSON private static final String JSON_COMMAND_METADATA_RESOURCE = "etc/editor/Commands.json"; private static final String APEX_MODEL_PROPERTIES_RESOURCE = "etc/editor/ApexModelProperties.json"; @@ -182,16 +185,16 @@ public class CLIParameters { return; } final File theFile = new File(fileName); - final String prefixExceptionMessage = "File " + fileName + "of type " + fileTag; + final String prefixExceptionMessage = "File " + fileName + OF_TYPE_TAG + fileTag; if (!theFile.exists()) { - throw new CLIException(prefixExceptionMessage + " does not exist"); + throw new CommandLineException(prefixExceptionMessage + " does not exist"); } if (!theFile.isFile()) { - throw new CLIException(prefixExceptionMessage + " is not a normal file"); + throw new CommandLineException(prefixExceptionMessage + " is not a normal file"); } if (!theFile.canRead()) { - throw new CLIException(prefixExceptionMessage + " is ureadable"); + throw new CommandLineException(prefixExceptionMessage + " is ureadable"); } } @@ -206,19 +209,19 @@ public class CLIParameters { return; } final File theFile = new File(fileName); - final String prefixExceptionMessage = "File " + fileName + "of type " + fileTag; + final String prefixExceptionMessage = "File " + fileName + OF_TYPE_TAG + fileTag; if (theFile.exists()) { if (!theFile.isFile()) { - throw new CLIException(prefixExceptionMessage + " is not a normal file"); + throw new CommandLineException(prefixExceptionMessage + " is not a normal file"); } if (!theFile.canWrite()) { - throw new CLIException(prefixExceptionMessage + " cannot be written"); + throw new CommandLineException(prefixExceptionMessage + " cannot be written"); } } else { try { theFile.createNewFile(); } catch (final IOException e) { - throw new CLIException(prefixExceptionMessage + " cannot be created: ", e); + throw new CommandLineException(prefixExceptionMessage + " cannot be created: ", e); } } } @@ -234,14 +237,14 @@ public class CLIParameters { return; } final File theDirectory = new File(directoryName); - final String prefixExceptionMessage = "directory " + directoryName + "of type " + directoryTag; + final String prefixExceptionMessage = "directory " + directoryName + OF_TYPE_TAG + directoryTag; if (theDirectory.exists()) { if (!theDirectory.isDirectory()) { - throw new CLIException(prefixExceptionMessage + " is not a directory"); + throw new CommandLineException(prefixExceptionMessage + " is not a directory"); } if (!theDirectory.canWrite()) { - throw new CLIException(prefixExceptionMessage + " cannot be written"); + throw new CommandLineException(prefixExceptionMessage + " cannot be written"); } } } diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java index 70c2f834b..aa74f4ba3 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java @@ -28,7 +28,7 @@ import java.util.List; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CLILineParser { +public class CommandLineParser { /** * This method breaks a line of input up into commands, parameters, and arguments. Commands are @@ -93,7 +93,7 @@ public class CLILineParser { if (quotedWordToString.matches("^\".*\"$")) { wordsWithQuotesMerged.add(quotedWordToString); } else { - throw new CLIException("trailing quote found in input " + wordsSplitOnQuotes); + throw new CommandLineException("trailing quote found in input " + wordsSplitOnQuotes); } } else { wordsWithQuotesMerged.add(wordsSplitOnQuotes.get(i++)); @@ -281,7 +281,7 @@ public class CLILineParser { // The first word must be alphanumeric, that is a command if (!commandWords.get(0).matches("^[a-zA-Z0-9]*$")) { - throw new CLIException( + throw new CommandLineException( "first command word is not alphanumeric or is not a command: " + commandWords.get(0)); } @@ -303,7 +303,7 @@ public class CLILineParser { if (commandWords.get(currentWordPos).matches("^[a-zA-Z0-9]+=[a-zA-Z0-9/\"].*$")) { currentWordPos++; } else { - throw new CLIException( + throw new CommandLineException( "command argument is not properly formed: " + commandWords.get(currentWordPos)); } } else { @@ -312,7 +312,7 @@ public class CLILineParser { commandWords.set(currentWordPos, commandWords.get(currentWordPos) + logicBlock); currentWordPos++; } else { - throw new CLIException( + throw new CommandLineException( "command argument is not properly formed: " + commandWords.get(currentWordPos)); } } diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java index 6be5c6846..c8bc7a083 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java @@ -37,7 +37,7 @@ import org.onap.policy.apex.model.utilities.Assertions; public class KeywordNode implements Comparable<KeywordNode> { private final String keyword; private final TreeMap<String, KeywordNode> children; - private CLICommand command; + private CommandLineCommand command; /** * This Constructor creates a keyword node with the given keyword and no command. @@ -54,7 +54,7 @@ public class KeywordNode implements Comparable<KeywordNode> { * @param keyword the keyword of the keyword node * @param command the command associated with this keyword */ - public KeywordNode(final String keyword, final CLICommand command) { + public KeywordNode(final String keyword, final CommandLineCommand command) { Assertions.argumentNotNull(keyword, "commands may not be null"); this.keyword = keyword; @@ -70,7 +70,7 @@ public class KeywordNode implements Comparable<KeywordNode> { * @param keywordList the list of keywords to process on this keyword node * @param incomingCommand the command */ - public void processKeywords(final List<String> keywordList, final CLICommand incomingCommand) { + public void processKeywords(final List<String> keywordList, final CommandLineCommand incomingCommand) { if (keywordList.isEmpty()) { this.command = incomingCommand; return; @@ -128,7 +128,7 @@ public class KeywordNode implements Comparable<KeywordNode> { * * @return the command of this keyword node */ - public CLICommand getCommand() { + public CommandLineCommand getCommand() { return command; } @@ -147,8 +147,8 @@ public class KeywordNode implements Comparable<KeywordNode> { * * @return the commands */ - public Set<CLICommand> getCommands() { - final Set<CLICommand> commandSet = new TreeSet<>(); + public Set<CommandLineCommand> getCommands() { + final Set<CommandLineCommand> commandSet = new TreeSet<>(); for (final KeywordNode child : children.values()) { if (child.getCommand() != null) { diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorEventsContext.java index bd75ddf76..b0d82b6fa 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorEventsContext.java @@ -36,7 +36,7 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; /** * The Class TestCLIEditorEventsContext. */ -public class TestCLIEditorEventsContext { +public class TestCommandLineEditorEventsContext { // CHECKSTYLE:OFF: MagicNumber private static final Path SRC_MAIN_FOLDER = Paths.get("src/main/resources/"); @@ -54,7 +54,6 @@ public class TestCLIEditorEventsContext { private static final String JSON_FILE = FILE_NAME + ".json"; private static final String LOG_FILE = FILE_NAME + ".log"; - @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -70,10 +69,11 @@ public class TestCLIEditorEventsContext { final File tempLogFile = temporaryFolder.newFile(LOG_FILE); final File tempModelFile = temporaryFolder.newFile(JSON_FILE); - final String[] cliArgs = new String[] {"-c", APEX_JAVA_POLICY_FILE.toString(), "-l", - tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()}; + final String[] cliArgs = new String[] + { "-c", APEX_JAVA_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o", + tempModelFile.getAbsolutePath() }; - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Get the model and log into strings @@ -100,10 +100,11 @@ public class TestCLIEditorEventsContext { final File tempLogFile = temporaryFolder.newFile(LOG_FILE); final File tempModelFile = temporaryFolder.newFile(JSON_FILE); - final String[] cliArgs = new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", - tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()}; + final String[] cliArgs = new String[] + { "-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o", + tempModelFile.getAbsolutePath() }; - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Get the model and log into strings @@ -126,14 +127,14 @@ public class TestCLIEditorEventsContext { final File tempModelFile = temporaryFolder.newFile(JSON_FILE); final String modelFile = SRC_TEST_FOLDER.resolve("model").resolve("empty_commands.json").toString(); - final String apexPropertiesLocation = - SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString(); + final String apexPropertiesLocation = SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json") + .toString(); - final String[] cliArgs = - new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o", - tempModelFile.getAbsolutePath(), "-m", modelFile, "-a", apexPropertiesLocation}; + final String[] cliArgs = new String[] + { "-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o", + tempModelFile.getAbsolutePath(), "-m", modelFile, "-a", apexPropertiesLocation }; - final ApexCLIEditorMain objUnderTest = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain objUnderTest = new ApexCommandLineEditorMain(cliArgs); assertEquals(1, objUnderTest.getErrorCount()); } @@ -146,14 +147,23 @@ public class TestCLIEditorEventsContext { final File modelFile = temporaryFolder.newFile("empty_commands.json"); - final String apexPropertiesLocation = - SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString(); - - final String[] cliArgs = new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", - tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-m", modelFile.getAbsolutePath(), - "-a", apexPropertiesLocation}; - - final ApexCLIEditorMain objUnderTest = new ApexCLIEditorMain(cliArgs); + final String apexPropertiesLocation = SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json") + .toString(); + + final String[] cliArgs = new String[] { + "-c", + APEX_AVRO_POLICY_FILE.toString(), + "-l", + tempLogFile.getAbsolutePath(), + "-o", + tempModelFile.getAbsolutePath(), + "-m", + modelFile.getAbsolutePath(), + "-a", + apexPropertiesLocation + }; + + final ApexCommandLineEditorMain objUnderTest = new ApexCommandLineEditorMain(cliArgs); assertEquals(1, objUnderTest.getErrorCount()); } diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorOptions.java index 2056c9239..5ff87c01b 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorOptions.java @@ -38,7 +38,7 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestCLIEditorOptions { +public class TestCommandLineEditorOptions { // CHECKSTYLE:OFF: MagicNumber /** @@ -55,7 +55,7 @@ public class TestCLIEditorOptions { final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l", tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()}; - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Get the model and log into strings @@ -87,7 +87,7 @@ public class TestCLIEditorOptions { final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l", tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-nl", "-nm"}; - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Get the model and log into strings @@ -119,7 +119,7 @@ public class TestCLIEditorOptions { final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l", tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-nm"}; - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Get the model and log into strings @@ -152,7 +152,7 @@ public class TestCLIEditorOptions { final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l", tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-nl"}; - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Get the model and log into strings @@ -184,7 +184,7 @@ public class TestCLIEditorOptions { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); System.setOut(new PrintStream(baos)); - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Cursor for log @@ -208,7 +208,7 @@ public class TestCLIEditorOptions { final PrintStream stdout = System.out; System.setOut(new PrintStream(baos)); - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs); assertEquals(0, cliEditor.getErrorCount()); // Cursor for log @@ -237,7 +237,7 @@ public class TestCLIEditorOptions { final String[] cliArgsIn = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l", tempLogFileIn.getAbsolutePath(), "-o", tempModelFileIn.getAbsolutePath()}; - final ApexCLIEditorMain cliEditorIn = new ApexCLIEditorMain(cliArgsIn); + final ApexCommandLineEditorMain cliEditorIn = new ApexCommandLineEditorMain(cliArgsIn); assertEquals(0, cliEditorIn.getErrorCount()); // Get the model and log into strings @@ -255,7 +255,7 @@ public class TestCLIEditorOptions { "src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex", "-l", tempLogFileOut.getAbsolutePath(), "-o", tempModelFileOut.getAbsolutePath()}; - final ApexCLIEditorMain cliEditorOut = new ApexCLIEditorMain(cliArgsOut); + final ApexCommandLineEditorMain cliEditorOut = new ApexCommandLineEditorMain(cliArgsOut); assertEquals(0, cliEditorOut.getErrorCount()); // Get the model and log into strings diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorScripting.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorScripting.java index 44cc5c702..1b49fb362 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorScripting.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorScripting.java @@ -41,14 +41,14 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestCLIEditorScripting { +public class TestCommandLineEditorScripting { private File tempModelFile; private File tempLogFile; - private String[] sampleLBPolicyArgs; + private String[] samplePolicyArgs; - private String[] sampleLBPolicyMapArgs; + private String[] samplePolicyMapArgs; /** * Initialise args. @@ -60,10 +60,10 @@ public class TestCLIEditorScripting { tempModelFile = File.createTempFile("SampleLBPolicyMap", ".json"); tempLogFile = File.createTempFile("SampleLBPolicyMap", ".log"); - sampleLBPolicyArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy.apex", "-o", + samplePolicyArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy.apex", "-o", tempModelFile.getAbsolutePath(), "-l", tempLogFile.getAbsolutePath()}; - sampleLBPolicyMapArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy_WithMap.apex", "-o", + samplePolicyMapArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy_WithMap.apex", "-o", tempModelFile.getAbsolutePath(), "-l", tempLogFile.getAbsolutePath()}; } @@ -83,19 +83,19 @@ public class TestCLIEditorScripting { * @throws ApexModelException if there is an Apex error */ @Test - public void testSampleLBPolicyScript() throws IOException, ApexModelException { - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(sampleLBPolicyArgs); + public void testSamplePolicyScript() throws IOException, ApexModelException { + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(samplePolicyArgs); assertEquals(0, cliEditor.getErrorCount()); // Read the file from disk final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); - final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); - final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream()); + final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); + final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream()); - final URL compareModelURL = + final URL compareModelUrl = ResourceUtils.getLocalFile("src/test/resources/compare/FuzzyPolicyModel_Compare.json"); - final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream()); + final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream()); // Ignore key info UUIDs writtenModel.getKeyInformation().getKeyInfoMap().clear(); @@ -111,10 +111,10 @@ public class TestCLIEditorScripting { * @throws ApexModelException if there is an Apex error */ @Test - public void testSampleLBMapPolicyScript() throws IOException, ApexModelException { + public void testSampleMapPolicyScript() throws IOException, ApexModelException { tempModelFile.delete(); - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(sampleLBPolicyMapArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(samplePolicyMapArgs); assertEquals(0, cliEditor.getErrorCount()); assertTrue(tempModelFile.isFile()); @@ -122,8 +122,8 @@ public class TestCLIEditorScripting { // Read the file from disk final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); - final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); - final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream()); + final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); + final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream()); final AxValidationResult validationResult = new AxValidationResult(); writtenModel.validate(validationResult); diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java index 1b99fce16..a45212007 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java @@ -36,11 +36,19 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.common.utils.resources.ResourceUtils; +/** + * The Class TestContextAlbums. + */ public class TestContextAlbums { private String[] logicBlockArgs; private File tempModelFile; + /** + * Creates the temp files. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void createTempFiles() throws IOException { tempModelFile = File.createTempFile("TestPolicyModel", ".json"); @@ -65,20 +73,20 @@ public class TestContextAlbums { */ @Test public void testLogicBlock() throws IOException, ApexModelException { - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(logicBlockArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(logicBlockArgs); assertEquals(1, cliEditor.getErrorCount()); // Read the file from disk final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); modelReader.setValidateFlag(false); - final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); - final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream()); + final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); + final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream()); assertNotNull(writtenModel); - final URL compareModelURL = + final URL compareModelUrl = ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json"); - final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream()); + final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream()); // Ignore key info UUIDs writtenModel.getKeyInformation().getKeyInfoMap().clear(); diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java index eb2f2a46b..3195bf025 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java @@ -46,6 +46,11 @@ public class TestFileMacro { private File tempModelFile; private File tempLogFile; + /** + * Creates the temp files. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void createTempFiles() throws IOException { tempModelFile = File.createTempFile("TestPolicyModel", ".json"); @@ -55,6 +60,9 @@ public class TestFileMacro { tempLogFile.getCanonicalPath(), "-o", tempModelFile.getCanonicalPath(), "-if", "true"}; } + /** + * Removes the generated models. + */ @After public void removeGeneratedModels() { tempModelFile.delete(); @@ -68,7 +76,7 @@ public class TestFileMacro { */ @Test public void testLogicBlock() throws IOException, ApexModelException { - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(fileMacroArgs); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(fileMacroArgs); // We expect eight errors assertEquals(8, cliEditor.getErrorCount()); @@ -76,12 +84,12 @@ public class TestFileMacro { final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); modelReader.setValidateFlag(false); - final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); - final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream()); + final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath()); + final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream()); - final URL compareModelURL = + final URL compareModelUrl = ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json"); - final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream()); + final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream()); // Ignore key info UUIDs writtenModel.getKeyInformation().getKeyInfoMap().clear(); diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java index 591acb29a..1a4f75576 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java @@ -34,6 +34,10 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.common.utils.resources.ResourceUtils; +// TODO: Auto-generated Javadoc +/** + * The Class TestLogicBlock. + */ public class TestLogicBlock { private String[] logicBlockArgs; private String[] avroSchemaArgs; @@ -41,6 +45,11 @@ public class TestLogicBlock { private File tempLogicModelFile; private File tempAvroModelFile; + /** + * Creates the temp files. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void createTempFiles() throws IOException { tempLogicModelFile = File.createTempFile("TestLogicPolicyModel", ".json"); @@ -53,6 +62,9 @@ public class TestLogicBlock { tempAvroModelFile.getCanonicalPath(), "-nl"}; } + /** + * Removes the temp files. + */ @After public void removeTempFiles() { tempLogicModelFile.delete(); @@ -67,18 +79,18 @@ public class TestLogicBlock { */ @Test public void testLogicBlock() throws IOException, ApexModelException { - new ApexCLIEditorMain(logicBlockArgs); + new ApexCommandLineEditorMain(logicBlockArgs); // Read the file from disk final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); modelReader.setValidateFlag(false); - final URL writtenModelURL = ResourceUtils.getLocalFile(tempLogicModelFile.getCanonicalPath()); - final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream()); + final URL writtenModelUrl = ResourceUtils.getLocalFile(tempLogicModelFile.getCanonicalPath()); + final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream()); - final URL compareModelURL = + final URL compareModelUrl = ResourceUtils.getLocalFile("src/test/resources/compare/LogicBlockModel_Compare.json"); - final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream()); + final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream()); // Ignore key info UUIDs writtenModel.getKeyInformation().getKeyInfoMap().clear(); @@ -95,18 +107,18 @@ public class TestLogicBlock { */ @Test public void testAvroSchema() throws IOException, ApexModelException { - new ApexCLIEditorMain(avroSchemaArgs); + new ApexCommandLineEditorMain(avroSchemaArgs); // Read the file from disk final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); modelReader.setValidateFlag(false); - final URL writtenModelURL = ResourceUtils.getLocalFile(tempAvroModelFile.getCanonicalPath()); - final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream()); + final URL writtenModelUrl = ResourceUtils.getLocalFile(tempAvroModelFile.getCanonicalPath()); + final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream()); - final URL compareModelURL = + final URL compareModelUrl = ResourceUtils.getLocalFile("src/test/resources/compare/AvroSchemaModel_Compare.json"); - final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream()); + final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream()); // Ignore key info UUIDs writtenModel.getKeyInformation().getKeyInfoMap().clear(); diff --git a/client/client-deployment/pom.xml b/client/client-deployment/pom.xml index aacf34a02..b3814db74 100644 --- a/client/client-deployment/pom.xml +++ b/client/client-deployment/pom.xml @@ -96,7 +96,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>3.1.0</version> <executions> <execution> <id>copy-common-resources-to-jar</id> @@ -137,7 +136,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> - <version>2.4.3</version> <executions> <execution> <phase>package</phase> @@ -186,7 +184,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> - <version>2.6</version> <configuration> <classifier>ui</classifier> <warSourceDirectory>src/main/resources/webapp</warSourceDirectory> diff --git a/client/client-editor/pom.xml b/client/client-editor/pom.xml index 3e250e0f4..9b4d53fab 100644 --- a/client/client-editor/pom.xml +++ b/client/client-editor/pom.xml @@ -122,7 +122,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>3.1.0</version> <executions> <execution> <id>copy-common-resources-to-jar</id> @@ -163,7 +162,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> - <version>2.4.3</version> <executions> <execution> <phase>package</phase> @@ -212,7 +210,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> - <version>2.6</version> <configuration> <classifier>ui</classifier> <warSourceDirectory>src/main/resources/webapp</warSourceDirectory> diff --git a/client/client-full/pom.xml b/client/client-full/pom.xml index 788bb1534..e2605766e 100644 --- a/client/client-full/pom.xml +++ b/client/client-full/pom.xml @@ -109,7 +109,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> - <version>2.4.3</version> <executions> <execution> <phase>package</phase> @@ -158,7 +157,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> - <version>2.6</version> <configuration> <classifier>ui</classifier> <warSourceDirectory>target/classes/webapp</warSourceDirectory> diff --git a/client/client-monitoring/pom.xml b/client/client-monitoring/pom.xml index 274ac23f3..225c7e65b 100644 --- a/client/client-monitoring/pom.xml +++ b/client/client-monitoring/pom.xml @@ -91,7 +91,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>3.1.0</version> <executions> <execution> <id>copy-common-resources-to-jar</id> @@ -132,7 +131,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> - <version>2.4.3</version> <executions> <execution> <phase>package</phase> @@ -181,7 +179,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> - <version>2.6</version> <configuration> <classifier>ui</classifier> <warSourceDirectory>src/main/resources/webapp</warSourceDirectory> diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/AbstractDistributor.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/AbstractDistributor.java index 042b2c22a..56368aeb4 100644 --- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/AbstractDistributor.java +++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/AbstractDistributor.java @@ -108,7 +108,7 @@ public abstract class AbstractDistributor implements Distributor { } /** - * Set the static lock manager + * Set the static lock manager. * @param incomingLockManager the lock manager value */ private static void setLockManager(final LockManager incomingLockManager) { @@ -116,7 +116,7 @@ public abstract class AbstractDistributor implements Distributor { } /** - * Set the static flush timer + * Set the static flush timer. * @param incomingFlushTimer the flush timer value */ private static void setFlushTimer(final DistributorFlushTimerTask incomingFlushTimer) { diff --git a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java index 290f22794..a659326a0 100644 --- a/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java +++ b/context/context-test-utils/src/test/java/org/onap/policy/apex/context/test/persistence/TestPersistentContextInstantiation.java @@ -126,9 +126,11 @@ public class TestPersistentContextInstantiation { final AxArtifactKey distributorKey = new AxArtifactKey("AbstractDistributor", "0.0.1"); final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey); - final AxArtifactKey[] usedArtifactStackArray = - { new AxArtifactKey("testC-top", "0.0.1"), new AxArtifactKey("testC-next", "0.0.1"), - new AxArtifactKey("testC-bot", "0.0.1") }; + final AxArtifactKey[] usedArtifactStackArray = { + new AxArtifactKey("testC-top", "0.0.1"), + new AxArtifactKey("testC-next", "0.0.1"), + new AxArtifactKey("testC-bot", "0.0.1") + }; final DaoParameters DaoParameters = new DaoParameters(); DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); diff --git a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/ApexDeploymentException.java b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/ApexDeploymentException.java index e932bbd45..5944b9f0d 100644 --- a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/ApexDeploymentException.java +++ b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/ApexDeploymentException.java @@ -43,9 +43,9 @@ public class ApexDeploymentException extends ApexException { * Instantiates a new apex deployment exception. * * @param message the message - * @param e the e + * @param exception the e */ - public ApexDeploymentException(final String message, final Exception e) { - super(message, e); + public ApexDeploymentException(final String message, final Exception exception) { + super(message, exception); } } diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingException.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingException.java index ef435b2a5..dfaf4629f 100644 --- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingException.java +++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/MessagingException.java @@ -41,9 +41,9 @@ public class MessagingException extends Exception { * Instantiates a new messaging exception. * * @param message the message - * @param e the e + * @param exception the e */ - public MessagingException(final String message, final Exception e) { - super(message, e); + public MessagingException(final String message, final Exception exception) { + super(message, exception); } } diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java index 45579c7ba..0d5f30737 100644 --- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java +++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java @@ -78,12 +78,12 @@ public class ApplicationThreadFactory implements ThreadFactory { * @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable) */ @Override - public Thread newThread(final Runnable r) { + public Thread newThread(final Runnable runnable) { final Thread thisThread; if (stackSize > 0) { - thisThread = new Thread(group, r, name + ':' + nextThreadNumber.getAndIncrement(), stackSize); + thisThread = new Thread(group, runnable, name + ':' + nextThreadNumber.getAndIncrement(), stackSize); } else { - thisThread = new Thread(group, r, name + ':' + nextThreadNumber.getAndIncrement()); + thisThread = new Thread(group, runnable, name + ':' + nextThreadNumber.getAndIncrement()); } if (thisThread.isDaemon()) { thisThread.setDaemon(false); diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java index f677e6b4a..bd2474339 100644 --- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java +++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java @@ -45,7 +45,7 @@ public class XPathReader { private String xmlFileName = null; private InputStream xmlStream = null; private Document xmlDocument; - private XPath xPath; + private XPath xpath; /** * Construct Reader for the file passed in. @@ -89,7 +89,7 @@ public class XPathReader { return; } - xPath = XPathFactory.newInstance().newXPath(); + xpath = XPathFactory.newInstance().newXPath(); LOGGER.info("Initialized XPath reader"); } catch (final Exception ex) { LOGGER.error("Error parsing XML file/stream from XPath reading, reason :\n" + ex.getMessage()); @@ -105,7 +105,7 @@ public class XPathReader { */ public Object read(final String expression, final QName returnType) { try { - final XPathExpression xPathExpression = xPath.compile(expression); + final XPathExpression xPathExpression = xpath.compile(expression); return xPathExpression.evaluate(xmlDocument, returnType); } catch (final XPathExpressionException ex) { LOGGER.error("Failed to read XML file for XPath processing, reason:\n" + ex.getMessage()); diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java index 62a2e0a75..00d8055be 100644 --- a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java +++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java @@ -29,7 +29,7 @@ package org.onap.policy.apex.core.protocols; public interface Action { /** - * This method returns a string representation of each action. + * Return a string representation of each action. * * @return the action string */ diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java index 73465cef6..95f786cad 100644 --- a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java +++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java @@ -146,15 +146,15 @@ public abstract class Message implements Serializable { * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(final Object o) { - if (this == o) { + public boolean equals(final Object object) { + if (this == object) { return true; } - if (o == null || getClass() != o.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - final Message message = (Message) o; + final Message message = (Message) object; if (action != null ? !action.equals(message.action) : message.action != null) { return false; diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java index 69e36baed..530e1aba7 100644 --- a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java +++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java @@ -99,18 +99,18 @@ public class Response extends Message { * @see org.onap.policy.apex.core.protocols.Message#equals(java.lang.Object) */ @Override - public boolean equals(final Object o) { - if (this == o) { + public boolean equals(final Object object) { + if (this == object) { return true; } - if (o == null || getClass() != o.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - if (!super.equals(o)) { + if (!super.equals(object)) { return false; } - final Response response = (Response) o; + final Response response = (Response) object; if (successful != response.successful) { return false; diff --git a/examples/examples-aadm/pom.xml b/examples/examples-aadm/pom.xml index 272aee8fd..0dd91dcde 100644 --- a/examples/examples-aadm/pom.xml +++ b/examples/examples-aadm/pom.xml @@ -80,7 +80,7 @@ <argument>-classpath</argument> <!-- automatically creates the classpath using all project dependencies, also adding the project build directory --> <classpath /> - <argument>org.onap.policy.apex.examples.aadm.model.AADMDomainModelSaver</argument> + <argument>org.onap.policy.apex.examples.aadm.model.AadmDomainModelSaver</argument> <argument>${project.build.directory}/classes/examples/models/AADM</argument> </arguments> </configuration> diff --git a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/ENodeBStatus.java b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/ENodeBStatus.java index 1f3cf5185..70af74ab9 100644 --- a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/ENodeBStatus.java +++ b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/ENodeBStatus.java @@ -56,7 +56,7 @@ public class ENodeBStatus implements Serializable { * * @return the number of Denial Of Service incidents on the eNodeB */ - public long getDOSCount() { + public long getDosCount() { return dosCount; } @@ -65,7 +65,7 @@ public class ENodeBStatus implements Serializable { * * @param incomingDosCount the number of Denial Of Service incidents on the eNodeB */ - public void setDOSCount(final long incomingDosCount) { + public void setDosCount(final long incomingDosCount) { this.dosCount = incomingDosCount; } @@ -74,7 +74,7 @@ public class ENodeBStatus implements Serializable { * * @return the long */ - public long incrementDOSCount() { + public long incrementDosCount() { return ++dosCount; } @@ -83,7 +83,7 @@ public class ENodeBStatus implements Serializable { * * @return the long */ - public long decrementDOSCount() { + public long decrementDosCount() { return --dosCount; } diff --git a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/IMSIStatus.java b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/ImsiStatus.java index 8f89d4c15..4b7def097 100644 --- a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/IMSIStatus.java +++ b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/ImsiStatus.java @@ -25,7 +25,7 @@ import java.io.Serializable; /** * The Class IMSIStatus holds the status of an IMSI in the AADM domain. */ -public class IMSIStatus implements Serializable { +public class ImsiStatus implements Serializable { private static final long serialVersionUID = 2852523814242234172L; private static final long TIME_NOT_SET = 0; @@ -43,7 +43,7 @@ public class IMSIStatus implements Serializable { * * @param imsi the IMSI value */ - public IMSIStatus(final String imsi) { + public ImsiStatus(final String imsi) { this.imsi = imsi; } @@ -52,7 +52,7 @@ public class IMSIStatus implements Serializable { * * @return the IMSI value */ - public String getIMSI() { + public String getImsi() { return imsi; } @@ -97,17 +97,17 @@ public class IMSIStatus implements Serializable { * * @return theeNodeB ID to which the IMSI is attached */ - public String getENodeBID() { + public String getENodeBId() { return enodeBId; } /** * Sets the eNodeB ID to which the IMSI is attached. * - * @param incomingENodeBID the eNodeB ID to which the IMSI is attached + * @param incomingENodeBId the eNodeB ID to which the IMSI is attached */ - public void setENodeBID(final String incomingENodeBID) { - this.enodeBId = incomingENodeBID; + public void setENodeBId(final String incomingENodeBId) { + this.enodeBId = incomingENodeBId; } /** @@ -115,7 +115,7 @@ public class IMSIStatus implements Serializable { * * @return true, if eNodeB ID to which the IMSI is attached is set */ - public boolean checkSetENodeBID() { + public boolean checkSetENodeBId() { return (enodeBId != null); } diff --git a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/IPAddressStatus.java b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/IpAddressStatus.java index fc3780f17..689865b16 100644 --- a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/IPAddressStatus.java +++ b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/concepts/IpAddressStatus.java @@ -25,7 +25,7 @@ import java.io.Serializable; /** * The Class IPAddressStatus holds the status of an IP address in the AADM domain. */ -public class IPAddressStatus implements Serializable { +public class IpAddressStatus implements Serializable { private static final long serialVersionUID = -7402022458317593252L; private final String ipAddress; @@ -37,7 +37,7 @@ public class IPAddressStatus implements Serializable { * * @param ipAddress the ip address */ - public IPAddressStatus(final String ipAddress) { + public IpAddressStatus(final String ipAddress) { this.ipAddress = ipAddress; } @@ -46,7 +46,7 @@ public class IPAddressStatus implements Serializable { * * @return the IP address */ - public String getIPAddress() { + public String getIpAddress() { return ipAddress; } @@ -55,7 +55,7 @@ public class IPAddressStatus implements Serializable { * * @return the imsi */ - public String getIMSI() { + public String getImsi() { return imsi; } @@ -64,7 +64,7 @@ public class IPAddressStatus implements Serializable { * * @param incomingImsi the imsi */ - public void setIMSI(final String incomingImsi) { + public void setImsi(final String incomingImsi) { this.imsi = incomingImsi; } @@ -73,7 +73,7 @@ public class IPAddressStatus implements Serializable { * * @return true, if check set IMSI */ - public boolean checkSetIMSI() { + public boolean checkSetImsi() { return (imsi != null); } } diff --git a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AADMDomainModelFactory.java b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelFactory.java index 9a2d50626..376643211 100644 --- a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AADMDomainModelFactory.java +++ b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelFactory.java @@ -49,20 +49,20 @@ import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader; /** * The Class AADMDomainModelFactory. */ -public class AADMDomainModelFactory { +public class AadmDomainModelFactory { /** * Gets the AADM policy model. * * @return the AADM policy model */ // CHECKSTYLE:OFF: checkstyle - public AxPolicyModel getAADMPolicyModel() { + public AxPolicyModel getAadmPolicyModel() { // CHECKSTYLE:ON: checkstyle // Data types for event parameters final AxContextSchema imsi = new AxContextSchema(new AxArtifactKey("IMSI", "0.0.1"), "Java", "java.lang.Long"); - final AxContextSchema ueIPAddress = + final AxContextSchema ueIpAddress = new AxContextSchema(new AxArtifactKey("UEIPAddress", "0.0.1"), "Java", "java.lang.String"); - final AxContextSchema nwIPAddress = + final AxContextSchema nwIpAddress = new AxContextSchema(new AxArtifactKey("NWIPAddress", "0.0.1"), "Java", "java.lang.String"); final AxContextSchema dosFlag = new AxContextSchema(new AxArtifactKey("DOSFlag", "0.0.1"), "Java", "java.lang.Boolean"); @@ -72,7 +72,7 @@ public class AADMDomainModelFactory { new AxContextSchema(new AxArtifactKey("ApplicationName", "0.0.1"), "Java", "java.lang.String"); final AxContextSchema protocolGroup = new AxContextSchema(new AxArtifactKey("ProtocolGroup", "0.0.1"), "Java", "java.lang.String"); - final AxContextSchema eNodeBID = + final AxContextSchema eNodeBId = new AxContextSchema(new AxArtifactKey("ENodeBID", "0.0.1"), "Java", "java.lang.Long"); final AxContextSchema httpHostClass = new AxContextSchema(new AxArtifactKey("HttpHostClass", "0.0.1"), "Java", "java.lang.String"); @@ -113,13 +113,13 @@ public class AADMDomainModelFactory { final AxContextSchemas aadmContextSchemas = new AxContextSchemas(new AxArtifactKey("AADMDatatypes", "0.0.1")); aadmContextSchemas.getSchemasMap().put(imsi.getKey(), imsi); - aadmContextSchemas.getSchemasMap().put(ueIPAddress.getKey(), ueIPAddress); - aadmContextSchemas.getSchemasMap().put(nwIPAddress.getKey(), nwIPAddress); + aadmContextSchemas.getSchemasMap().put(ueIpAddress.getKey(), ueIpAddress); + aadmContextSchemas.getSchemasMap().put(nwIpAddress.getKey(), nwIpAddress); aadmContextSchemas.getSchemasMap().put(dosFlag.getKey(), dosFlag); aadmContextSchemas.getSchemasMap().put(roundTripTime.getKey(), roundTripTime); aadmContextSchemas.getSchemasMap().put(applicationName.getKey(), applicationName); aadmContextSchemas.getSchemasMap().put(protocolGroup.getKey(), protocolGroup); - aadmContextSchemas.getSchemasMap().put(eNodeBID.getKey(), eNodeBID); + aadmContextSchemas.getSchemasMap().put(eNodeBId.getKey(), eNodeBId); aadmContextSchemas.getSchemasMap().put(httpHostClass.getKey(), httpHostClass); aadmContextSchemas.getSchemasMap().put(tcpOnFlag.getKey(), tcpOnFlag); aadmContextSchemas.getSchemasMap().put(probeOnFlag.getKey(), probeOnFlag); @@ -146,11 +146,11 @@ public class AADMDomainModelFactory { aadmEvent.getParameterMap().put("IMSI", new AxField(new AxReferenceKey(aadmEvent.getKey(), "IMSI"), imsi.getKey())); aadmEvent.getParameterMap().put("ENODEB_ID", - new AxField(new AxReferenceKey(aadmEvent.getKey(), "ENODEB_ID"), eNodeBID.getKey())); + new AxField(new AxReferenceKey(aadmEvent.getKey(), "ENODEB_ID"), eNodeBId.getKey())); aadmEvent.getParameterMap().put("IMSI_IP", - new AxField(new AxReferenceKey(aadmEvent.getKey(), "IMSI_IP"), ueIPAddress.getKey())); + new AxField(new AxReferenceKey(aadmEvent.getKey(), "IMSI_IP"), ueIpAddress.getKey())); aadmEvent.getParameterMap().put("NW_IP", - new AxField(new AxReferenceKey(aadmEvent.getKey(), "NW_IP"), nwIPAddress.getKey())); + new AxField(new AxReferenceKey(aadmEvent.getKey(), "NW_IP"), nwIpAddress.getKey())); aadmEvent.getParameterMap().put("DoS", new AxField(new AxReferenceKey(aadmEvent.getKey(), "DoS"), dosFlag.getKey())); aadmEvent.getParameterMap().put("TCP_UE_SIDE_MEDIAN_RTT_TX_TO_RX", new AxField( @@ -168,9 +168,9 @@ public class AADMDomainModelFactory { aadmEvent.getParameterMap().put("TCP_ON", new AxField(new AxReferenceKey(aadmEvent.getKey(), "TCP_ON"), tcpOnFlag.getKey())); aadmEvent.getParameterMap().put("SGW_IP_ADDRESS", - new AxField(new AxReferenceKey(aadmEvent.getKey(), "SGW_IP_ADDRESS"), nwIPAddress.getKey())); + new AxField(new AxReferenceKey(aadmEvent.getKey(), "SGW_IP_ADDRESS"), nwIpAddress.getKey())); aadmEvent.getParameterMap().put("UE_IP_ADDRESS", - new AxField(new AxReferenceKey(aadmEvent.getKey(), "UE_IP_ADDRESS"), ueIPAddress.getKey())); + new AxField(new AxReferenceKey(aadmEvent.getKey(), "UE_IP_ADDRESS"), ueIpAddress.getKey())); aadmEvent.getParameterMap().put("SERVICE_REQUEST_COUNT", new AxField( new AxReferenceKey(aadmEvent.getKey(), "SERVICE_REQUEST_COUNT"), serviceRequestCount.getKey())); aadmEvent.getParameterMap().put("ATTACH_COUNT", @@ -192,11 +192,11 @@ public class AADMDomainModelFactory { aadmXStreamActEvent.getParameterMap().put("IMSI", new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "IMSI"), imsi.getKey())); aadmXStreamActEvent.getParameterMap().put("IMSI_IP", - new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "IMSI_IP"), ueIPAddress.getKey())); + new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "IMSI_IP"), ueIpAddress.getKey())); aadmXStreamActEvent.getParameterMap().put("ENODEB_ID", - new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "ENODEB_ID"), eNodeBID.getKey())); + new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "ENODEB_ID"), eNodeBId.getKey())); aadmXStreamActEvent.getParameterMap().put("NW_IP", - new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "NW_IP"), nwIPAddress.getKey())); + new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "NW_IP"), nwIpAddress.getKey())); aadmXStreamActEvent.getParameterMap().put("ACTTASK", new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "ACTTASK"), actionTask.getKey())); aadmXStreamActEvent.getParameterMap().put("PROBE_ON", @@ -216,22 +216,22 @@ public class AADMDomainModelFactory { aadmXStreamActEvent.getParameterMap().put("THRESHOLD", new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "THRESHOLD"), threshold.getKey())); - final AxEvent vMMEEvent = + final AxEvent vMmeEvent = new AxEvent(new AxArtifactKey("VMMEEvent", "0.0.1"), "org.onap.policy.apex.examples.aadm.events"); - vMMEEvent.setSource("External"); - vMMEEvent.setTarget("Apex"); - vMMEEvent.getParameterMap().put("IMSI", - new AxField(new AxReferenceKey(vMMEEvent.getKey(), "IMSI"), imsi.getKey())); - vMMEEvent.getParameterMap().put("ENODEB_ID", - new AxField(new AxReferenceKey(vMMEEvent.getKey(), "ENODEB_ID"), eNodeBID.getKey())); - vMMEEvent.getParameterMap().put("IMSI_IP", - new AxField(new AxReferenceKey(vMMEEvent.getKey(), "IMSI_IP"), ueIPAddress.getKey())); - vMMEEvent.getParameterMap().put("NW_IP", - new AxField(new AxReferenceKey(vMMEEvent.getKey(), "NW_IP"), nwIPAddress.getKey())); - vMMEEvent.getParameterMap().put("PROFILE", - new AxField(new AxReferenceKey(vMMEEvent.getKey(), "PROFILE"), profile.getKey())); - vMMEEvent.getParameterMap().put("THRESHOLD", - new AxField(new AxReferenceKey(vMMEEvent.getKey(), "THRESHOLD"), threshold.getKey())); + vMmeEvent.setSource("External"); + vMmeEvent.setTarget("Apex"); + vMmeEvent.getParameterMap().put("IMSI", + new AxField(new AxReferenceKey(vMmeEvent.getKey(), "IMSI"), imsi.getKey())); + vMmeEvent.getParameterMap().put("ENODEB_ID", + new AxField(new AxReferenceKey(vMmeEvent.getKey(), "ENODEB_ID"), eNodeBId.getKey())); + vMmeEvent.getParameterMap().put("IMSI_IP", + new AxField(new AxReferenceKey(vMmeEvent.getKey(), "IMSI_IP"), ueIpAddress.getKey())); + vMmeEvent.getParameterMap().put("NW_IP", + new AxField(new AxReferenceKey(vMmeEvent.getKey(), "NW_IP"), nwIpAddress.getKey())); + vMmeEvent.getParameterMap().put("PROFILE", + new AxField(new AxReferenceKey(vMmeEvent.getKey(), "PROFILE"), profile.getKey())); + vMmeEvent.getParameterMap().put("THRESHOLD", + new AxField(new AxReferenceKey(vMmeEvent.getKey(), "THRESHOLD"), threshold.getKey())); final AxEvent sapcEvent = new AxEvent(new AxArtifactKey("SAPCEvent", "0.0.1"), "org.onap.policy.apex.examples.aadm.events"); @@ -240,11 +240,11 @@ public class AADMDomainModelFactory { sapcEvent.getParameterMap().put("IMSI", new AxField(new AxReferenceKey(sapcEvent.getKey(), "IMSI"), imsi.getKey())); sapcEvent.getParameterMap().put("ENODEB_ID", - new AxField(new AxReferenceKey(sapcEvent.getKey(), "ENODEB_ID"), eNodeBID.getKey())); + new AxField(new AxReferenceKey(sapcEvent.getKey(), "ENODEB_ID"), eNodeBId.getKey())); sapcEvent.getParameterMap().put("IMSI_IP", - new AxField(new AxReferenceKey(sapcEvent.getKey(), "IMSI_IP"), ueIPAddress.getKey())); + new AxField(new AxReferenceKey(sapcEvent.getKey(), "IMSI_IP"), ueIpAddress.getKey())); sapcEvent.getParameterMap().put("NW_IP", - new AxField(new AxReferenceKey(sapcEvent.getKey(), "NW_IP"), nwIPAddress.getKey())); + new AxField(new AxReferenceKey(sapcEvent.getKey(), "NW_IP"), nwIpAddress.getKey())); sapcEvent.getParameterMap().put("PROFILE", new AxField(new AxReferenceKey(sapcEvent.getKey(), "PROFILE"), profile.getKey())); sapcEvent.getParameterMap().put("THRESHOLD", @@ -270,9 +270,9 @@ public class AADMDomainModelFactory { sapcBlacklistSubscriberEvent.getParameterMap().put("BLACKLIST_ON", new AxField( new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), "BLACKLIST_ON"), blacklistOnFlag.getKey())); sapcBlacklistSubscriberEvent.getParameterMap().put("IMSI_IP", new AxField( - new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), "IMSI_IP"), ueIPAddress.getKey())); + new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), "IMSI_IP"), ueIpAddress.getKey())); sapcBlacklistSubscriberEvent.getParameterMap().put("NW_IP", - new AxField(new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), "NW_IP"), nwIPAddress.getKey())); + new AxField(new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), "NW_IP"), nwIpAddress.getKey())); sapcBlacklistSubscriberEvent.getParameterMap().put("PROBE_ON", new AxField( new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), "PROBE_ON"), probeOnFlag.getKey())); sapcBlacklistSubscriberEvent.getParameterMap().put("TCP_ON", @@ -296,7 +296,7 @@ public class AADMDomainModelFactory { final AxEvents aadmEvents = new AxEvents(new AxArtifactKey("AADMEvents", "0.0.1")); aadmEvents.getEventMap().put(aadmEvent.getKey(), aadmEvent); aadmEvents.getEventMap().put(aadmXStreamActEvent.getKey(), aadmXStreamActEvent); - aadmEvents.getEventMap().put(vMMEEvent.getKey(), vMMEEvent); + aadmEvents.getEventMap().put(vMmeEvent.getKey(), vMmeEvent); aadmEvents.getEventMap().put(sapcEvent.getKey(), sapcEvent); aadmEvents.getEventMap().put(sapcBlacklistSubscriberEvent.getKey(), sapcBlacklistSubscriberEvent); aadmEvents.getEventMap().put(periodicEvent.getKey(), periodicEvent); @@ -305,9 +305,9 @@ public class AADMDomainModelFactory { final AxContextSchema eNodeBStatus = new AxContextSchema(new AxArtifactKey("ENodeBStatus", "0.0.1"), "Java", "org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus"); final AxContextSchema imsiStatus = new AxContextSchema(new AxArtifactKey("IMSIStatus", "0.0.1"), "Java", - "org.onap.policy.apex.examples.aadm.concepts.IMSIStatus"); + "org.onap.policy.apex.examples.aadm.concepts.ImsiStatus"); final AxContextSchema ipAddressStatus = new AxContextSchema(new AxArtifactKey("IPAddressStatus", "0.0.1"), - "Java", "org.onap.policy.apex.examples.aadm.concepts.IPAddressStatus"); + "Java", "org.onap.policy.apex.examples.aadm.concepts.IpAddressStatus"); aadmContextSchemas.getSchemasMap().put(eNodeBStatus.getKey(), eNodeBStatus); aadmContextSchemas.getSchemasMap().put(imsiStatus.getKey(), imsiStatus); aadmContextSchemas.getSchemasMap().put(ipAddressStatus.getKey(), ipAddressStatus); @@ -371,32 +371,32 @@ public class AADMDomainModelFactory { aadmDoSProvenActTask .setTaskLogic(new AxTaskLogic(aadmDoSProvenActTask.getKey(), "TaskLogic", "MVEL", logicReader)); - final AxTask vMMEMatchTask = new AxTask(new AxArtifactKey("VMMEMatchTask", "0.0.1")); - vMMEMatchTask.duplicateInputFields(vMMEEvent.getParameterMap()); - vMMEMatchTask.duplicateOutputFields(vMMEEvent.getParameterMap()); - vMMEMatchTask.setTaskLogic(new AxTaskLogic(vMMEMatchTask.getKey(), "TaskLogic", "MVEL", logicReader)); + final AxTask vMmeMatchTask = new AxTask(new AxArtifactKey("VMMEMatchTask", "0.0.1")); + vMmeMatchTask.duplicateInputFields(vMmeEvent.getParameterMap()); + vMmeMatchTask.duplicateOutputFields(vMmeEvent.getParameterMap()); + vMmeMatchTask.setTaskLogic(new AxTaskLogic(vMmeMatchTask.getKey(), "TaskLogic", "MVEL", logicReader)); - final AxTask vMMEEstablishTask = new AxTask(new AxArtifactKey("VMMEEstablishTask", "0.0.1")); - vMMEEstablishTask.duplicateInputFields(vMMEEvent.getParameterMap()); - vMMEEstablishTask.duplicateOutputFields(vMMEEvent.getParameterMap()); + final AxTask vMmeEstablishTask = new AxTask(new AxArtifactKey("VMMEEstablishTask", "0.0.1")); + vMmeEstablishTask.duplicateInputFields(vMmeEvent.getParameterMap()); + vMmeEstablishTask.duplicateOutputFields(vMmeEvent.getParameterMap()); logicReader.setDefaultLogic("Default_TaskLogic"); - vMMEEstablishTask.setTaskLogic(new AxTaskLogic(vMMEEstablishTask.getKey(), "TaskLogic", "MVEL", logicReader)); + vMmeEstablishTask.setTaskLogic(new AxTaskLogic(vMmeEstablishTask.getKey(), "TaskLogic", "MVEL", logicReader)); - final AxTask vMMEDecideTask = new AxTask(new AxArtifactKey("VMMEDecideTask", "0.0.1")); - vMMEDecideTask.duplicateInputFields(vMMEEvent.getParameterMap()); - vMMEDecideTask.duplicateOutputFields(vMMEEvent.getParameterMap()); - vMMEDecideTask.setTaskLogic(new AxTaskLogic(vMMEDecideTask.getKey(), "TaskLogic", "MVEL", logicReader)); + final AxTask vMmeDecideTask = new AxTask(new AxArtifactKey("VMMEDecideTask", "0.0.1")); + vMmeDecideTask.duplicateInputFields(vMmeEvent.getParameterMap()); + vMmeDecideTask.duplicateOutputFields(vMmeEvent.getParameterMap()); + vMmeDecideTask.setTaskLogic(new AxTaskLogic(vMmeDecideTask.getKey(), "TaskLogic", "MVEL", logicReader)); - final AxTask vMMENoActTask = new AxTask(new AxArtifactKey("VMMENoActTask", "0.0.1")); - vMMENoActTask.duplicateInputFields(vMMEEvent.getParameterMap()); - vMMENoActTask.duplicateOutputFields(vMMEEvent.getParameterMap()); - vMMENoActTask.setTaskLogic(new AxTaskLogic(vMMENoActTask.getKey(), "TaskLogic", "MVEL", logicReader)); + final AxTask vMmeNoActTask = new AxTask(new AxArtifactKey("VMMENoActTask", "0.0.1")); + vMmeNoActTask.duplicateInputFields(vMmeEvent.getParameterMap()); + vMmeNoActTask.duplicateOutputFields(vMmeEvent.getParameterMap()); + vMmeNoActTask.setTaskLogic(new AxTaskLogic(vMmeNoActTask.getKey(), "TaskLogic", "MVEL", logicReader)); - final AxTask vMMEActTask = new AxTask(new AxArtifactKey("VMMEActTask", "0.0.1")); - vMMEActTask.duplicateInputFields(vMMEEvent.getParameterMap()); - vMMEActTask.duplicateOutputFields(vMMEEvent.getParameterMap()); + final AxTask vMmeActTask = new AxTask(new AxArtifactKey("VMMEActTask", "0.0.1")); + vMmeActTask.duplicateInputFields(vMmeEvent.getParameterMap()); + vMmeActTask.duplicateOutputFields(vMmeEvent.getParameterMap()); logicReader.setDefaultLogic(null); - vMMEActTask.setTaskLogic(new AxTaskLogic(vMMEActTask.getKey(), "TaskLogic", "MVEL", logicReader)); + vMmeActTask.setTaskLogic(new AxTaskLogic(vMmeActTask.getKey(), "TaskLogic", "MVEL", logicReader)); final AxTask sapcMatchTask = new AxTask(new AxArtifactKey("SAPCMatchTask", "0.0.1")); sapcMatchTask.duplicateInputFields(sapcEvent.getParameterMap()); @@ -453,11 +453,11 @@ public class AADMDomainModelFactory { aadmTasks.getTaskMap().put(aadmDoSSuggestionActTask.getKey(), aadmDoSSuggestionActTask); aadmTasks.getTaskMap().put(aadmNoActTask.getKey(), aadmNoActTask); aadmTasks.getTaskMap().put(aadmDoSProvenActTask.getKey(), aadmDoSProvenActTask); - aadmTasks.getTaskMap().put(vMMEMatchTask.getKey(), vMMEMatchTask); - aadmTasks.getTaskMap().put(vMMEEstablishTask.getKey(), vMMEEstablishTask); - aadmTasks.getTaskMap().put(vMMEDecideTask.getKey(), vMMEDecideTask); - aadmTasks.getTaskMap().put(vMMENoActTask.getKey(), vMMENoActTask); - aadmTasks.getTaskMap().put(vMMEActTask.getKey(), vMMEActTask); + aadmTasks.getTaskMap().put(vMmeMatchTask.getKey(), vMmeMatchTask); + aadmTasks.getTaskMap().put(vMmeEstablishTask.getKey(), vMmeEstablishTask); + aadmTasks.getTaskMap().put(vMmeDecideTask.getKey(), vMmeDecideTask); + aadmTasks.getTaskMap().put(vMmeNoActTask.getKey(), vMmeNoActTask); + aadmTasks.getTaskMap().put(vMmeActTask.getKey(), vMmeActTask); aadmTasks.getTaskMap().put(sapcMatchTask.getKey(), sapcMatchTask); aadmTasks.getTaskMap().put(sapcEstablishTask.getKey(), sapcEstablishTask); aadmTasks.getTaskMap().put(sapcDecideTask.getKey(), sapcDecideTask); @@ -535,53 +535,53 @@ public class AADMDomainModelFactory { aadmPolicy.getStateMap().put(aadmDecideState.getKey().getLocalName(), aadmDecideState); aadmPolicy.getStateMap().put(aadmActState.getKey().getLocalName(), aadmActState); - final AxPolicy vMMEPolicy = new AxPolicy(new AxArtifactKey("VMMEPolicy", "0.0.1")); - vMMEPolicy.setTemplate("MEDA"); - - final AxState vMMEActState = new AxState(new AxReferenceKey(vMMEPolicy.getKey(), "Act")); - vMMEActState.setTrigger(vMMEEvent.getKey()); - final AxStateOutput vMMEAct2Out = - new AxStateOutput(vMMEActState.getKey(), AxReferenceKey.getNullKey(), vMMEEvent.getKey()); - vMMEActState.getStateOutputs().put(vMMEAct2Out.getKey().getLocalName(), vMMEAct2Out); - vMMEActState.setDefaultTask(vMMEActTask.getKey()); - vMMEActState.getTaskReferences().put(vMMEActTask.getKey(), new AxStateTaskReference(vMMEActState.getKey(), - vMMEActTask.getKey(), AxStateTaskOutputType.DIRECT, vMMEAct2Out.getKey())); - vMMEActState.getTaskReferences().put(vMMENoActTask.getKey(), new AxStateTaskReference(vMMEActState.getKey(), - vMMENoActTask.getKey(), AxStateTaskOutputType.DIRECT, vMMEAct2Out.getKey())); - - final AxState vMMEDecideState = new AxState(new AxReferenceKey(vMMEPolicy.getKey(), "Decide")); - vMMEDecideState.setTrigger(vMMEEvent.getKey()); - final AxStateOutput vMMEDec2Act = - new AxStateOutput(vMMEDecideState.getKey(), vMMEActState.getKey(), vMMEEvent.getKey()); - vMMEDecideState.getStateOutputs().put(vMMEDec2Act.getKey().getLocalName(), vMMEDec2Act); - vMMEDecideState.setDefaultTask(vMMEDecideTask.getKey()); - vMMEDecideState.getTaskReferences().put(vMMEDecideTask.getKey(), new AxStateTaskReference( - vMMEDecideState.getKey(), vMMEDecideTask.getKey(), AxStateTaskOutputType.DIRECT, vMMEDec2Act.getKey())); - - final AxState vMMEEstablishState = new AxState(new AxReferenceKey(vMMEPolicy.getKey(), "Establish")); - vMMEEstablishState.setTrigger(vMMEEvent.getKey()); - final AxStateOutput vMMEEst2Dec = - new AxStateOutput(vMMEEstablishState.getKey(), vMMEDecideState.getKey(), vMMEEvent.getKey()); - vMMEEstablishState.getStateOutputs().put(vMMEEst2Dec.getKey().getLocalName(), vMMEEst2Dec); - vMMEEstablishState.setDefaultTask(vMMEEstablishTask.getKey()); - vMMEEstablishState.getTaskReferences().put(vMMEEstablishTask.getKey(), - new AxStateTaskReference(vMMEEstablishState.getKey(), vMMEEstablishTask.getKey(), - AxStateTaskOutputType.DIRECT, vMMEEst2Dec.getKey())); - - final AxState vMMEMatchState = new AxState(new AxReferenceKey(vMMEPolicy.getKey(), "Match")); - vMMEMatchState.setTrigger(vMMEEvent.getKey()); - final AxStateOutput vMMEMat2Est = - new AxStateOutput(vMMEMatchState.getKey(), vMMEEstablishState.getKey(), vMMEEvent.getKey()); - vMMEMatchState.getStateOutputs().put(vMMEMat2Est.getKey().getLocalName(), vMMEMat2Est); - vMMEMatchState.setDefaultTask(vMMEMatchTask.getKey()); - vMMEMatchState.getTaskReferences().put(vMMEMatchTask.getKey(), new AxStateTaskReference(vMMEMatchState.getKey(), - vMMEMatchTask.getKey(), AxStateTaskOutputType.DIRECT, vMMEMat2Est.getKey())); - - vMMEPolicy.setFirstState(vMMEMatchState.getKey().getLocalName()); - vMMEPolicy.getStateMap().put(vMMEMatchState.getKey().getLocalName(), vMMEMatchState); - vMMEPolicy.getStateMap().put(vMMEEstablishState.getKey().getLocalName(), vMMEEstablishState); - vMMEPolicy.getStateMap().put(vMMEDecideState.getKey().getLocalName(), vMMEDecideState); - vMMEPolicy.getStateMap().put(vMMEActState.getKey().getLocalName(), vMMEActState); + final AxPolicy vMmePolicy = new AxPolicy(new AxArtifactKey("VMMEPolicy", "0.0.1")); + vMmePolicy.setTemplate("MEDA"); + + final AxState vMmeActState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), "Act")); + vMmeActState.setTrigger(vMmeEvent.getKey()); + final AxStateOutput vMmeAct2Out = + new AxStateOutput(vMmeActState.getKey(), AxReferenceKey.getNullKey(), vMmeEvent.getKey()); + vMmeActState.getStateOutputs().put(vMmeAct2Out.getKey().getLocalName(), vMmeAct2Out); + vMmeActState.setDefaultTask(vMmeActTask.getKey()); + vMmeActState.getTaskReferences().put(vMmeActTask.getKey(), new AxStateTaskReference(vMmeActState.getKey(), + vMmeActTask.getKey(), AxStateTaskOutputType.DIRECT, vMmeAct2Out.getKey())); + vMmeActState.getTaskReferences().put(vMmeNoActTask.getKey(), new AxStateTaskReference(vMmeActState.getKey(), + vMmeNoActTask.getKey(), AxStateTaskOutputType.DIRECT, vMmeAct2Out.getKey())); + + final AxState vMmeDecideState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), "Decide")); + vMmeDecideState.setTrigger(vMmeEvent.getKey()); + final AxStateOutput vMmeDec2Act = + new AxStateOutput(vMmeDecideState.getKey(), vMmeActState.getKey(), vMmeEvent.getKey()); + vMmeDecideState.getStateOutputs().put(vMmeDec2Act.getKey().getLocalName(), vMmeDec2Act); + vMmeDecideState.setDefaultTask(vMmeDecideTask.getKey()); + vMmeDecideState.getTaskReferences().put(vMmeDecideTask.getKey(), new AxStateTaskReference( + vMmeDecideState.getKey(), vMmeDecideTask.getKey(), AxStateTaskOutputType.DIRECT, vMmeDec2Act.getKey())); + + final AxState vMmeEstablishState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), "Establish")); + vMmeEstablishState.setTrigger(vMmeEvent.getKey()); + final AxStateOutput vMmeEst2Dec = + new AxStateOutput(vMmeEstablishState.getKey(), vMmeDecideState.getKey(), vMmeEvent.getKey()); + vMmeEstablishState.getStateOutputs().put(vMmeEst2Dec.getKey().getLocalName(), vMmeEst2Dec); + vMmeEstablishState.setDefaultTask(vMmeEstablishTask.getKey()); + vMmeEstablishState.getTaskReferences().put(vMmeEstablishTask.getKey(), + new AxStateTaskReference(vMmeEstablishState.getKey(), vMmeEstablishTask.getKey(), + AxStateTaskOutputType.DIRECT, vMmeEst2Dec.getKey())); + + final AxState vMmeMatchState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), "Match")); + vMmeMatchState.setTrigger(vMmeEvent.getKey()); + final AxStateOutput vMmeMat2Est = + new AxStateOutput(vMmeMatchState.getKey(), vMmeEstablishState.getKey(), vMmeEvent.getKey()); + vMmeMatchState.getStateOutputs().put(vMmeMat2Est.getKey().getLocalName(), vMmeMat2Est); + vMmeMatchState.setDefaultTask(vMmeMatchTask.getKey()); + vMmeMatchState.getTaskReferences().put(vMmeMatchTask.getKey(), new AxStateTaskReference(vMmeMatchState.getKey(), + vMmeMatchTask.getKey(), AxStateTaskOutputType.DIRECT, vMmeMat2Est.getKey())); + + vMmePolicy.setFirstState(vMmeMatchState.getKey().getLocalName()); + vMmePolicy.getStateMap().put(vMmeMatchState.getKey().getLocalName(), vMmeMatchState); + vMmePolicy.getStateMap().put(vMmeEstablishState.getKey().getLocalName(), vMmeEstablishState); + vMmePolicy.getStateMap().put(vMmeDecideState.getKey().getLocalName(), vMmeDecideState); + vMmePolicy.getStateMap().put(vMmeActState.getKey().getLocalName(), vMmeActState); final AxPolicy sapcPolicy = new AxPolicy(new AxArtifactKey("SAPCPolicy", "0.0.1")); sapcPolicy.setTemplate("MEDA"); @@ -680,7 +680,7 @@ public class AADMDomainModelFactory { final AxPolicies aadmPolicies = new AxPolicies(new AxArtifactKey("AADMPolicies", "0.0.1")); aadmPolicies.getPolicyMap().put(aadmPolicy.getKey(), aadmPolicy); - aadmPolicies.getPolicyMap().put(vMMEPolicy.getKey(), vMMEPolicy); + aadmPolicies.getPolicyMap().put(vMmePolicy.getKey(), vMmePolicy); aadmPolicies.getPolicyMap().put(sapcPolicy.getKey(), sapcPolicy); aadmPolicies.getPolicyMap().put(periodicPolicy.getKey(), periodicPolicy); diff --git a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AADMDomainModelSaver.java b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelSaver.java index a25a0e983..5a3afd901 100644 --- a/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AADMDomainModelSaver.java +++ b/examples/examples-aadm/src/main/java/org/onap/policy/apex/examples/aadm/model/AadmDomainModelSaver.java @@ -29,11 +29,11 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public final class AADMDomainModelSaver { +public final class AadmDomainModelSaver { /** * Private default constructor to prevent subclassing. */ - private AADMDomainModelSaver() {} + private AadmDomainModelSaver() {} /** * Write the AADM model to args[0]. @@ -43,12 +43,12 @@ public final class AADMDomainModelSaver { */ public static void main(final String[] args) throws ApexException { if (args.length != 1) { - System.err.println("usage: " + AADMDomainModelSaver.class.getCanonicalName() + " modelDirectory"); + System.err.println("usage: " + AadmDomainModelSaver.class.getCanonicalName() + " modelDirectory"); return; } // Save Java model - final AxPolicyModel aadmPolicyModel = new AADMDomainModelFactory().getAADMPolicyModel(); + final AxPolicyModel aadmPolicyModel = new AadmDomainModelFactory().getAadmPolicyModel(); final ApexModelSaver<AxPolicyModel> aadmModelSaver = new ApexModelSaver<>(AxPolicyModel.class, aadmPolicyModel, args[0]); aadmModelSaver.apexModelWriteJson(); diff --git a/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutJsonEvent.json b/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutJsonEvent.json index c43f41353..427dea352 100644 --- a/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutJsonEvent.json +++ b/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } diff --git a/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutXmlEvent.json b/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutXmlEvent.json index 294da2483..3658b09a2 100644 --- a/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutXmlEvent.json +++ b/examples/examples-aadm/src/main/resources/examples/config/AADM/Stdin2StdoutXmlEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -24,7 +24,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } }, @@ -38,7 +38,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } } diff --git a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSProvenActTask_TaskLogic.mvel b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSProvenActTask_TaskLogic.mvel index 078841792..225a0da4d 100644 --- a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSProvenActTask_TaskLogic.mvel +++ b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSProvenActTask_TaskLogic.mvel @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus; -import org.onap.policy.apex.examples.aadm.concepts.IMSIStatus; +import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus; logger.debug(subject.id + ":" + subject.taskName + " execution logic"); logger.debug(inFields); @@ -44,10 +44,10 @@ else{ outFields["NW_IP"] = inFields["SGW_IP_ADDRESS"]; } -IMSIStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); +ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); logger.debug(imsiStatus); -ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBID()); +ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBId()); eNodeBStatus.setBeingProbed(false); leaveProbingOn = false; @@ -62,14 +62,14 @@ if (!leaveProbingOn) { outFields["TCP_ON"] = false; } -eNodeBStatus.decrementDOSCount(); -logger.debug(eNodeBStatus.getENodeB() + ": dosCount is " + eNodeBStatus.getDOSCount()); +eNodeBStatus.decrementDosCount(); +logger.debug(eNodeBStatus.getENodeB() + ": dosCount is " + eNodeBStatus.getDosCount()); imsiStatus.setAnomalous(false); -logger.debug("imsi: " + imsiStatus.getIMSI() + " anamalous " + imsiStatus.getAnomalous()); +logger.debug("imsi: " + imsiStatus.getImsi() + " anamalous " + imsiStatus.getAnomalous()); -getContextAlbum("IMSIStatusAlbum") .put(imsiStatus.getIMSI(), imsiStatus); +getContextAlbum("IMSIStatusAlbum") .put(imsiStatus.getImsi(), imsiStatus); getContextAlbum("ENodeBStatusAlbum").put(eNodeBStatus.getENodeB(), eNodeBStatus); outFields["THRESHOLD"] = 0; diff --git a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSSuggestionActTask_TaskLogic.mvel b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSSuggestionActTask_TaskLogic.mvel index d04f9425e..63ac8d0ba 100644 --- a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSSuggestionActTask_TaskLogic.mvel +++ b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMDoSSuggestionActTask_TaskLogic.mvel @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus; -import org.onap.policy.apex.examples.aadm.concepts.IMSIStatus; +import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus; logger.debug(subject.id + ":" + subject.taskName + " execution logic"); logger.debug(inFields); @@ -42,16 +42,16 @@ else { outFields["NW_IP"] = inFields["SGW_IP_ADDRESS"]; } -IMSIStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); +ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); logger.debug(imsiStatus); -ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBID()); +ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBId()); logger.debug(eNodeBStatus); -if (imsiStatus.getENodeBID() != null && !imsiStatus.getENodeBID().equals(inFields["ENODEB_ID"]) || inFields["AVG_SUBSCRIBER_SERVICE_REQUEST"] == null) { +if (imsiStatus.getENodeBId() != null && !imsiStatus.getENodeBId().equals(inFields["ENODEB_ID"]) || inFields["AVG_SUBSCRIBER_SERVICE_REQUEST"] == null) { // if user moved enodeB remove him from previous one - if (imsiStatus.getENodeBID() != null) { - eNodeBStatus.decrementDOSCount(); + if (imsiStatus.getENodeBId() != null) { + eNodeBStatus.decrementDosCount(); } // if user became non anomalous return action @@ -79,20 +79,20 @@ if (imsiStatus.getENodeBID() != null && !imsiStatus.getENodeBID().equals(inField imsiStatus.setAnomalous(true); imsiStatus.setAnomolousTime(System.currentTimeMillis()); -imsiStatus.setENodeBID(inFields["ENODEB_ID"]); -getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getIMSI(), imsiStatus); -logger.debug(imsiStatus.getENodeBID() + ": enodeb added to imsi ip added " + outFields["IMSI_IP"]); +imsiStatus.setENodeBId(inFields["ENODEB_ID"]); +getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getImsi(), imsiStatus); +logger.debug(imsiStatus.getENodeBId() + ": enodeb added to imsi ip added " + outFields["IMSI_IP"]); -ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBID()); +ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBId()); if (eNodeBStatus == null) { - eNodeBStatus = new ENodeBStatus(imsiStatus.getENodeBID()); + eNodeBStatus = new ENodeBStatus(imsiStatus.getENodeBId()); getContextAlbum("ENodeBStatusAlbum").put(eNodeBStatus.getENodeB(), eNodeBStatus); - logger.debug("new eNodeB added " + getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBID())); + logger.debug("new eNodeB added " + getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBId())); } -eNodeBStatus.incrementDOSCount(); +eNodeBStatus.incrementDosCount(); getContextAlbum("ENodeBStatusAlbum").put(eNodeBStatus.getENodeB(), eNodeBStatus); -logger.debug(eNodeBStatus.getENodeB() + ": dosCount incremented to " + eNodeBStatus.getDOSCount()); +logger.debug(eNodeBStatus.getENodeB() + ": dosCount incremented to " + eNodeBStatus.getDosCount()); outFields["PROBE_ON"] = true; outFields["TCP_ON"] = true; diff --git a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMMatchTask_TaskLogic.mvel b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMMatchTask_TaskLogic.mvel index bb38034af..24ad9bb0a 100644 --- a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMMatchTask_TaskLogic.mvel +++ b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMMatchTask_TaskLogic.mvel @@ -18,8 +18,8 @@ * ============LICENSE_END========================================================= */ import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus; -import org.onap.policy.apex.examples.aadm.concepts.IPAddressStatus; -import org.onap.policy.apex.examples.aadm.concepts.IMSIStatus; +import org.onap.policy.apex.examples.aadm.concepts.IpAddressStatus; +import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus; logger.debug(subject.id + ":" + subject.taskName + " execution logic"); logger.debug(inFields); @@ -46,22 +46,22 @@ if (eNodeBID == null ) { return false; } -IPAddressStatus ipAddressStatus = getContextAlbum("IPAddressStatusAlbum").get(ipAddress); +IpAddressStatus ipAddressStatus = getContextAlbum("IPAddressStatusAlbum").get(ipAddress); if (ipAddressStatus == null) { - ipAddressStatus = new IPAddressStatus(ipAddress); - ipAddressStatus.setIMSI(imsi); - getContextAlbum("IPAddressStatusAlbum").put(ipAddressStatus.getIPAddress(), ipAddressStatus); + ipAddressStatus = new IpAddressStatus(ipAddress); + ipAddressStatus.setImsi(imsi); + getContextAlbum("IPAddressStatusAlbum").put(ipAddressStatus.getIpAddress(), ipAddressStatus); logger.debug("added new IP address " + getContextAlbum("IPAddressStatusAlbum").get(ipAddress)); } else { logger.debug("found IP address " + ipAddressStatus); } -IMSIStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)imsi); +ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)imsi); if (imsiStatus == null) { - imsiStatus = new IMSIStatus(imsi); - imsiStatus.setENodeBID(eNodeBID); - getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getIMSI(), imsiStatus); + imsiStatus = new ImsiStatus(imsi); + imsiStatus.setENodeBId(eNodeBID); + getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getImsi(), imsiStatus); logger.debug("added new IMSI " + imsi + " to IMSI status map") } diff --git a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMPolicy_Act_TaskSelectionLogic.mvel b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMPolicy_Act_TaskSelectionLogic.mvel index 2d0d45bdf..9c71db50a 100644 --- a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMPolicy_Act_TaskSelectionLogic.mvel +++ b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/AADMPolicy_Act_TaskSelectionLogic.mvel @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -import org.onap.policy.apex.examples.aadm.concepts.IMSIStatus; +import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus; import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus; logger.debug(subject.id + ":" + subject.stateName + " execution logic"); @@ -25,7 +25,7 @@ logger.debug(inFields); logger.debug("inFields[SERVICE_REQUEST_COUNT]=" + inFields["SERVICE_REQUEST_COUNT"]); -IMSIStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); +ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); if (imsiStatus.getBlockingCount() > 1) { subject.getTaskKey("AADMNoActTask").copyTo(selectedTask); @@ -33,7 +33,7 @@ if (imsiStatus.getBlockingCount() > 1) { return false; } -logger.debug("imsi: " + imsiStatus.getIMSI() + " anamalous " + imsiStatus.getAnomalous()); +logger.debug("imsi: " + imsiStatus.getImsi() + " anamalous " + imsiStatus.getAnomalous()); // check if this is second iteration if (inFields["TCP_UE_SIDE_AVG_THROUGHPUT"] != null && inFields["TCP_UE_SIDE_AVG_THROUGHPUT"] > 100 && imsiStatus.getAnomalous()) { @@ -49,7 +49,7 @@ ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get((String)inF if (inFields["SERVICE_REQUEST_COUNT"] != null && inFields["AVG_SUBSCRIBER_SERVICE_REQUEST"] != null && inFields["SERVICE_REQUEST_COUNT"] > inFields["AVG_SUBSCRIBER_SERVICE_REQUEST"] && - eNodeBStatus != null && eNodeBStatus.getDOSCount() > 100 && + eNodeBStatus != null && eNodeBStatus.getDosCount() > 100 && inFields["NUM_SUBSCRIBERS"] != null && inFields["NUM_SUBSCRIBERS"] > 100) { logger.debug("inside NUM_SUBSCRIBERS"); subject.getTaskKey("AADMDoSProvenActTask").copyTo(selectedTask); diff --git a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/PeriodicActTask_TaskLogic.mvel b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/PeriodicActTask_TaskLogic.mvel index 115ac5477..6a2c598b0 100644 --- a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/PeriodicActTask_TaskLogic.mvel +++ b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/PeriodicActTask_TaskLogic.mvel @@ -17,15 +17,15 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -import org.onap.policy.apex.examples.aadm.concepts.IMSIStatus; +import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus; logger.debug(subject.id + ":" + subject.taskName + " execution logic"); logger.debug(inFields); -for (IMSIStatus imsiStatus : getContextAlbum("IMSIStatusAlbum").values()) { +for (ImsiStatus imsiStatus : getContextAlbum("IMSIStatusAlbum").values()) { if ((System.currentTimeMillis() - imsiStatus.getBlacklistedTime()) > 180000) { imsiStatus.setBlacklistedTime(0); - getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getIMSI(), imsiStatus); + getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getImsi(), imsiStatus); } } diff --git a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/SAPCActTask_TaskLogic.mvel b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/SAPCActTask_TaskLogic.mvel index 7ceaa2abe..b0c6c3158 100644 --- a/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/SAPCActTask_TaskLogic.mvel +++ b/examples/examples-aadm/src/main/resources/org/onap/policy/apex/examples/aadm/model/mvel/SAPCActTask_TaskLogic.mvel @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -import org.onap.policy.apex.examples.aadm.concepts.IMSIStatus; +import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus; logger.debug(subject.id + ":" + subject.taskName + " execution logic"); logger.debug(inFields); @@ -38,7 +38,7 @@ if (outFields["IMSI"] == 0 && inFields["IMSI_IP"] != null && inFields["IMSI_IP"] return true; } -IMSIStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); +ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]); logger.debug(imsiStatus); if (imsiStatus.getBlockingCount() > 1) { @@ -62,8 +62,8 @@ if (imsiStatus.getBlockingCount() > 0 && imsiStatus.getBlacklistedTime() != 0) { imsiStatus.incrementBlockingCount(); imsiStatus.setBlacklistedTime(System.currentTimeMillis()); -logger.debug("Bocking count for IMSI: " + imsiStatus.getIMSI() + " is: " + imsiStatus.getBlockingCount()); -getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getIMSI(), imsiStatus); +logger.debug("Bocking count for IMSI: " + imsiStatus.getImsi() + " is: " + imsiStatus.getBlockingCount()); +getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getImsi(), imsiStatus); outFields["PROFILE"] = "ServiceA"; outFields["BLACKLIST_ON"] = true; diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmDbWrite.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmDbWrite.java index b67bb6245..bbcbaab03 100644 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmDbWrite.java +++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmDbWrite.java @@ -44,7 +44,7 @@ public class TestAadmDbWrite { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true"); - testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAADMModelCreator()); + testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAadmModelCreator()); } @After diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMModel.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmModel.java index ba992b522..1ac1e9829 100644 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMModel.java +++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmModel.java @@ -34,7 +34,7 @@ import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; import org.onap.policy.apex.model.basicmodel.test.TestApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -public class TestAADMModel { +public class TestAadmModel { private Connection connection; TestApexModel<AxPolicyModel> testApexModel; @@ -47,7 +47,7 @@ public class TestAADMModel { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true"); - testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAADMModelCreator()); + testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAadmModelCreator()); } @After @@ -63,17 +63,17 @@ public class TestAADMModel { } @Test - public void testModelWriteReadXML() throws Exception { + public void testModelWriteReadXml() throws Exception { testApexModel.testApexModelWriteReadXml(); } @Test - public void testModelWriteReadJSON() throws Exception { + public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } @Test - public void testModelWriteReadJPA() throws Exception { + public void testModelWriteReadJpa() throws Exception { final DaoParameters DaoParameters = new DaoParameters(); DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); DaoParameters.setPersistenceUnit("AADMModelTest"); diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMModelCreator.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmModelCreator.java index 421a45a15..7f34bff59 100644 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMModelCreator.java +++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmModelCreator.java @@ -20,7 +20,7 @@ package org.onap.policy.apex.examples.aadm; -import org.onap.policy.apex.examples.aadm.model.AADMDomainModelFactory; +import org.onap.policy.apex.examples.aadm.model.AadmDomainModelFactory; import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; @@ -28,11 +28,11 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; * This class implements Interface TestApexModelCreator to support AADM model. * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestAADMModelCreator implements TestApexModelCreator<AxPolicyModel> { +public class TestAadmModelCreator implements TestApexModelCreator<AxPolicyModel> { @Override public AxPolicyModel getModel() { - return new AADMDomainModelFactory().getAADMPolicyModel(); + return new AadmDomainModelFactory().getAadmPolicyModel(); } @Override diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMUseCase.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmUseCase.java index 21f240ba8..579bf3484 100644 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAADMUseCase.java +++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestAadmUseCase.java @@ -39,23 +39,24 @@ import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus; -import org.onap.policy.apex.examples.aadm.model.AADMDomainModelFactory; +import org.onap.policy.apex.examples.aadm.model.AadmDomainModelFactory; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +// TODO: Auto-generated Javadoc /** * This class tests AADM use case. * @author Sergey Sachkov (sergey.sachkov@ericsson.com) * */ -public class TestAADMUseCase { - private static final XLogger logger = XLoggerFactory.getXLogger(TestAADMUseCase.class); +public class TestAadmUseCase { + private static final XLogger logger = XLoggerFactory.getXLogger(TestAadmUseCase.class); private SchemaParameters schemaParameters; private ContextParameters contextParameters; @@ -86,10 +87,13 @@ public class TestAADMUseCase { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); ParameterService.register(engineParameters); } + /** + * After test. + */ @After public void afterTest() { ParameterService.deregister(engineParameters); @@ -110,8 +114,8 @@ public class TestAADMUseCase { * @throws IOException Signals that an I/O exception has occurred. */ @Test - public void testAADMCase() throws ApexException, InterruptedException, IOException { - final AxPolicyModel apexPolicyModel = new AADMDomainModelFactory().getAADMPolicyModel(); + public void testAadmCase() throws ApexException, InterruptedException, IOException { + final AxPolicyModel apexPolicyModel = new AadmDomainModelFactory().getAadmPolicyModel(); assertNotNull(apexPolicyModel); final AxArtifactKey key = new AxArtifactKey("AADMApexEngine", "0.0.1"); @@ -159,7 +163,7 @@ public class TestAADMUseCase { final ContextAlbum eNodeBStatusAlbum = apexEngine.getInternalContext().get("ENodeBStatusAlbum"); final ENodeBStatus eNodeBStatus = (ENodeBStatus) eNodeBStatusAlbum.get("123"); - eNodeBStatus.setDOSCount(101); + eNodeBStatus.setDosCount(101); eNodeBStatusAlbum.put(eNodeBStatus.getENodeB(), eNodeBStatus); logger.info("Sending too many connections trigger "); @@ -194,10 +198,10 @@ public class TestAADMUseCase { // only one imsi was sent to process, so stop probe and tcp assertTrue(!(boolean) result.get("TCP_ON")); assertTrue(!(boolean) result.get("PROBE_ON")); - assertEquals(100, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDOSCount()); + assertEquals(100, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDosCount()); logger.info("Receiving action event with {} action", result.get("ACTTASK")); - ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDOSCount(99); + ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDosCount(99); // getting number of connections send it to policy, expecting probe action logger.info("Sending too many connections trigger "); @@ -230,9 +234,9 @@ public class TestAADMUseCase { assertTrue(result.get("ACTTASK").equals("probe")); assertTrue((boolean) result.get("TCP_ON")); assertTrue((boolean) result.get("PROBE_ON")); - assertEquals(99, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDOSCount()); + assertEquals(99, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDosCount()); - ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDOSCount(99); + ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDosCount(99); // tcp correlation return positive dos logger.info("Receiving action event with {} action", result.get("ACTTASK")); @@ -265,10 +269,10 @@ public class TestAADMUseCase { assertTrue(result.get("ACTTASK").equals("act")); assertTrue(!(boolean) result.get("TCP_ON")); assertTrue(!(boolean) result.get("PROBE_ON")); - assertEquals(98, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDOSCount()); + assertEquals(98, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDosCount()); logger.info("Receiving action event with {} action", result.get("ACTTASK")); - ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDOSCount(101); + ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDosCount(101); // user moving enodeB logger.info("Sending too many connections trigger "); @@ -302,7 +306,7 @@ public class TestAADMUseCase { assertTrue(result.get("ACTTASK").equals("act")); assertTrue(!(boolean) result.get("TCP_ON")); assertTrue(!(boolean) result.get("PROBE_ON")); - assertEquals(100, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDOSCount()); + assertEquals(100, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDosCount()); logger.info("Receiving action event with {} action", result.get("ACTTASK")); logger.info("Sending too many connections trigger "); @@ -335,12 +339,12 @@ public class TestAADMUseCase { assertTrue(result.get("ACTTASK").equals("probe")); assertTrue((boolean) result.get("TCP_ON")); assertTrue((boolean) result.get("PROBE_ON")); - assertEquals(99, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDOSCount()); - assertEquals(1, ((ENodeBStatus) eNodeBStatusAlbum.get("124")).getDOSCount()); + assertEquals(99, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDosCount()); + assertEquals(1, ((ENodeBStatus) eNodeBStatusAlbum.get("124")).getDosCount()); logger.info("Receiving action event with {} action", result.get("ACTTASK")); // End of user moving enodeB - ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDOSCount(101); + ((ENodeBStatus) eNodeBStatusAlbum.get("123")).setDosCount(101); // user becomes non anomalous logger.info("Sending too many connections trigger "); @@ -373,7 +377,7 @@ public class TestAADMUseCase { assertTrue(result.get("ACTTASK").equals("probe")); assertTrue((boolean) result.get("TCP_ON")); assertTrue((boolean) result.get("PROBE_ON")); - assertEquals(102, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDOSCount()); + assertEquals(102, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDosCount()); logger.info("Receiving action event with {} action", result.get("ACTTASK")); logger.info("Sending too many connections trigger "); @@ -406,7 +410,7 @@ public class TestAADMUseCase { assertTrue(result.get("ACTTASK").equals("probe")); assertTrue((boolean) result.get("TCP_ON")); assertTrue((boolean) result.get("PROBE_ON")); - assertEquals(102, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDOSCount()); + assertEquals(102, ((ENodeBStatus) eNodeBStatusAlbum.get("123")).getDosCount()); logger.info("Receiving action event with {} action", result.get("ACTTASK")); // End of user becomes non anomalous apexEngine.handleEvent(result); @@ -436,12 +440,12 @@ public class TestAADMUseCase { * Test vpn cleardown. */ @After - public void testAADMCleardown() {} + public void testAadmCleardown() {} /** * Gets the trigger event. * - * @param apexModel the apex model + * @param apexPolicyModel the apex policy model * @return the trigger event */ private AxEvent getTriggerEvent(final AxPolicyModel apexPolicyModel) { diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java index 4b66eb116..cb7e3c824 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java @@ -44,7 +44,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -66,6 +66,9 @@ public class TestAnomalyDetectionTslUseCase { private ContextParameters contextParameters; private EngineParameters engineParameters; + /** + * Before test. + */ @Before public void beforeTest() { schemaParameters = new SchemaParameters(); @@ -88,11 +91,14 @@ public class TestAnomalyDetectionTslUseCase { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters()); ParameterService.register(engineParameters); } + /** + * After test. + */ @After public void afterTest() { ParameterService.deregister(engineParameters); @@ -105,6 +111,13 @@ public class TestAnomalyDetectionTslUseCase { ParameterService.deregister(schemaParameters); } + /** + * Test anomaly detection tsl. + * + * @throws ApexException the apex exception + * @throws InterruptedException the interrupted exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test // once through the long running test below public void testAnomalyDetectionTsl() throws ApexException, InterruptedException, IOException { @@ -170,7 +183,7 @@ public class TestAnomalyDetectionTslUseCase { final AxArtifactKey key = new AxArtifactKey("AnomalyTSLApexEngine", "0.0.1"); final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + parameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); parameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters()); final ApexEngine apexEngine1 = new ApexEngineFactory().createApexEngine(key); @@ -205,6 +218,14 @@ public class TestAnomalyDetectionTslUseCase { Thread.sleep(1000); } + /** + * The main method. + * + * @param args the arguments + * @throws ApexException the apex exception + * @throws InterruptedException the interrupted exception + * @throws IOException Signals that an I/O exception has occurred. + */ public static void main(final String[] args) throws ApexException, InterruptedException, IOException { new TestAnomalyDetectionTslUseCase().testAnomalyDetectionTslmain(); } diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java index 632ae623e..3052c31a7 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java @@ -44,11 +44,12 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +// TODO: Auto-generated Javadoc /** * Test Auto learning in TSL. * @@ -64,6 +65,9 @@ public class TestAutoLearnTslUseCase { private ContextParameters contextParameters; private EngineParameters engineParameters; + /** + * Before test. + */ @Before public void beforeTest() { schemaParameters = new SchemaParameters(); @@ -86,11 +90,14 @@ public class TestAutoLearnTslUseCase { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters()); ParameterService.register(engineParameters); } + /** + * After test. + */ @After public void afterTest() { ParameterService.deregister(engineParameters); @@ -103,6 +110,13 @@ public class TestAutoLearnTslUseCase { ParameterService.deregister(schemaParameters); } + /** + * Test auto learn tsl. + * + * @throws ApexException the apex exception + * @throws InterruptedException the interrupted exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test // once through the long running test below public void testAutoLearnTsl() throws ApexException, InterruptedException, IOException { @@ -167,7 +181,7 @@ public class TestAutoLearnTslUseCase { final AxArtifactKey key = new AxArtifactKey("AADMApexEngine", "0.0.1"); final EngineParameters parameters = new EngineParameters(); - parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + parameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); parameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters()); final ApexEngine apexEngine1 = new ApexEngineFactory().createApexEngine(key); @@ -228,6 +242,14 @@ public class TestAutoLearnTslUseCase { } + /** + * The main method. + * + * @param args the arguments + * @throws ApexException the apex exception + * @throws InterruptedException the interrupted exception + * @throws IOException Signals that an I/O exception has occurred. + */ public static void main(final String[] args) throws ApexException, InterruptedException, IOException { new TestAutoLearnTslUseCase().testAutoLearnTslMain(); } diff --git a/examples/examples-decisionmaker/pom.xml b/examples/examples-decisionmaker/pom.xml index 4bbbc775e..280e6bfd1 100644 --- a/examples/examples-decisionmaker/pom.xml +++ b/examples/examples-decisionmaker/pom.xml @@ -57,7 +57,7 @@ <goal>java</goal> </goals> <configuration> - <mainClass>org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain</mainClass> + <mainClass>org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain</mainClass> <classpathScope>compile</classpathScope> <arguments> <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.name}.apex</argument> diff --git a/examples/examples-myfirstpolicy/pom.xml b/examples/examples-myfirstpolicy/pom.xml index cc56d0b1f..7aa4f5bdf 100644 --- a/examples/examples-myfirstpolicy/pom.xml +++ b/examples/examples-myfirstpolicy/pom.xml @@ -97,7 +97,7 @@ <!-- automatically creates the classpath using all project dependencies, also adding the project build directory --> <classpath /> - <argument>org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelSaver</argument> + <argument>org.onap.policy.apex.examples.myfirstpolicy.model.MfpDomainModelSaver</argument> <argument>${project.build.directory}/classes/examples/models/MyFirstPolicy</argument> </arguments> </configuration> diff --git a/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelFactory.java b/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MfpDomainModelFactory.java index 5e5bb913d..f81a22ee9 100644 --- a/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelFactory.java +++ b/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MfpDomainModelFactory.java @@ -30,7 +30,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * * @author John Keeney (john.keeney@ericsson.com) */ -public class MFPDomainModelFactory { +public class MfpDomainModelFactory { private static final String MFP1PATH = "examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json"; private static final String MFP1_ALT_PATH = "examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.alt.json"; @@ -41,13 +41,13 @@ public class MFPDomainModelFactory { * * @return the MyFirstPolicy#1 policy model */ - public AxPolicyModel getMFP1PolicyModel() { + public AxPolicyModel getMfp1PolicyModel() { java.util.TimeZone.getTimeZone("gmt"); try { final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class); - return reader.read(ResourceUtils.getResourceAsString(MFPDomainModelFactory.MFP1PATH)); + return reader.read(ResourceUtils.getResourceAsString(MfpDomainModelFactory.MFP1PATH)); } catch (final Exception e) { - throw new ApexRuntimeException("Failed to build MyFirstPolicy from path: " + MFPDomainModelFactory.MFP1PATH, + throw new ApexRuntimeException("Failed to build MyFirstPolicy from path: " + MfpDomainModelFactory.MFP1PATH, e); } } @@ -57,14 +57,14 @@ public class MFPDomainModelFactory { * * @return the MyFirstPolicy#1 policy model */ - public AxPolicyModel getMFP1AltPolicyModel() { + public AxPolicyModel getMfp1AltPolicyModel() { java.util.TimeZone.getTimeZone("gmt"); try { final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class); - return reader.read(ResourceUtils.getResourceAsString(MFPDomainModelFactory.MFP1_ALT_PATH)); + return reader.read(ResourceUtils.getResourceAsString(MfpDomainModelFactory.MFP1_ALT_PATH)); } catch (final Exception e) { throw new ApexRuntimeException( - "Failed to build MyFirstPolicy_ALT from path: " + MFPDomainModelFactory.MFP1_ALT_PATH, e); + "Failed to build MyFirstPolicy_ALT from path: " + MfpDomainModelFactory.MFP1_ALT_PATH, e); } } @@ -73,12 +73,12 @@ public class MFPDomainModelFactory { * * @return the MyFirstPolicy#1 policy model */ - public AxPolicyModel getMFP2PolicyModel() { + public AxPolicyModel getMfp2PolicyModel() { try { final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class); - return reader.read(ResourceUtils.getResourceAsString(MFPDomainModelFactory.MFP2PATH)); + return reader.read(ResourceUtils.getResourceAsString(MfpDomainModelFactory.MFP2PATH)); } catch (final Exception e) { - throw new ApexRuntimeException("Failed to build MyFirstPolicy from path: " + MFPDomainModelFactory.MFP2PATH, + throw new ApexRuntimeException("Failed to build MyFirstPolicy from path: " + MfpDomainModelFactory.MFP2PATH, e); } } diff --git a/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelSaver.java b/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MfpDomainModelSaver.java index fb47f6cf9..5122390a8 100644 --- a/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelSaver.java +++ b/examples/examples-myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MfpDomainModelSaver.java @@ -29,10 +29,10 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; * * @author John Keeney (john.keeney@ericsson.com) */ -public final class MFPDomainModelSaver { +public final class MfpDomainModelSaver { /** Private constructor to prevent instantiation. */ - private MFPDomainModelSaver() {} + private MfpDomainModelSaver() {} /** * Write the MyFirstPolicy model to args[0]. @@ -42,18 +42,18 @@ public final class MFPDomainModelSaver { */ public static void main(final String[] args) throws ApexException { if (args.length != 1) { - System.err.println("usage: " + MFPDomainModelSaver.class.getCanonicalName() + " modelDirectory"); + System.err.println("usage: " + MfpDomainModelSaver.class.getCanonicalName() + " modelDirectory"); return; } // Save Java model - AxPolicyModel mfpPolicyModel = new MFPDomainModelFactory().getMFP1PolicyModel(); + AxPolicyModel mfpPolicyModel = new MfpDomainModelFactory().getMfp1PolicyModel(); ApexModelSaver<AxPolicyModel> mfpModelSaver = new ApexModelSaver<>(AxPolicyModel.class, mfpPolicyModel, args[0] + "/1/"); mfpModelSaver.apexModelWriteJson(); mfpModelSaver.apexModelWriteXml(); - mfpPolicyModel = new MFPDomainModelFactory().getMFP2PolicyModel(); + mfpPolicyModel = new MfpDomainModelFactory().getMfp2PolicyModel(); mfpModelSaver = new ApexModelSaver<>(AxPolicyModel.class, mfpPolicyModel, args[0] + "/2/"); mfpModelSaver.apexModelWriteJson(); mfpModelSaver.apexModelWriteXml(); diff --git a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigFile2StdoutJsonEvent.json b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigFile2StdoutJsonEvent.json index fc81cd6a6..d8d53f8c9 100644 --- a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigFile2StdoutJsonEvent.json +++ b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigFile2StdoutJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" }, "JAVASCRIPT": { "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" diff --git a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigStdin2StdoutJsonEvent.json b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigStdin2StdoutJsonEvent.json index 27bd0a6a9..338e1df99 100644 --- a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigStdin2StdoutJsonEvent.json +++ b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigStdin2StdoutJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" }, "JAVASCRIPT": { "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" diff --git a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigWs2WsServerJsonEvent.json b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigWs2WsServerJsonEvent.json index c4cf72171..9d438a4ec 100644 --- a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigWs2WsServerJsonEvent.json +++ b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/1/MyFirstPolicyConfigWs2WsServerJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" }, "JAVASCRIPT": { "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" @@ -21,7 +21,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 4000 @@ -36,7 +36,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 3000 diff --git a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigFile2StdoutJsonEvent.json b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigFile2StdoutJsonEvent.json index be8ae938a..d4dba4446 100644 --- a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigFile2StdoutJsonEvent.json +++ b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigFile2StdoutJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" }, "JAVASCRIPT": { "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" diff --git a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigStdin2StdoutJsonEvent.json b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigStdin2StdoutJsonEvent.json index 56e79b2f3..0853a9850 100644 --- a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigStdin2StdoutJsonEvent.json +++ b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigStdin2StdoutJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" }, "JAVASCRIPT": { "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" diff --git a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigWs2WsServerJsonEvent.json b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigWs2WsServerJsonEvent.json index 65612b6db..cd621e694 100644 --- a/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigWs2WsServerJsonEvent.json +++ b/examples/examples-myfirstpolicy/src/main/resources/examples/config/MyFirstPolicy/2/MyFirstPolicyConfigWs2WsServerJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" }, "JAVASCRIPT": { "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" @@ -21,7 +21,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 4000 @@ -36,7 +36,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 3000 diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpLogic.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpLogic.java index 651bd9280..e425088ff 100644 --- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpLogic.java +++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpLogic.java @@ -30,7 +30,7 @@ import java.util.Map.Entry; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelFactory; +import org.onap.policy.apex.examples.myfirstpolicy.model.MfpDomainModelFactory; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.policymodel.concepts.AxPolicy; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; @@ -59,7 +59,7 @@ public class TestMfpLogic { */ @Test public void testMfp1TaskLogic() { - final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP1PolicyModel(); + final AxPolicyModel apexPolicyModel = new MfpDomainModelFactory().getMfp1PolicyModel(); assertNotNull(apexPolicyModel); final Map<String, String> logics = new LinkedHashMap<>(); @@ -85,7 +85,7 @@ public class TestMfpLogic { */ @Test public void testMfp1AltTaskLogic() { - final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP1AltPolicyModel(); + final AxPolicyModel apexPolicyModel = new MfpDomainModelFactory().getMfp1AltPolicyModel(); assertNotNull(apexPolicyModel); final Map<String, String> logics = new LinkedHashMap<>(); @@ -110,7 +110,7 @@ public class TestMfpLogic { */ @Test public void testMfp2TaskLogic() { - final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP2PolicyModel(); + final AxPolicyModel apexPolicyModel = new MfpDomainModelFactory().getMfp2PolicyModel(); assertNotNull(apexPolicyModel); final Map<String, String> logics = new LinkedHashMap<>(); diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCli.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCli.java index 0d6b4737c..a63df03bc 100644 --- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCli.java +++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCli.java @@ -27,7 +27,7 @@ import java.io.IOException; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain; +import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; @@ -71,8 +71,8 @@ public class TestMfpModelCli { { "-c", "src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex", "-l", tempLogFile2.getAbsolutePath(), "-o", tempModelFile2.getAbsolutePath() }; - new ApexCLIEditorMain(testApexModel1CliArgs); - new ApexCLIEditorMain(testApexModel2CliArgs); + new ApexCommandLineEditorMain(testApexModel1CliArgs); + new ApexCommandLineEditorMain(testApexModel2CliArgs); final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class); AxPolicyModel generatedmodel = reader.read(TextFileUtils.getTextFileAsString(tempModelFile1.getAbsolutePath())); diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCreator.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCreator.java index ebbdac7c2..d77405d9e 100644 --- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCreator.java +++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpModelCreator.java @@ -20,7 +20,7 @@ package org.onap.policy.apex.examples.myfirstpolicy; -import org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelFactory; +import org.onap.policy.apex.examples.myfirstpolicy.model.MfpDomainModelFactory; import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; @@ -83,7 +83,7 @@ public abstract class TestMfpModelCreator implements TestApexModelCreator<AxPoli */ @Override public AxPolicyModel getModel() { - return new MFPDomainModelFactory().getMFP1PolicyModel(); + return new MfpDomainModelFactory().getMfp1PolicyModel(); } } @@ -99,7 +99,7 @@ public abstract class TestMfpModelCreator implements TestApexModelCreator<AxPoli */ @Override public AxPolicyModel getModel() { - return new MFPDomainModelFactory().getMFP2PolicyModel(); + return new MfpDomainModelFactory().getMfp2PolicyModel(); } } diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpUseCase.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpUseCase.java index ec5d9e0c9..8c95c9fec 100644 --- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpUseCase.java +++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMfpUseCase.java @@ -43,14 +43,14 @@ import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl; import org.onap.policy.apex.core.engine.event.EnEvent; -import org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelFactory; +import org.onap.policy.apex.examples.myfirstpolicy.model.MfpDomainModelFactory; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; import org.onap.policy.apex.model.eventmodel.concepts.AxField; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -75,6 +75,9 @@ public class TestMfpUseCase { private static SchemaParameters schemaParameters; private static EngineParameters engineParameters; + /** + * Before test. + */ @BeforeClass public static void beforeTest() { schemaParameters = new SchemaParameters(); @@ -97,11 +100,14 @@ public class TestMfpUseCase { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters()); ParameterService.register(engineParameters); } + /** + * After test. + */ @AfterClass public static void afterTest() { ParameterService.deregister(engineParameters); @@ -123,7 +129,7 @@ public class TestMfpUseCase { */ @Test public void testMfp1Case() throws ApexException, InterruptedException, IOException { - final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP1PolicyModel(); + final AxPolicyModel apexPolicyModel = new MfpDomainModelFactory().getMfp1PolicyModel(); assertNotNull(apexPolicyModel); final TestSaleAuthListener listener = new TestSaleAuthListener("Test"); @@ -171,7 +177,7 @@ public class TestMfpUseCase { */ @Test public void testMfp2Case() throws ApexException, InterruptedException, IOException { - final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP2PolicyModel(); + final AxPolicyModel apexPolicyModel = new MfpDomainModelFactory().getMfp2PolicyModel(); assertNotNull(apexPolicyModel); final TestSaleAuthListener listener = new TestSaleAuthListener("Test"); diff --git a/examples/examples-onap-vcpe/pom.xml b/examples/examples-onap-vcpe/pom.xml index 3080416b2..b0562b9f9 100644 --- a/examples/examples-onap-vcpe/pom.xml +++ b/examples/examples-onap-vcpe/pom.xml @@ -83,7 +83,7 @@ <goal>java</goal> </goals> <configuration> - <mainClass>org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain</mainClass> + <mainClass>org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain</mainClass> <classpathScope>compile</classpathScope> <arguments> <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.name}.apex</argument> diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSim.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSim.java index f6ae332a8..369e6172c 100644 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSim.java +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSim.java @@ -27,12 +27,18 @@ import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.server.ResourceConfig; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -public class AAIAndGuardSim { +/** + * The Class AaiAndGuardSim. + */ +public class AaiAndGuardSim { private static final String BASE_URI = "http://localhost:54321/AAIAndGuardSim"; private HttpServer server; - public AAIAndGuardSim() { - final ResourceConfig rc = new ResourceConfig(AAIAndGuardSimEndpoint.class); + /** + * Instantiates a new aai and guard sim. + */ + public AaiAndGuardSim() { + final ResourceConfig rc = new ResourceConfig(AaiAndGuardSimEndpoint.class); server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); while (!server.isStarted()) { @@ -40,12 +46,23 @@ public class AAIAndGuardSim { } } + /** + * Tear down. + * + * @throws Exception the exception + */ public void tearDown() throws Exception { server.shutdown(); } + /** + * The main method. + * + * @param args the arguments + * @throws Exception the exception + */ public static void main(final String[] args) throws Exception { - final AAIAndGuardSim sim = new AAIAndGuardSim(); + final AaiAndGuardSim sim = new AaiAndGuardSim(); while (true) { try { diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSimEndpoint.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSimEndpoint.java index 6c7f7db19..e36ef4d11 100644 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSimEndpoint.java +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSimEndpoint.java @@ -34,15 +34,22 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.core.Response; - +/** + * The Class AaiAndGuardSimEndpoint. + */ @Path("/sim") -public class AAIAndGuardSimEndpoint { +public class AaiAndGuardSimEndpoint { private static int postMessagesReceived = 0; private static int putMessagesReceived = 0; private static int statMessagesReceived = 0; private static int getMessagesReceived = 0; + /** + * Service get stats. + * + * @return the response + */ @Path("/pdp/api/Stats") @GET public Response serviceGetStats() { @@ -51,6 +58,12 @@ public class AAIAndGuardSimEndpoint { + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); } + /** + * Service guard post request. + * + * @param jsonString the json string + * @return the response + */ @Path("/pdp/api/getDecision") @POST public Response serviceGuardPostRequest(final String jsonString) { @@ -65,6 +78,11 @@ public class AAIAndGuardSimEndpoint { } } + /** + * Service get event. + * + * @return the response + */ @Path("/event/GetEvent") @GET public Response serviceGetEvent() { @@ -83,18 +101,34 @@ public class AAIAndGuardSimEndpoint { return Response.status(200).entity(eventString).build(); } + /** + * Service get empty event. + * + * @return the response + */ @Path("/event/GetEmptyEvent") @GET public Response serviceGetEmptyEvent() { return Response.status(200).build(); } + /** + * Service get event bad response. + * + * @return the response + */ @Path("/event/GetEventBadResponse") @GET public Response serviceGetEventBadResponse() { return Response.status(400).build(); } + /** + * Service post request. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/PostEvent") @POST public Response servicePostRequest(final String jsonString) { @@ -112,12 +146,24 @@ public class AAIAndGuardSimEndpoint { + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); } + /** + * Service post request bad response. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/PostEventBadResponse") @POST public Response servicePostRequestBadResponse(final String jsonString) { return Response.status(400).build(); } + /** + * Service put request. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/PutEvent") @PUT public Response servicePutRequest(final String jsonString) { diff --git a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java index 001886370..fa8903b62 100644 --- a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java +++ b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java @@ -22,7 +22,7 @@ package org.onap.policy.apex.examples.pcvs.model; import java.io.File; -import org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain; +import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain; import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; @@ -54,7 +54,7 @@ public class PcvsDomainModelFactory { new String[] {"-c", "src/main/resources/org/onap/policy/apex/examples/pcvs/vpnsla/vpnsla.apex", "-wd", workingDirectory, "-o", full}; - final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(args); + final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(args); if (cliEditor.getErrorCount() > 0) { throw new ApexRuntimeException( "Apex CLI editor execution failed with " + cliEditor.getErrorCount() + " errors"); diff --git a/examples/examples-periodic/pom.xml b/examples/examples-periodic/pom.xml index 8894e71d7..fb8d43661 100644 --- a/examples/examples-periodic/pom.xml +++ b/examples/examples-periodic/pom.xml @@ -57,7 +57,7 @@ <goal>java</goal> </goals> <configuration> - <mainClass>org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain</mainClass> + <mainClass>org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain</mainClass> <classpathScope>compile</classpathScope> <arguments> <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.name}.apex</argument> diff --git a/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat index c1f71459e..d00eec363 100644 --- a/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat +++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat @@ -76,7 +76,7 @@ set APEX_APP_MAP[ws-echo]=java -jar %APEX_HOME%\lib\applications\simple-wsclient set APEX_APP_MAP[tpl-event-json]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.tools.model.generator.model2event.Application set APEX_APP_MAP[model-2-cli]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.tools.model.generator.model2cli.Application set APEX_APP_MAP[rest-editor]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-editor-%_VERSION%-editor.jar -set APEX_APP_MAP[cli-editor]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain +set APEX_APP_MAP[cli-editor]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain set APEX_APP_MAP[engine]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.service.engine.main.ApexMain set APEX_APP_MAP[eng-deployment]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-deployment-%_VERSION%-deployment.jar set APEX_APP_MAP[eng-monitoring]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-monitoring-%_VERSION%-monitoring.jar diff --git a/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh index 246906b56..0bd5995bc 100755 --- a/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh +++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh @@ -85,7 +85,7 @@ APEX_APP_MAP["ws-echo"]="java -jar $APEX_HOME/lib/applications/simple-wsclient-$ APEX_APP_MAP["tpl-event-json"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -cp ${CLASSPATH} $_config org.onap.policy.apex.tools.model.generator.model2event.Application" APEX_APP_MAP["model-2-cli"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -cp ${CLASSPATH} $_config org.onap.policy.apex.tools.model.generator.model2cli.Application" APEX_APP_MAP["rest-editor"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -jar $APEX_HOME/lib/applications/client-editor-$_version-editor.jar" -APEX_APP_MAP["cli-editor"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -cp ${CLASSPATH} $_config org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain" +APEX_APP_MAP["cli-editor"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -cp ${CLASSPATH} $_config org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain" APEX_APP_MAP["engine"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -cp ${CLASSPATH} $_config org.onap.policy.apex.service.engine.main.ApexMain" APEX_APP_MAP["eng-deployment"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -jar $APEX_HOME/lib/applications/client-deployment-$_version-deployment.jar" APEX_APP_MAP["eng-monitoring"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -jar $APEX_HOME/lib/applications/client-monitoring-$_version-monitoring.jar" diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java index 9d35c30a8..123d834ff 100644 --- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributor.java @@ -20,6 +20,9 @@ package org.onap.policy.apex.plugins.context.distribution.hazelcast; +import com.hazelcast.core.Hazelcast; +import com.hazelcast.core.HazelcastInstance; + import java.util.Map; import org.onap.policy.apex.context.ContextException; @@ -28,9 +31,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; - /** * This context distributor distributes context across threads in multiple JVMs on multiple hosts. * It uses hazelcast to distribute maps. @@ -70,12 +70,20 @@ public class HazelcastContextDistributor extends AbstractDistributor { // Create the hazelcast instance if it does not already exist if (hazelcastInstance == null) { - hazelcastInstance = Hazelcast.newHazelcastInstance(); + setHazelcastInstance(Hazelcast.newHazelcastInstance()); } LOGGER.exit("init(" + key + ")"); } + /** + * Set the hazelcast instance statically. + * @param newHazelcastInstance the hazelcast instance + */ + private static void setHazelcastInstance(HazelcastInstance newHazelcastInstance) { + hazelcastInstance = newHazelcastInstance; + } + /* * (non-Javadoc) * @@ -101,6 +109,6 @@ public class HazelcastContextDistributor extends AbstractDistributor { if (hazelcastInstance != null) { hazelcastInstance.shutdown(); } - hazelcastInstance = null; + setHazelcastInstance(null); } } diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java index c3c137349..9d7f003ee 100644 --- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java @@ -38,6 +38,9 @@ import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * The Class HazelcastContextDistributorTest. + */ public class HazelcastContextDistributorTest { private static final String HAZEL_CAST_PLUGIN_CLASS = HazelcastContextDistributor.class.getCanonicalName(); // Logger for this class @@ -46,6 +49,9 @@ public class HazelcastContextDistributorTest { private SchemaParameters schemaParameters; private ContextParameters contextParameters; + /** + * Before test. + */ @Before public void beforeTest() { contextParameters = new ContextParameters(); @@ -69,6 +75,9 @@ public class HazelcastContextDistributorTest { ParameterService.register(schemaParameters); } + /** + * After test. + */ @After public void afterTest() { ParameterService.deregister(schemaParameters); @@ -78,6 +87,14 @@ public class HazelcastContextDistributorTest { ParameterService.deregister(contextParameters.getPersistorParameters()); ParameterService.deregister(contextParameters); } + + /** + * Test context album update hazelcast. + * + * @throws ApexModelException the apex model exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception + */ @Test public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextAlbumUpdateHazelcast test . . ."); @@ -87,6 +104,13 @@ public class HazelcastContextDistributorTest { logger.debug("Ran testContextAlbumUpdateHazelcast test"); } + /** + * Test context instantiation hazelcast. + * + * @throws ApexModelException the apex model exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception + */ @Test public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextInstantiationHazelcast test . . ."); @@ -96,6 +120,13 @@ public class HazelcastContextDistributorTest { logger.debug("Ran testContextInstantiationHazelcast test"); } + /** + * Test context update hazelcast. + * + * @throws ApexModelException the apex model exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception + */ @Test public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextUpdateHazelcast test . . ."); diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java index c8b1cedce..e11f3da8b 100644 --- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java @@ -22,7 +22,6 @@ package org.onap.policy.apex.plugins.context.distribution.infinispan; import java.util.Map; -import org.infinispan.Cache; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.context.impl.distribution.AbstractDistributor; import org.onap.policy.apex.context.parameters.ContextParameterConstants; @@ -32,8 +31,8 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * This context distributor distributes context across threads in multiple JVMs on multiple hosts. - * It uses Infinispan to distribute maps. + * This context distributor distributes context across threads in multiple JVMs on multiple hosts. It uses Infinispan to + * distribute maps. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -58,8 +57,7 @@ public class InfinispanContextDistributor extends AbstractDistributor { /* * (non-Javadoc) * - * @see - * org.onap.policy.apex.context.impl.distribution.AbstractContextDistributor#init(org.onap.policy.apex + * @see org.onap.policy.apex.context.impl.distribution.AbstractContextDistributor#init(org.onap.policy.apex * .model.basicmodel.concepts.AxArtifactKey) */ @Override @@ -71,18 +69,26 @@ public class InfinispanContextDistributor extends AbstractDistributor { // Create the infinispan manager if it does not already exist if (infinispanManager == null) { // Get the parameters from the parameter service - final InfinispanDistributorParameters parameters = - ParameterService.get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); + final InfinispanDistributorParameters parameters = ParameterService + .get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME); - LOGGER.debug("initiating Infinispan with the parameters: " + parameters); + LOGGER.debug("initiating Infinispan with the parameters: {}", parameters); // Create the manager - infinispanManager = new InfinispanManager(parameters); + setInfinispanManager(new InfinispanManager(parameters)); } LOGGER.exit("init(" + key + ")"); } + /** + * Set the infinispan manager statically. + * @param newInfinispanManager the new infinspan manager instance + */ + private static void setInfinispanManager(InfinispanManager newInfinispanManager) { + infinispanManager = newInfinispanManager; + } + /* * (non-Javadoc) * @@ -94,10 +100,7 @@ public class InfinispanContextDistributor extends AbstractDistributor { LOGGER.info("InfinispanContextDistributor: create album: " + contextAlbumKey.getId()); // Get the Cache from Infinispan - final Cache<String, Object> infinispanCache = - infinispanManager.getCacheManager().getCache(contextAlbumKey.getId().replace(':', '_')); - - return infinispanCache; + return infinispanManager.getCacheManager().getCache(contextAlbumKey.getId().replace(':', '_')); } /* @@ -111,6 +114,6 @@ public class InfinispanContextDistributor extends AbstractDistributor { if (infinispanManager != null) { infinispanManager.shutdown(); } - infinispanManager = null; + setInfinispanManager(null); } } diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java index 16fdd85ac..1993d21de 100644 --- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java @@ -46,7 +46,7 @@ public class InfinispanDistributorParameters extends DistributorParameters { private String configFile = DEFAULT_INFINISPAN_DISTRIBUTION_CONFIG_FILE; private String jgroupsFile = DEFAULT_INFINISPAN_DISTRIBUTION_JGROUPS_FILE; private boolean preferIPv4Stack = DEFAULT_INFINISPAN_JAVA_NET_PREFER_IPV4_STACK; - private String jGroupsBindAddress = DEFAULT_INFINSPAN_JGROUPS_BIND_ADDRESS; + private String jgroupsBindAddress = DEFAULT_INFINSPAN_JGROUPS_BIND_ADDRESS; // @formatter:on /** @@ -116,16 +116,16 @@ public class InfinispanDistributorParameters extends DistributorParameters { * @return the j groups bind address */ public String getjGroupsBindAddress() { - return jGroupsBindAddress; + return jgroupsBindAddress; } /** * Setj groups bind address. * - * @param jGroupsBindAddress the j groups bind address + * @param jgroupsBindAddress the j groups bind address */ - public void setjGroupsBindAddress(final String jGroupsBindAddress) { - this.jGroupsBindAddress = jGroupsBindAddress; + public void setjGroupsBindAddress(final String jgroupsBindAddress) { + this.jgroupsBindAddress = jgroupsBindAddress; } /* @@ -136,6 +136,6 @@ public class InfinispanDistributorParameters extends DistributorParameters { @Override public String toString() { return "InfinispanDistributorParameters [configFile=" + configFile + ", jgroupsFile=" + jgroupsFile - + ", preferIPv4Stack=" + preferIPv4Stack + ", jGroupsBindAddress=" + jGroupsBindAddress + "]"; + + ", preferIPv4Stack=" + preferIPv4Stack + ", jGroupsBindAddress=" + jgroupsBindAddress + "]"; } } diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java index 1a2076f10..843a6b971 100644 --- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanManager.java @@ -45,7 +45,7 @@ public class InfinispanManager { * @throws ContextException On errors connecting to Infinispan */ public InfinispanManager(final InfinispanDistributorParameters infinispanDistributorParameters) - throws ContextException { + throws ContextException { LOGGER.entry("Creating Infinispan Manager: " + infinispanDistributorParameters); setSystemProperties(infinispanDistributorParameters); @@ -55,8 +55,8 @@ public class InfinispanManager { cacheManager = new DefaultCacheManager(infinispanDistributorParameters.getConfigFile()); LOGGER.debug("started infinispan cache manager using specified configuration"); } catch (final IOException ioException) { - final String errorMessage = - "failed to start infinispan cache manager, no infinispan configuration found on local file system or in classpath, " + final String errorMessage = "failed to start infinispan cache manager, " + + "no infinispan configuration found on local file system or in classpath, " + "try setting Infinspan \"configFile\" parameter"; LOGGER.error(errorMessage); throw new ContextException(errorMessage, ioException); @@ -101,7 +101,7 @@ public class InfinispanManager { */ private void setSystemProperties(final InfinispanDistributorParameters infinispanDistributorParameters) { System.setProperty("java.net.preferIPv4Stack", - Boolean.toString(infinispanDistributorParameters.preferIPv4Stack())); + Boolean.toString(infinispanDistributorParameters.preferIPv4Stack())); System.setProperty("jgroups.bind_addr", infinispanDistributorParameters.getjGroupsBindAddress()); } diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java index 862dcef83..3da1cf509 100644 --- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java +++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java @@ -17,6 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ + package org.onap.policy.apex.plugins.context.distribution.infinispan; import java.io.IOException; @@ -38,6 +39,9 @@ import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +/** + * The Class InfinispanContextDistributorTest. + */ public class InfinispanContextDistributorTest { private static final XLogger logger = XLoggerFactory.getXLogger(InfinispanContextDistributorTest.class); @@ -46,6 +50,9 @@ public class InfinispanContextDistributorTest { private SchemaParameters schemaParameters; private ContextParameters contextParameters; + /** + * Before test. + */ @Before public void beforeTest() { contextParameters = new ContextParameters(); @@ -70,6 +77,9 @@ public class InfinispanContextDistributorTest { ParameterService.register(schemaParameters); } + /** + * After test. + */ @After public void afterTest() { ParameterService.deregister(schemaParameters); @@ -80,6 +90,13 @@ public class InfinispanContextDistributorTest { ParameterService.deregister(contextParameters); } + /** + * Test context album update infinispan. + * + * @throws ApexModelException the apex model exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception + */ @Test public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextAlbumUpdateInfinispan test . . ."); @@ -89,6 +106,13 @@ public class InfinispanContextDistributorTest { logger.debug("Ran testContextAlbumUpdateInfinispan test"); } + /** + * Test context instantiation infinispan. + * + * @throws ApexModelException the apex model exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception + */ @Test public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextInstantiationInfinispan test . . ."); @@ -98,6 +122,13 @@ public class InfinispanContextDistributorTest { logger.debug("Ran testContextInstantiationInfinispan test"); } + /** + * Test context update infinispan. + * + * @throws ApexModelException the apex model exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception + */ @Test public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException { logger.debug("Running testContextUpdateInfinispan test . . ."); @@ -107,6 +138,13 @@ public class InfinispanContextDistributorTest { logger.debug("Ran testContextUpdateInfinispan test"); } + /** + * Test sequential context instantiation infinispan. + * + * @throws ApexModelException the apex model exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception + */ @Test public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException { logger.debug("Running testSequentialContextInstantiationInfinispan test . . ."); diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java index 928255031..4e6ab71a4 100644 --- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java +++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockFacade.java @@ -37,6 +37,9 @@ public class CuratorLockFacade implements Lock { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(CuratorLockFacade.class); + // Recurring string constants + private static final String FAILED_TO_ACQUIRE_LOCK_TAG = "failed to acquire lock for \"{}\""; + // The Lock ID private final String lockId; @@ -64,7 +67,7 @@ public class CuratorLockFacade implements Lock { try { lockMutex.acquire(); } catch (final Exception e) { - LOGGER.warn("failed to acquire lock for \"" + lockId, e); + LOGGER.warn(FAILED_TO_ACQUIRE_LOCK_TAG, lockId, e); } } @@ -75,7 +78,7 @@ public class CuratorLockFacade implements Lock { */ @Override public void lockInterruptibly() throws InterruptedException { - LOGGER.warn("lockInterruptibly() not supported for \"" + lockId); + LOGGER.warn("lockInterruptibly() not supported for \"{}\"", lockId); } /* @@ -131,7 +134,7 @@ public class CuratorLockFacade implements Lock { */ @Override public Condition newCondition() { - LOGGER.warn("newCondition() not supported for \"" + lockId); + LOGGER.warn("newCondition() not supported for \"{} \"", lockId); return null; } } diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java index d2976d799..bc8ce9055 100644 --- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java +++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java @@ -81,9 +81,10 @@ public class CuratorLockManager extends AbstractLockManager { // Check if the curator address has been set curatorZookeeperAddress = lockParameters.getZookeeperAddress(); if (curatorZookeeperAddress == null || curatorZookeeperAddress.trim().length() == 0) { - LOGGER.warn("could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly"); - throw new ContextException( - "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly"); + String message = "could not set up Curator locking, " + + "check if the curator Zookeeper address parameter is set correctly"; + LOGGER.warn(message); + throw new ContextException(message); } // Set up the curator framework we'll use diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java index 22bf5e596..5a24fb701 100644 --- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java +++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorReentrantReadWriteLock.java @@ -33,7 +33,7 @@ import org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock; */ public class CuratorReentrantReadWriteLock implements ReadWriteLock { // The Lock ID - private final String lockID; + private final String lockId; // The Curator lock private final InterProcessReadWriteLock curatorReadWriteLock; @@ -49,7 +49,7 @@ public class CuratorReentrantReadWriteLock implements ReadWriteLock { * @param lockId The unique ID of the lock. */ public CuratorReentrantReadWriteLock(final CuratorFramework curatorFramework, final String lockId) { - lockID = lockId; + this.lockId = lockId; // Create the Curator lock curatorReadWriteLock = new InterProcessReadWriteLock(curatorFramework, lockId); @@ -64,8 +64,8 @@ public class CuratorReentrantReadWriteLock implements ReadWriteLock { * * @return the lock ID */ - public String getLockID() { - return lockID; + public String getLockId() { + return lockId; } /* diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java index 73678ad2a..9d4a5ca8f 100644 --- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java +++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLock.java @@ -20,12 +20,12 @@ package org.onap.policy.apex.plugins.context.locking.hazelcast; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReadWriteLock; - import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.ILock; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; + /** * This class maps a Hazelcast {@link ILock} to a Java {@link ReadWriteLock}. * @@ -33,7 +33,7 @@ import com.hazelcast.core.ILock; */ public class HazelcastLock implements ReadWriteLock { // The Lock ID - private final String lockID; + private final String lockId; // The hazelcast lock private final ILock readLock; @@ -46,7 +46,7 @@ public class HazelcastLock implements ReadWriteLock { * @param lockId The unique ID of the lock. */ public HazelcastLock(final HazelcastInstance hazelcastInstance, final String lockId) { - lockID = lockId; + this.lockId = lockId; // Create the Hazelcast read and write locks readLock = hazelcastInstance.getLock(lockId + "_READ"); @@ -58,8 +58,8 @@ public class HazelcastLock implements ReadWriteLock { * * @return the lock ID */ - public String getLockID() { - return lockID; + public String getLockId() { + return lockId; } /* diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java index 34258bf24..4994cf7f5 100644 --- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java +++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-hazelcast/src/main/java/org/onap/policy/apex/plugins/context/locking/hazelcast/HazelcastLockManager.java @@ -20,6 +20,9 @@ package org.onap.policy.apex.plugins.context.locking.hazelcast; +import com.hazelcast.core.Hazelcast; +import com.hazelcast.core.HazelcastInstance; + import java.util.concurrent.locks.ReadWriteLock; import org.onap.policy.apex.context.ContextException; @@ -28,9 +31,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; - /** * The Class HazelcastLockManager manages Hazelcast locks for locks on items in Apex context albums. * diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java index 20e701bc7..bee2f5957 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java @@ -43,7 +43,7 @@ public class AvroBytesObjectMapper implements AvroObjectMapper { private Type avroType; // The Apex compatible class - private final Class<Byte[]> schemaClass = Byte[].class; + private static final Class<Byte[]> schemaClass = Byte[].class; /* * (non-Javadoc) @@ -142,8 +142,6 @@ public class AvroBytesObjectMapper implements AvroObjectMapper { } // Create a ByteBuffer object to serialize the bytes - final ByteBuffer byteBuffer = ByteBuffer.wrap((byte[]) object); - - return byteBuffer; + return ByteBuffer.wrap((byte[]) object); } } diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java index 35e811dec..ca771d957 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java @@ -132,7 +132,7 @@ public class AvroDirectObjectMapper implements AvroObjectMapper { // the decoded object is always returned as a null if (!schemaClass.isAssignableFrom(avroObject.getClass())) { final String returnString = - userKey.getId() + ": object \"" + avroObject + "\" of class \"" + avroObject.getClass() + userKey.getId() + ": object \"" + avroObject + "\" of class \"" + avroObject.getClass() + "\" cannot be decoded to an object of class \"" + schemaClass.getCanonicalName() + "\""; LOGGER.warn(returnString); throw new ContextRuntimeException(returnString); @@ -150,13 +150,11 @@ public class AvroDirectObjectMapper implements AvroObjectMapper { @Override public Object mapToAvro(final Object object) { // Null values are only allowed if the schema class is null - if (object == null) { - if (schemaClass != null) { - final String returnString = userKey.getId() + ": cannot encode a null object of class \"" - + schemaClass.getCanonicalName() + "\""; - LOGGER.warn(returnString); - throw new ContextRuntimeException(returnString); - } + if (object == null && schemaClass != null) { + final String returnString = userKey.getId() + ": cannot encode a null object of class \"" + + schemaClass.getCanonicalName() + "\""; + LOGGER.warn(returnString); + throw new ContextRuntimeException(returnString); } // For direct mappings, just work directly with the Java objects diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java index a48ca8089..21e4d76a8 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java @@ -75,12 +75,12 @@ public class AvroObjectMapperFactory { if (Schema.Type.UNION.equals(schema.getType())) { final List<Schema> types = schema.getTypes(); - // TODO: properly support UNIONS + // currently only support unions with 2 types, one of which is NULL final Schema nullschema = Schema.create(Schema.Type.NULL); if (types.size() != 2 || !types.contains(nullschema)) { final String resultSting = userKey.getId() - + ": Apex currently only supports UNION schemas with 2 options, one must be NULL"; + + ": Apex currently only supports UNION schemas with 2 options, one must be NULL"; LOGGER.warn(resultSting); throw new ContextRuntimeException(resultSting); } @@ -92,7 +92,8 @@ public class AvroObjectMapperFactory { } if (Schema.Type.NULL.equals(schema.getType())) { final String resultSting = userKey.getId() - + ": Apex currently only supports UNION schema2 with 2 options, only one can be NULL, and the other cannot be another UNION"; + + ": Apex currently only supports UNION schema2 with 2 options, " + + "only one can be NULL, and the other cannot be another UNION"; LOGGER.warn(resultSting); throw new ContextRuntimeException(resultSting); } @@ -102,8 +103,8 @@ public class AvroObjectMapperFactory { // Check that there is a definition for the mapper for this type if (!AVRO_OBJECT_MAPPER_MAP.containsKey(avroType) || AVRO_OBJECT_MAPPER_MAP.get(avroType) == null) { - final String resultSting = - userKey.getId() + ": no Avro object mapper defined for Avro type \"" + avroType + "\""; + final String resultSting = userKey.getId() + ": no Avro object mapper defined for Avro type \"" + avroType + + "\""; LOGGER.warn(resultSting); throw new ContextRuntimeException(resultSting); } @@ -118,7 +119,7 @@ public class AvroObjectMapperFactory { } catch (final Exception e) { final String resultSting = userKey.getId() + ": could not create an Avro object mapper of type \"" - + AVRO_OBJECT_MAPPER_MAP.get(avroType) + "\" for Avro type \"" + avroType + "\" : " + e; + + AVRO_OBJECT_MAPPER_MAP.get(avroType) + "\" for Avro type \"" + avroType + "\" : " + e; LOGGER.warn(resultSting, e); throw new ContextRuntimeException(resultSting, e); } diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java index df430b683..9cdb5845b 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java @@ -20,6 +20,10 @@ package org.onap.policy.apex.plugins.context.schema.avro; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; + import java.io.ByteArrayOutputStream; import org.apache.avro.Schema; @@ -38,13 +42,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; - /** - * This class is the implementation of the {@link org.onap.policy.apex.context.SchemaHelper} - * interface for Avro schemas. + * This class is the implementation of the {@link org.onap.policy.apex.context.SchemaHelper} interface for Avro schemas. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -52,6 +51,9 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { // Get a reference to the logger private static final XLogger LOGGER = XLoggerFactory.getXLogger(AvroSchemaHelper.class); + // Recurring string constants + private static final String OBJECT_TAG = ": object \""; + // The Avro schema for this context schema private Schema avroSchema; @@ -59,7 +61,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { private AvroObjectMapper avroObjectMapper; @Override - public void init(final AxKey userKey, final AxContextSchema schema) throws ContextRuntimeException { + public void init(final AxKey userKey, final AxContextSchema schema) { super.init(userKey, schema); // Configure the Avro schema @@ -67,7 +69,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { avroSchema = new Schema.Parser().parse(schema.getSchema()); } catch (final Exception e) { final String resultSting = userKey.getId() + ": avro context schema \"" + schema.getId() - + "\" schema is invalid: " + e.getMessage() + ", schema: " + schema.getSchema(); + + "\" schema is invalid: " + e.getMessage() + ", schema: " + schema.getSchema(); LOGGER.warn(resultSting); throw new ContextRuntimeException(resultSting); } @@ -91,7 +93,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { @Override public Object getSchemaObject() { - return avroSchema; + return getAvroSchema(); } @Override @@ -119,10 +121,9 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { final String elementJsonString = gson.toJson((JsonElement) incomingObject); return createNewInstance(elementJsonString); - } - else { + } else { final String returnString = getUserKey().getId() + ": the object \"" + incomingObject - + "\" is not an instance of JsonObject"; + + "\" is not an instance of JsonObject"; LOGGER.warn(returnString); throw new ContextRuntimeException(returnString); } @@ -146,8 +147,8 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { final JsonDecoder jsonDecoder = DecoderFactory.get().jsonDecoder(avroSchema, objectString); decodedObject = new GenericDatumReader<GenericRecord>(avroSchema).read(null, jsonDecoder); } catch (final Exception e) { - final String returnString = getUserKey().getId() + ": object \"" + objectString - + "\" Avro unmarshalling failed: " + e.getMessage(); + final String returnString = getUserKey().getId() + OBJECT_TAG + objectString + + "\" Avro unmarshalling failed: " + e.getMessage(); LOGGER.warn(returnString, e); throw new ContextRuntimeException(returnString, e); } @@ -157,8 +158,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { } /** - * Check that the incoming object is a string, the incoming object must be a string containing - * Json + * Check that the incoming object is a string, the incoming object must be a string containing Json. * * @param object incoming object * @return object as String @@ -185,10 +185,10 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { return (String) object; } } catch (final ClassCastException e) { - final String returnString = getUserKey().getId() + ": object \"" + object + "\" of type \"" - + (object != null ? object.getClass().getCanonicalName() : "null") + "\" must be assignable to \"" - + getSchemaClass().getCanonicalName() - + "\" or be a Json string representation of it for Avro unmarshalling"; + final String returnString = getUserKey().getId() + OBJECT_TAG + object + "\" of type \"" + + (object != null ? object.getClass().getCanonicalName() : "null") + + "\" must be assignable to \"" + getSchemaClass().getCanonicalName() + + "\" or be a Json string representation of it for Avro unmarshalling"; LOGGER.warn(returnString); throw new ContextRuntimeException(returnString); } @@ -217,8 +217,8 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { jsonEncoder.flush(); return new String(output.toByteArray()); } catch (final Exception e) { - final String returnString = - getUserKey().getId() + ": object \"" + object + "\" Avro marshalling failed: " + e.getMessage(); + final String returnString = getUserKey().getId() + OBJECT_TAG + object + "\" Avro marshalling failed: " + + e.getMessage(); LOGGER.warn(returnString); throw new ContextRuntimeException(returnString, e); } @@ -239,8 +239,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper { } /** - * Check if we can pass this object straight through encoding or decoding, is it an object - * native to the schema. + * Check if we can pass this object straight through encoding or decoding, is it an object native to the schema. * * @param object the object to check * @return true if it's a straight pass through diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java index dc3770a43..b4c8737dd 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java @@ -20,13 +20,13 @@ package org.onap.policy.apex.plugins.context.schema.avro; -import java.util.Map.Entry; - import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import java.util.Map.Entry; + /** * This static final class contains utility methods for Avro schemas. * diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java index 09d1d9f1f..a9acb1c12 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java @@ -42,7 +42,7 @@ public class AvroStringObjectMapper implements AvroObjectMapper { private Type avroType; // The Apex compatible class - private final Class<String> schemaClass = String.class; + private static final Class<String> schemaClass = String.class; /* * (non-Javadoc) diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAai.java index 5198e82e0..bca896d2e 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAai.java @@ -42,14 +42,21 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestAvroSchemaAai. + * * @author Liam Fallon (liam.fallon@ericsson.com) - * @version + * @version */ -public class TestAvroSchemaAAI { +public class TestAvroSchemaAai { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); private AxContextSchemas schemas; private String aaiInventoryResponseSchema; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); @@ -59,6 +66,9 @@ public class TestAvroSchemaAAI { TextFileUtils.getTextFileAsString("src/test/resources/avsc/AAIInventoryResponseItemType.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); @@ -68,13 +78,21 @@ public class TestAvroSchemaAAI { } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test AAI response policy. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testAAIResponsePolicy() throws IOException { + public void testAaiResponsePolicy() throws IOException { final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", aaiInventoryResponseSchema); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java index b72b2ca10..972e0bd32 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java @@ -40,9 +40,12 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; +// TODO: Auto-generated Javadoc /** + * The Class TestAvroSchemaArray. + * * @author Liam Fallon (liam.fallon@ericsson.com) - * @version + * @version */ public class TestAvroSchemaArray { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); @@ -50,6 +53,11 @@ public class TestAvroSchemaArray { private String longArraySchema; private String addressArraySchema; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); @@ -58,6 +66,9 @@ public class TestAvroSchemaArray { addressArraySchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/ArrayExampleAddress.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); @@ -67,11 +78,19 @@ public class TestAvroSchemaArray { } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test array init. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testArrayInit() throws IOException { final AxContextSchema avroSchema = @@ -90,6 +109,11 @@ public class TestAvroSchemaArray { newArrayFull.get(0).toString()); } + /** + * Test long array unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testLongArrayUnmarshalMarshal() throws IOException { final AxContextSchema avroSchema = @@ -102,6 +126,11 @@ public class TestAvroSchemaArray { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/ArrayExampleLongFull.json"); } + /** + * Test address array unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testAddressArrayUnmarshalMarshal() throws IOException { final AxContextSchema avroSchema = @@ -114,6 +143,13 @@ public class TestAvroSchemaArray { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/ArrayExampleAddressFull.json"); } + /** + * Test unmarshal marshal. + * + * @param schemaHelper the schema helper + * @param fileName the file name + * @throws IOException Signals that an I/O exception has occurred. + */ private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException { final String inString = TextFileUtils.getTextFileAsString(fileName); final Array<?> schemaObject = (Array<?>) schemaHelper.unmarshal(inString); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java index 47a5c969c..883f14bcb 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java @@ -41,15 +41,23 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; +// TODO: Auto-generated Javadoc /** + * The Class TestAvroSchemaEnum. + * * @author Liam Fallon (liam.fallon@ericsson.com) - * @version + * @version */ public class TestAvroSchemaEnum { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); private AxContextSchemas schemas; private String enumSchema; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); @@ -57,6 +65,9 @@ public class TestAvroSchemaEnum { enumSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/EnumSchema.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); @@ -66,11 +77,19 @@ public class TestAvroSchemaEnum { } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test enum init. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testEnumInit() throws IOException { final AxContextSchema avroSchema = @@ -86,6 +105,11 @@ public class TestAvroSchemaEnum { assertEquals("HEARTS", newEnumFull.toString()); } + /** + * Test enum unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testEnumUnmarshalMarshal() throws IOException { final AxContextSchema avroSchema = @@ -127,6 +151,13 @@ public class TestAvroSchemaEnum { } } + /** + * Test unmarshal marshal. + * + * @param schemaHelper the schema helper + * @param fileName the file name + * @throws IOException Signals that an I/O exception has occurred. + */ private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException { final String inString = TextFileUtils.getTextFileAsString(fileName); final EnumSymbol decodedObject = (EnumSymbol) schemaHelper.unmarshal(inString); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java index 6d709645f..26f4ba8af 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java @@ -43,6 +43,8 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestAvroSchemaFixed. + * * @author Liam Fallon (liam.fallon@ericsson.com) * @version */ @@ -51,6 +53,11 @@ public class TestAvroSchemaFixed { private AxContextSchemas schemas; private String fixedSchema; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); @@ -58,24 +65,35 @@ public class TestAvroSchemaFixed { fixedSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/FixedSchema.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters()); ParameterService.register(schemaParameters); - + } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test fixed init. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFixedInit() throws IOException { - final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", fixedSchema); + final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", + fixedSchema); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); @@ -84,9 +102,9 @@ public class TestAvroSchemaFixed { schemaHelper.createNewInstance(); fail("Test should throw an exception here"); } catch (final Exception e) { - assertEquals( - "AvroTest:0.0.1: could not create an instance of class \"org.apache.avro.generic.GenericData.Fixed\" using the default constructor \"Fixed()\"", - e.getMessage()); + assertEquals("AvroTest:0.0.1: could not create an instance " + + "of class \"org.apache.avro.generic.GenericData.Fixed\" " + + "using the default constructor \"Fixed()\"", e.getMessage()); } final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/FixedExampleGood.json"); @@ -95,10 +113,15 @@ public class TestAvroSchemaFixed { assertTrue(newFixedFull.toString().endsWith("53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70]")); } + /** + * Test fixed unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFixedUnmarshalMarshal() throws IOException { - final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", fixedSchema); + final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", + fixedSchema); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); @@ -110,33 +133,39 @@ public class TestAvroSchemaFixed { fail("This test should throw an exception here"); } catch (final Exception e) { assertEquals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: Expected fixed. Got VALUE_NULL", - e.getMessage()); + e.getMessage()); } try { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/FixedExampleNull.json"); fail("This test should throw an exception here"); } catch (final Exception e) { assertEquals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: Expected fixed. Got VALUE_NULL", - e.getMessage()); + e.getMessage()); } try { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/FixedExampleBad0.json"); fail("This test should throw an exception here"); } catch (final Exception e) { - assertEquals( - "AvroTest:0.0.1: object \"\"BADBAD\"\" Avro unmarshalling failed: Expected fixed length 64, but got6", - e.getMessage()); + assertEquals("AvroTest:0.0.1: object \"\"BADBAD\"\" " + + "Avro unmarshalling failed: Expected fixed length 64, but got6", e.getMessage()); } try { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/FixedExampleBad1.json"); fail("This test should throw an exception here"); } catch (final Exception e) { - assertEquals( - "AvroTest:0.0.1: object \"\"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0\"\" Avro unmarshalling failed: Expected fixed length 64, but got65", - e.getMessage()); + assertEquals("AvroTest:0.0.1: object " + + "\"\"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0\"\" " + + "Avro unmarshalling failed: Expected fixed length 64, but got65", e.getMessage()); } } + /** + * Test unmarshal marshal. + * + * @param schemaHelper the schema helper + * @param fileName the file name + * @throws IOException Signals that an I/O exception has occurred. + */ private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException { final String inString = TextFileUtils.getTextFileAsString(fileName); final Fixed decodedObject = (Fixed) schemaHelper.unmarshal(inString); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java index 9cb027acf..cc79f9eb6 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java @@ -37,19 +37,27 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestAvroSchemaHelperBadSchemas. + * * @author Liam Fallon (liam.fallon@ericsson.com) - * @version + * @version */ public class TestAvroSchemaHelperBadSchemas { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); private AxContextSchemas schemas; + /** + * Inits the test. + */ @Before public void initTest() { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); ModelService.registerModel(AxContextSchemas.class, schemas); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); @@ -59,11 +67,17 @@ public class TestAvroSchemaHelperBadSchemas { } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Bad schema test. + */ @Test public void badSchemaTest() { final AxContextSchema avroBadSchema0 = new AxContextSchema(new AxArtifactKey("AvroBad0", "0.0.1"), "AVRO", "}"); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java index 1f078879d..86d8426de 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java @@ -39,6 +39,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestAvroSchemaHelperMarshal. + * * @author Liam Fallon (liam.fallon@ericsson.com) * @version */ @@ -46,48 +48,63 @@ public class TestAvroSchemaHelperMarshal { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); private AxContextSchemas schemas; + /** + * Inits the test. + */ @Before public void initTest() { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); ModelService.registerModel(AxContextSchemas.class, schemas); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters()); ParameterService.register(schemaParameters); - + } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test null marshal. + */ @Test public void testNullMarshal() { - final AxContextSchema avroNullSchema = - new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", "{\"type\": \"null\"}"); + final AxContextSchema avroNullSchema = new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", + "{\"type\": \"null\"}"); schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema); - final SchemaHelper schemaHelper0 = - new SchemaHelperFactory().createSchemaHelper(testKey, avroNullSchema.getKey()); + final SchemaHelper schemaHelper0 = new SchemaHelperFactory().createSchemaHelper(testKey, + avroNullSchema.getKey()); assertEquals("null", schemaHelper0.marshal2String(null)); assertEquals("null", schemaHelper0.marshal2String(123)); assertEquals("null", schemaHelper0.marshal2String("Everything is marshalled to Null, no matter what it is")); } + /** + * Test boolean marshal. + */ @Test public void testBooleanMarshal() { - final AxContextSchema avroBooleanSchema = - new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", "{\"type\": \"boolean\"}"); + final AxContextSchema avroBooleanSchema = new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", + "{\"type\": \"boolean\"}"); schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema); - final SchemaHelper schemaHelper1 = - new SchemaHelperFactory().createSchemaHelper(testKey, avroBooleanSchema.getKey()); + final SchemaHelper schemaHelper1 = new SchemaHelperFactory().createSchemaHelper(testKey, + avroBooleanSchema.getKey()); assertEquals("true", schemaHelper1.marshal2String(true)); assertEquals("false", schemaHelper1.marshal2String(false)); @@ -96,29 +113,30 @@ public class TestAvroSchemaHelperMarshal { fail("Test should throw an exception here"); } catch (final Exception e) { e.printStackTrace(); - assertEquals( - "AvroTest:0.0.1: object \"0\" Avro marshalling failed: java.lang.Integer cannot be cast to java.lang.Boolean", - e.getMessage()); + assertEquals("AvroTest:0.0.1: object \"0\" Avro marshalling failed: " + + "java.lang.Integer cannot be cast to java.lang.Boolean", e.getMessage()); } try { schemaHelper1.marshal2String("0"); fail("Test should throw an exception here"); } catch (final Exception e) { e.printStackTrace(); - assertEquals( - "AvroTest:0.0.1: object \"0\" Avro marshalling failed: java.lang.String cannot be cast to java.lang.Boolean", - e.getMessage()); + assertEquals("AvroTest:0.0.1: object \"0\" Avro marshalling failed: " + + "java.lang.String cannot be cast to java.lang.Boolean", e.getMessage()); } } + /** + * Test int marshal. + */ @Test public void testIntMarshal() { - final AxContextSchema avroIntSchema = - new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", "{\"type\": \"int\"}"); + final AxContextSchema avroIntSchema = new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", + "{\"type\": \"int\"}"); schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema); - final SchemaHelper schemaHelper2 = - new SchemaHelperFactory().createSchemaHelper(testKey, avroIntSchema.getKey()); + final SchemaHelper schemaHelper2 = new SchemaHelperFactory().createSchemaHelper(testKey, + avroIntSchema.getKey()); assertEquals("0", schemaHelper2.marshal2String(0)); assertEquals("1", schemaHelper2.marshal2String(1)); @@ -131,26 +149,29 @@ public class TestAvroSchemaHelperMarshal { schemaHelper2.marshal2String("Hello"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: java.lang.String cannot be cast to java.lang.Number")); + assertTrue(e.getMessage().startsWith("AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: " + + "java.lang.String cannot be cast to java.lang.Number")); } try { schemaHelper2.marshal2String(null); fail("Test should throw an exception here"); } catch (final Exception e) { assertTrue(e.getMessage() - .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Integer\"")); + .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Integer\"")); } } + /** + * Test long marshal. + */ @Test public void testLongMarshal() { - final AxContextSchema avroLongSchema = - new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", "{\"type\": \"long\"}"); + final AxContextSchema avroLongSchema = new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", + "{\"type\": \"long\"}"); schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema); - final SchemaHelper schemaHelper3 = - new SchemaHelperFactory().createSchemaHelper(testKey, avroLongSchema.getKey()); + final SchemaHelper schemaHelper3 = new SchemaHelperFactory().createSchemaHelper(testKey, + avroLongSchema.getKey()); assertEquals("0", schemaHelper3.marshal2String(0L)); assertEquals("1", schemaHelper3.marshal2String(1L)); @@ -161,26 +182,29 @@ public class TestAvroSchemaHelperMarshal { schemaHelper3.marshal2String("Hello"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: java.lang.String cannot be cast to java.lang.Long")); + assertTrue(e.getMessage().startsWith("AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: " + + "java.lang.String cannot be cast to java.lang.Long")); } try { schemaHelper3.marshal2String(null); fail("Test should throw an exception here"); } catch (final Exception e) { assertTrue(e.getMessage() - .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Long\"")); + .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Long\"")); } } + /** + * Test float marshal. + */ @Test public void testFloatMarshal() { - final AxContextSchema avroFloatSchema = - new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", "{\"type\": \"float\"}"); + final AxContextSchema avroFloatSchema = new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", + "{\"type\": \"float\"}"); schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema); - final SchemaHelper schemaHelper4 = - new SchemaHelperFactory().createSchemaHelper(testKey, avroFloatSchema.getKey()); + final SchemaHelper schemaHelper4 = new SchemaHelperFactory().createSchemaHelper(testKey, + avroFloatSchema.getKey()); assertEquals("0.0", schemaHelper4.marshal2String(0F)); assertEquals("1.0", schemaHelper4.marshal2String(1F)); @@ -195,27 +219,29 @@ public class TestAvroSchemaHelperMarshal { schemaHelper4.marshal2String("Hello"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: java.lang.String cannot be cast to java.lang.Float")); + assertTrue(e.getMessage().startsWith("AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: " + + "java.lang.String cannot be cast to java.lang.Float")); } try { schemaHelper4.marshal2String(null); fail("Test should throw an exception here"); } catch (final Exception e) { assertTrue(e.getMessage() - .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Float\"")); + .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Float\"")); } } - + /** + * Test double marshal. + */ @Test public void testDoubleMarshal() { - final AxContextSchema avroDoubleSchema = - new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", "{\"type\": \"double\"}"); + final AxContextSchema avroDoubleSchema = new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", + "{\"type\": \"double\"}"); schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema); - final SchemaHelper schemaHelper5 = - new SchemaHelperFactory().createSchemaHelper(testKey, avroDoubleSchema.getKey()); + final SchemaHelper schemaHelper5 = new SchemaHelperFactory().createSchemaHelper(testKey, + avroDoubleSchema.getKey()); assertEquals("0.0", schemaHelper5.marshal2String(0D)); assertEquals("1.0", schemaHelper5.marshal2String(1D)); @@ -230,26 +256,29 @@ public class TestAvroSchemaHelperMarshal { schemaHelper5.marshal2String("Hello"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: java.lang.String cannot be cast to java.lang.Double")); + assertTrue(e.getMessage().startsWith("AvroTest:0.0.1: object \"Hello\" Avro marshalling failed: " + + "java.lang.String cannot be cast to java.lang.Double")); } try { schemaHelper5.marshal2String(null); fail("Test should throw an exception here"); } catch (final Exception e) { assertTrue(e.getMessage() - .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Double\"")); + .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Double\"")); } } + /** + * Test string marshal. + */ @Test public void testStringMarshal() { - final AxContextSchema avroStringSchema = - new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"string\"}"); + final AxContextSchema avroStringSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", + "{\"type\": \"string\"}"); schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema); - final SchemaHelper schemaHelper7 = - new SchemaHelperFactory().createSchemaHelper(testKey, avroStringSchema.getKey()); + final SchemaHelper schemaHelper7 = new SchemaHelperFactory().createSchemaHelper(testKey, + avroStringSchema.getKey()); assertEquals("\"0\"", schemaHelper7.marshal2String("0")); assertEquals("\"1\"", schemaHelper7.marshal2String("1")); @@ -266,19 +295,23 @@ public class TestAvroSchemaHelperMarshal { fail("Test should throw an exception here"); } catch (final Exception e) { assertTrue(e.getMessage() - .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.String\"")); + .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.String\"")); } } + /** + * Test bytes marshal. + */ @Test public void testBytesMarshal() { - final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"bytes\"}"); + final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", + "{\"type\": \"bytes\"}"); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); - final byte[] helloBytes = {104, 101, 108, 108, 111}; + final byte[] helloBytes = + { 104, 101, 108, 108, 111 }; final String helloOut = schemaHelper.marshal2String(helloBytes); assertEquals("\"hello\"", helloOut); @@ -287,7 +320,7 @@ public class TestAvroSchemaHelperMarshal { fail("Test should throw an exception here"); } catch (final Exception e) { assertTrue(e.getMessage() - .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Byte[]\"")); + .startsWith("AvroTest:0.0.1: cannot encode a null object of class \"java.lang.Byte[]\"")); } } } diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java index db7edd673..6dede515e 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java @@ -40,6 +40,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestAvroSchemaHelperUnmarshal. + * * @author Liam Fallon (liam.fallon@ericsson.com) * @version */ @@ -47,12 +49,18 @@ public class TestAvroSchemaHelperUnmarshal { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); private AxContextSchemas schemas; + /** + * Inits the test. + */ @Before public void initTest() { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); ModelService.registerModel(AxContextSchemas.class, schemas); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); @@ -62,11 +70,17 @@ public class TestAvroSchemaHelperUnmarshal { } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test null unmarshal. + */ @Test public void testNullUnmarshal() { final AxContextSchema avroNullSchema = new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", @@ -90,11 +104,14 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper0.unmarshal("123"); fail("test should throw an exception here"); } catch (final Exception e) { - assertEquals("AvroTest:0.0.1: object \"123\" Avro unmarshalling failed: Expected null. Got VALUE_NUMBER_INT", - e.getMessage()); + assertEquals("AvroTest:0.0.1: object \"123\" Avro unmarshalling failed: " + + "Expected null. Got VALUE_NUMBER_INT", e.getMessage()); } } + /** + * Test boolean unmarshal. + */ @Test public void testBooleanUnmarshal() { final AxContextSchema avroBooleanSchema = new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", @@ -108,8 +125,8 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper1.createNewInstance(); fail("test should throw an exception here"); } catch (final Exception e) { - assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default constructor \"Boolean()\"", - e.getMessage()); + assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" " + + "using the default constructor \"Boolean()\"", e.getMessage()); } assertEquals(true, schemaHelper1.createNewInstance("true")); @@ -125,6 +142,9 @@ public class TestAvroSchemaHelperUnmarshal { } } + /** + * Test int unmarshal. + */ @Test public void testIntUnmarshal() { final AxContextSchema avroIntSchema = new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", @@ -138,8 +158,8 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper2.createNewInstance(); fail("test should throw an exception here"); } catch (final Exception e) { - assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" using the default constructor \"Integer()\"", - e.getMessage()); + assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" " + + "using the default constructor \"Integer()\"", e.getMessage()); } assertEquals(123, schemaHelper2.createNewInstance("123")); @@ -154,25 +174,28 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper2.unmarshal("2147483648"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"2147483648\" Avro unmarshalling failed: Numeric value (2147483648) out of range of int")); + assertTrue(e.getMessage().startsWith("AvroTest:0.0.1: object \"2147483648\" Avro unmarshalling failed: " + + "Numeric value (2147483648) out of range of int")); } try { schemaHelper2.unmarshal("-2147483649"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"-2147483649\" Avro unmarshalling failed: Numeric value (-2147483649) out of range of int")); + assertTrue(e.getMessage().startsWith("AvroTest:0.0.1: object \"-2147483649\" Avro unmarshalling failed: " + + "Numeric value (-2147483649) out of range of int")); } try { schemaHelper2.unmarshal(null); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: " + + "String to read from cannot be null!")); } } + /** + * Test long unmarshal. + */ @Test public void testLongUnmarshal() { final AxContextSchema avroLongSchema = new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", @@ -186,8 +209,8 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper3.createNewInstance(); fail("test should throw an exception here"); } catch (final Exception e) { - assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default constructor \"Long()\"", - e.getMessage()); + assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" " + + "using the default constructor \"Long()\"", e.getMessage()); } assertEquals(123456789L, schemaHelper3.createNewInstance("123456789")); @@ -202,32 +225,37 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper3.unmarshal("9223372036854775808"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"9223372036854775808\" Avro unmarshalling failed: Numeric value (9223372036854775808) out of range of long")); + assertTrue(e.getMessage() + .startsWith("AvroTest:0.0.1: object \"9223372036854775808\" Avro unmarshalling failed: " + + "Numeric value (9223372036854775808) out of range of long")); } try { schemaHelper3.unmarshal("-9223372036854775809"); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().startsWith( - "AvroTest:0.0.1: object \"-9223372036854775809\" Avro unmarshalling failed: Numeric value (-9223372036854775809) out of range of long")); + assertTrue(e.getMessage() + .startsWith("AvroTest:0.0.1: object \"-9223372036854775809\" Avro unmarshalling failed: " + + "Numeric value (-9223372036854775809) out of range of long")); } try { schemaHelper3.unmarshal("\"Hello\""); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected long. Got VALUE_STRING")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: " + + "Expected long. Got VALUE_STRING")); } try { schemaHelper3.unmarshal(null); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: " + + "String to read from cannot be null!")); } } + /** + * Test float unmarshal. + */ @Test public void testFloatUnmarshal() { final AxContextSchema avroFloatSchema = new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", @@ -241,8 +269,8 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper4.createNewInstance(); fail("test should throw an exception here"); } catch (final Exception e) { - assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" using the default constructor \"Float()\"", - e.getMessage()); + assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" " + + "using the default constructor \"Float()\"", e.getMessage()); } assertEquals(1.2345F, schemaHelper4.createNewInstance("1.2345")); @@ -259,18 +287,21 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper4.unmarshal("\"Hello\""); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected float. Got VALUE_STRING")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: " + + "Expected float. Got VALUE_STRING")); } try { schemaHelper4.unmarshal(null); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: " + + "String to read from cannot be null!")); } } + /** + * Test double unmarshal. + */ @Test public void testDoubleUnmarshal() { final AxContextSchema avroDoubleSchema = new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", @@ -284,8 +315,8 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper5.createNewInstance(); fail("test should throw an exception here"); } catch (final Exception e) { - assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" using the default constructor \"Double()\"", - e.getMessage()); + assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" " + + "using the default constructor \"Double()\"", e.getMessage()); } assertEquals(1.2345E06, schemaHelper5.createNewInstance("1.2345E06")); @@ -302,18 +333,21 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper5.unmarshal("\"Hello\""); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected double. Got VALUE_STRING")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: " + + "Expected double. Got VALUE_STRING")); } try { schemaHelper5.unmarshal(null); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: " + + "String to read from cannot be null!")); } } + /** + * Test string unmarshal. + */ @Test public void testStringUnmarshal() { final AxContextSchema avroStringSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", @@ -341,11 +375,14 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper7.unmarshal(null); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: " + + "String to read from cannot be null!")); } } + /** + * Test bytes unmarshal. + */ @Test public void testBytesUnmarshal() { final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", @@ -358,8 +395,8 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper.createNewInstance(); fail("test should throw an exception here"); } catch (final Exception e) { - assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Byte[]\" using the default constructor \"Byte[]()\"", - e.getMessage()); + assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Byte[]\" " + + "using the default constructor \"Byte[]()\"", e.getMessage()); } final byte[] newBytes = (byte[]) schemaHelper.createNewInstance("\"hello\""); assertEquals(5, newBytes.length); @@ -373,8 +410,8 @@ public class TestAvroSchemaHelperUnmarshal { schemaHelper.unmarshal(null); fail("Test should throw an exception here"); } catch (final Exception e) { - assertTrue(e.getMessage().equals( - "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!")); + assertTrue(e.getMessage().equals("AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: " + + "String to read from cannot be null!")); } } } diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java index 7bf6b0029..9bc87cf61 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java @@ -43,8 +43,10 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestAvroSchemaMap. + * * @author Liam Fallon (liam.fallon@ericsson.com) - * @version + * @version */ public class TestAvroSchemaMap { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); @@ -53,6 +55,11 @@ public class TestAvroSchemaMap { private String addressMapSchema; private String addressMapSchemaInvalidFields; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); @@ -63,6 +70,9 @@ public class TestAvroSchemaMap { TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddressInvalidFields.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); @@ -72,11 +82,19 @@ public class TestAvroSchemaMap { } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test map init. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testMapInit() throws IOException { final AxContextSchema avroSchema = @@ -95,6 +113,11 @@ public class TestAvroSchemaMap { newMapFull.get(new Utf8("address2")).toString()); } + /** + * Test long map unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testLongMapUnmarshalMarshal() throws IOException { final AxContextSchema avroSchema = @@ -107,6 +130,11 @@ public class TestAvroSchemaMap { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/MapExampleLongFull.json"); } + /** + * Test address map unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testAddressMapUnmarshalMarshal() throws IOException { final AxContextSchema avroSchema = @@ -119,6 +147,11 @@ public class TestAvroSchemaMap { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/MapExampleAddressFull.json"); } + /** + * Test address map unmarshal marshal invalid fields. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testAddressMapUnmarshalMarshalInvalidFields() throws IOException { final AxContextSchema avroSchema = @@ -130,6 +163,13 @@ public class TestAvroSchemaMap { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/MapExampleAddressInvalidFields.json"); } + /** + * Test unmarshal marshal. + * + * @param schemaHelper the schema helper + * @param fileName the file name + * @throws IOException Signals that an I/O exception has occurred. + */ private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException { final String originalInString = TextFileUtils.getTextFileAsString(fileName); final HashMap<?, ?> firstDecodedMap = (HashMap<?, ?>) schemaHelper.unmarshal(originalInString); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java index 000dcc9fd..6b1d09eb6 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java @@ -40,29 +40,40 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; +// TODO: Auto-generated Javadoc /** + * The Class TestAvroSchemaRecord. + * * @author Liam Fallon (liam.fallon@ericsson.com) - * @version + * @version */ public class TestAvroSchemaRecord { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); private AxContextSchemas schemas; private String recordSchema; - private String recordSchemaVPN; - private String recordSchemaVPNReuse; + private String recordSchemaVpn; + private String recordSchemaVpnReuse; private String recordSchemaInvalidFields; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); ModelService.registerModel(AxContextSchemas.class, schemas); recordSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExample.avsc"); - recordSchemaVPN = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPN.avsc"); - recordSchemaVPNReuse = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPNReuse.avsc"); + recordSchemaVpn = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPN.avsc"); + recordSchemaVpnReuse = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPNReuse.avsc"); recordSchemaInvalidFields = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleInvalidFields.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); @@ -72,11 +83,19 @@ public class TestAvroSchemaRecord { } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test record init. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testRecordInit() throws IOException { final AxContextSchema avroSchema = @@ -93,6 +112,11 @@ public class TestAvroSchemaRecord { assertEquals("gobbledygook", newRecordFull.get("passwordHash").toString()); } + /** + * Test record unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testRecordUnmarshalMarshal() throws IOException { final AxContextSchema avroSchema = @@ -105,6 +129,11 @@ public class TestAvroSchemaRecord { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/RecordExampleFull.json"); } + /** + * Test record unmarshal marshal invalid. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testRecordUnmarshalMarshalInvalid() throws IOException { final AxContextSchema avroSchema = @@ -116,10 +145,15 @@ public class TestAvroSchemaRecord { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/RecordExampleInvalidFields.json"); } + /** + * Test VPN record unmarshal marshal. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testVPNRecordUnmarshalMarshal() throws IOException { + public void testVpnRecordUnmarshalMarshal() throws IOException { final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVPN); + new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpn); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); @@ -127,16 +161,28 @@ public class TestAvroSchemaRecord { testUnmarshalMarshal(schemaHelper, "src/test/resources/data/RecordExampleVPNFull.json"); } + /** + * Test VPN record reuse. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testVPNRecordReuse() throws IOException { + public void testVpnRecordReuse() throws IOException { final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVPNReuse); + new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpnReuse); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); } + /** + * Test unmarshal marshal. + * + * @param schemaHelper the schema helper + * @param fileName the file name + * @throws IOException Signals that an I/O exception has occurred. + */ private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException { final String inString = TextFileUtils.getTextFileAsString(fileName); final GenericRecord decodedObject = (GenericRecord) schemaHelper.unmarshal(inString); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java index 33cb20328..c957d8d4c 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java @@ -42,14 +42,21 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestAvroSchemaUnion. + * * @author Liam Fallon (liam.fallon@ericsson.com) - * @version + * @version */ public class TestAvroSchemaUnion { private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1"); private AxContextSchemas schemas; private String uinionSchema; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); @@ -57,25 +64,36 @@ public class TestAvroSchemaUnion { uinionSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/UnionExample.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters()); ParameterService.register(schemaParameters); - + } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test union all fields. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Ignore @Test public void testUnionAllFields() throws IOException { final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema); + new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); @@ -88,17 +106,22 @@ public class TestAvroSchemaUnion { assertEquals("red", user.get("favourite_colour").toString()); } + /** + * Test union optional field. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Ignore @Test public void testUnionOptionalField() throws IOException { final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema); + new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); final String inString = - TextFileUtils.getTextFileAsString("src/test/resources/data/UnionExampleOptionalField.json"); + TextFileUtils.getTextFileAsString("src/test/resources/data/UnionExampleOptionalField.json"); final GenericRecord user = (GenericRecord) schemaHelper.createNewInstance(inString); assertEquals("Ben", user.get("name").toString()); @@ -106,11 +129,16 @@ public class TestAvroSchemaUnion { assertEquals("red", user.get("favourite_colour").toString()); } + /** + * Test union null field. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Ignore @Test public void testUnionNullField() throws IOException { final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema); + new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java index 42764a1ca..646b8aa04 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java @@ -44,6 +44,8 @@ import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.parameters.ParameterService; /** + * The Class TestHealthCheckSchema. + * * @author Liam Fallon (liam.fallon@ericsson.com) */ public class TestHealthCheckSchema { @@ -51,6 +53,11 @@ public class TestHealthCheckSchema { private AxContextSchemas schemas; private String healthCheckSchema; + /** + * Inits the test. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Before public void initTest() throws IOException { schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1")); @@ -59,24 +66,35 @@ public class TestHealthCheckSchema { healthCheckSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/HealthCheckBodyType.avsc"); } + /** + * Inits the context. + */ @Before public void initContext() { SchemaParameters schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters()); ParameterService.register(schemaParameters); - + } + /** + * Clear context. + */ @After public void clearContext() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test health check. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testHealthCheck() throws IOException { - final AxContextSchema avroSchema = - new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", healthCheckSchema); + final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", + healthCheckSchema); schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema); final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey()); @@ -89,15 +107,15 @@ public class TestHealthCheckSchema { final GenericRecord inputRecord = new GenericData.Record(healthCheckRecordSchema.getField("input").schema()); final Schema inputRecordRecordSchema = inputRecord.getSchema(); - final GenericRecord actionIndentifiersRecord = - new GenericData.Record(inputRecordRecordSchema.getField("action_DasH_identifiers").schema()); + final GenericRecord actionIndentifiersRecord = new GenericData.Record( + inputRecordRecordSchema.getField("action_DasH_identifiers").schema()); - final GenericRecord commonHeaderRecord = - new GenericData.Record(inputRecordRecordSchema.getField("common_DasH_header").schema()); + final GenericRecord commonHeaderRecord = new GenericData.Record( + inputRecordRecordSchema.getField("common_DasH_header").schema()); final Schema commonHeaderRecordSchema = commonHeaderRecord.getSchema(); - final GenericRecord commonHeaderFlagsRecord = - new GenericData.Record(commonHeaderRecordSchema.getField("flags").schema()); + final GenericRecord commonHeaderFlagsRecord = new GenericData.Record( + commonHeaderRecordSchema.getField("flags").schema()); healthCheckRecord.put("input", inputRecord); inputRecord.put("action_DasH_identifiers", actionIndentifiersRecord); @@ -105,8 +123,8 @@ public class TestHealthCheckSchema { commonHeaderRecord.put("flags", commonHeaderFlagsRecord); inputRecord.put("action", "HealthCheck"); - inputRecord.put("payload", - "{\"host-ip-address\":\"131.160.203.125\",\"input.url\":\"131.160.203.125/afr\",\"request-action-type\":\"GET\",\"request-action\":\"AFR\"}"); + inputRecord.put("payload", "{\"host-ip-address\":\"131.160.203.125\",\"input.url\":\"131.160.203.125/afr\"," + + "\"request-action-type\":\"GET\",\"request-action\":\"AFR\"}"); actionIndentifiersRecord.put("vnf_DasH_id", "49414df5-3482-4fd8-9952-c463dff2770b"); @@ -125,6 +143,13 @@ public class TestHealthCheckSchema { assertEquals(eventString.toString().replaceAll("\\s+", ""), outString.replaceAll("\\s+", "")); } + /** + * Test unmarshal marshal. + * + * @param schemaHelper the schema helper + * @param fileName the file name + * @throws IOException Signals that an I/O exception has occurred. + */ private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException { final String inString = TextFileUtils.getTextFileAsString(fileName); final GenericRecord decodedObject = (GenericRecord) schemaHelper.unmarshal(inString); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java index 93174b941..de324512b 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java @@ -49,12 +49,12 @@ import org.slf4j.LoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runnable { +public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runnable { // Get a reference to the logger - private static final Logger LOGGER = LoggerFactory.getLogger(ApexJMSConsumer.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ApexJmsConsumer.class); // The Apex and JMS parameters read from the parameter service - private JMSCarrierTechnologyParameters jmsConsumerProperties; + private JmsCarrierTechnologyParameters jmsConsumerProperties; // The event receiver that will receive events from this consumer private ApexEventReceiver eventReceiver; @@ -83,14 +83,14 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn this.name = consumerName; // Check and get the JMS Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof JMSCarrierTechnologyParameters)) { + if (!(consumerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) { final String errorMessage = "specified consumer properties of type \"" + consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName() + "\" are not applicable to a JMS consumer"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - jmsConsumerProperties = (JMSCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); + jmsConsumerProperties = (JmsCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); // Look up the JMS connection factory InitialContext jmsContext = null; @@ -212,7 +212,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn } /** - * The helper function to create a message consumer from a given JMS session + * The helper function to create a message consumer from a given JMS session. * * @param jmsSession a JMS session */ diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java index 86e9555f9..7277a7dc3 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java @@ -47,13 +47,17 @@ import org.slf4j.LoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class ApexJMSProducer implements ApexEventProducer { - +public class ApexJmsProducer implements ApexEventProducer { // Get a reference to the logger - private static final Logger LOGGER = LoggerFactory.getLogger(ApexJMSProducer.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ApexJmsProducer.class); + + // Recurring string constants + private static final String COULD_NOT_SEND_PREFIX = "could not send event \""; + private static final String FOR_PRODUCER_TAG = "\" for producer ("; + private static final String JMS_MESSAGE_PRODUCER_TAG = "\" on JMS message producer "; // The JMS parameters read from the parameter service - private JMSCarrierTechnologyParameters jmsProducerProperties; + private JmsCarrierTechnologyParameters jmsProducerProperties; // The connection to the JMS server private Connection connection; @@ -78,16 +82,17 @@ public class ApexJMSProducer implements ApexEventProducer { */ @Override public void init(final String producerName, final EventHandlerParameters producerParameters) - throws ApexEventException { + throws ApexEventException { this.name = producerName; // Check and get the JMS Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof JMSCarrierTechnologyParameters)) { - final String errorMessage = "specified producer properties are not applicable to a JMS producer (" + this.name + ")"; + if (!(producerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) { + final String errorMessage = "specified producer properties are not applicable to a JMS producer (" + + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - jmsProducerProperties = (JMSCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + jmsProducerProperties = (JmsCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); // Look up the JMS connection factory InitialContext jmsContext = null; @@ -99,12 +104,12 @@ public class ApexJMSProducer implements ApexEventProducer { // Check if we actually got a connection factory if (connectionFactory == null) { throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory() - + "\" returned null for producer (" + this.name + ")"); + + "\" returned null for producer (" + this.name + ")"); } } catch (final Exception e) { final String errorMessage = "lookup of JMS connection factory \"" - + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \"" - + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")"; + + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \"" + + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -117,12 +122,12 @@ public class ApexJMSProducer implements ApexEventProducer { // Check if we actually got a topic if (jmsOutgoingTopic == null) { throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic() - + "\" returned null for producer (" + this.name + ")"); + + "\" returned null for producer (" + this.name + ")"); } } catch (final Exception e) { final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic() - + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties() - + "\" for producer (" + this.name + ")"; + + "\" failed for JMS producer properties \"" + + jmsProducerProperties.getJmsProducerProperties() + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -130,11 +135,11 @@ public class ApexJMSProducer implements ApexEventProducer { // Create and start a connection to the JMS server try { connection = connectionFactory.createConnection(jmsProducerProperties.getSecurityPrincipal(), - jmsProducerProperties.getSecurityCredentials()); + jmsProducerProperties.getSecurityCredentials()); connection.start(); } catch (final Exception e) { final String errorMessage = "connection to JMS server failed for JMS properties \"" - + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")"; + + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -144,7 +149,7 @@ public class ApexJMSProducer implements ApexEventProducer { jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (final Exception e) { final String errorMessage = "creation of session to JMS server failed for JMS properties \"" - + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")"; + + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -153,8 +158,8 @@ public class ApexJMSProducer implements ApexEventProducer { try { messageProducer = jmsSession.createProducer(jmsOutgoingTopic); } catch (final Exception e) { - final String errorMessage = - "creation of producer for sending events to JMS server failed for JMS properties \"" + final String errorMessage = "creation of producer for sending events " + + "to JMS server failed for JMS properties \"" + jmsProducerProperties.getJmsConsumerProperties() + "\""; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); @@ -202,17 +207,17 @@ public class ApexJMSProducer implements ApexEventProducer { @Override public void sendEvent(final long executionId, final String eventname, final Object eventObject) { // Check if this is a synchronized event, if so we have received a reply - final SynchronousEventCache synchronousEventCache = - (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS); + final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap + .get(EventHandlerPeeredMode.SYNCHRONOUS); if (synchronousEventCache != null) { synchronousEventCache.removeCachedEventToApexIfExists(executionId); } // Check if the object to be sent is serializable if (!Serializable.class.isAssignableFrom(eventObject.getClass())) { - final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer " - + this.name + ", object of type \"" + eventObject.getClass().getCanonicalName() - + "\" is not serializable"; + final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name + + ", object of type \"" + eventObject.getClass().getCanonicalName() + + "\" is not serializable"; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -226,8 +231,8 @@ public class ApexJMSProducer implements ApexEventProducer { try { jmsMessage = jmsSession.createObjectMessage((Serializable) eventObject); } catch (final Exception e) { - final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer " - + this.name + ", could not create JMS Object Message for object \"" + eventObject; + final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + + this.name + ", could not create JMS Object Message for object \"" + eventObject; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -236,8 +241,8 @@ public class ApexJMSProducer implements ApexEventProducer { try { jmsMessage = jmsSession.createTextMessage(eventObject.toString()); } catch (final Exception e) { - final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer " - + this.name + ", could not create JMS Text Message for object \"" + eventObject; + final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + + this.name + ", could not create JMS Text Message for object \"" + eventObject; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -246,8 +251,8 @@ public class ApexJMSProducer implements ApexEventProducer { try { messageProducer.send(jmsMessage); } catch (final Exception e) { - final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer " - + this.name + ", send failed for object \"" + eventObject; + final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name + + ", send failed for object \"" + eventObject; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java index 80977b5d8..8b120ca3a 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java @@ -30,8 +30,8 @@ import org.onap.policy.common.parameters.ValidationStatus; /** * Apex parameters for JMS as an event carrier technology. - * <p> - * The parameters for this plugin are: + * + * <p>The parameters for this plugin are: * <ol> * <li>initialContextFactory: JMS uses a naming {@link Context} object to look up the locations of JMS servers and JMS * topics. An Initial Context Factory is used to when creating a {@link Context} object that can be used for JMS @@ -69,28 +69,28 @@ import org.onap.policy.common.parameters.ValidationStatus; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters { +public class JmsCarrierTechnologyParameters extends CarrierTechnologyParameters { /** The label of this carrier technology. */ public static final String JMS_CARRIER_TECHNOLOGY_LABEL = "JMS"; /** The producer plugin class for the JMS carrier technology. */ - public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJMSProducer.class.getCanonicalName(); + public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJmsProducer.class.getCanonicalName(); /** The consumer plugin class for the JMS carrier technology. */ - public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJMSConsumer.class.getCanonicalName(); + public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJmsConsumer.class.getCanonicalName(); // @formatter:off // Default parameter values - private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory"; - private static final String DEFAULT_INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory"; - private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447"; - private static final String DEFAULT_SECURITY_PRINCIPAL = "userid"; - private static final String DEFAULT_SECURITY_CREDENTIALS = "password"; - private static final String DEFAULT_CONSUMER_TOPIC = "apex-in"; - private static final String DEFAULT_PRODUCER_TOPIC = "apex-out"; - private static final int DEFAULT_CONSUMER_WAIT_TIME = 100; - private static final boolean DEFAULT_TO_OBJECT_MESSAGE_SENDING = true; + private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory"; + private static final String DEFAULT_INITIAL_CTXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory"; + private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447"; + private static final String DEFAULT_SECURITY_PRINCIPAL = "userid"; + private static final String DEFAULT_SECURITY_CREDENTIALS = "password"; + private static final String DEFAULT_CONSUMER_TOPIC = "apex-in"; + private static final String DEFAULT_PRODUCER_TOPIC = "apex-out"; + private static final int DEFAULT_CONSUMER_WAIT_TIME = 100; + private static final boolean DEFAULT_TO_OBJECT_MSG_SENDING = true; // Parameter property map tokens private static final String PROPERTY_INITIAL_CONTEXT_FACTORY = Context.INITIAL_CONTEXT_FACTORY; @@ -100,21 +100,21 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters // JMS carrier parameters private String connectionFactory = DEFAULT_CONNECTION_FACTORY; - private String initialContextFactory = DEFAULT_INITIAL_CONTEXT_FACTORY; + private String initialContextFactory = DEFAULT_INITIAL_CTXT_FACTORY; private String providerUrl = DEFAULT_PROVIDER_URL; private String securityPrincipal = DEFAULT_SECURITY_PRINCIPAL; private String securityCredentials = DEFAULT_SECURITY_CREDENTIALS; private String producerTopic = DEFAULT_PRODUCER_TOPIC; private String consumerTopic = DEFAULT_CONSUMER_TOPIC; private int consumerWaitTime = DEFAULT_CONSUMER_WAIT_TIME; - private boolean objectMessageSending = DEFAULT_TO_OBJECT_MESSAGE_SENDING; + private boolean objectMessageSending = DEFAULT_TO_OBJECT_MSG_SENDING; // @formatter:on /** * Constructor to create a jms carrier technology parameters instance and register the instance with the parameter * service. */ - public JMSCarrierTechnologyParameters() { + public JmsCarrierTechnologyParameters() { super(); // Set the carrier technology properties for the JMS carrier technology diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java index 3351a58e9..dfb12617c 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java @@ -47,7 +47,7 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(ApexKafkaConsumer.class); // The Kafka parameters read from the parameter service - private KAFKACarrierTechnologyParameters kafkaConsumerProperties; + private KafkaCarrierTechnologyParameters kafkaConsumerProperties; // The event receiver that will receive events from this consumer private ApexEventReceiver eventReceiver; @@ -79,7 +79,7 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable { this.name = consumerName; // Check and get the Kafka Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof KAFKACarrierTechnologyParameters)) { + if (!(consumerParameters.getCarrierTechnologyParameters() instanceof KafkaCarrierTechnologyParameters)) { LOGGER.warn("specified consumer properties of type \"" + consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName() + "\" are not applicable to a Kafka consumer"); @@ -88,10 +88,10 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable { + "\" are not applicable to a Kafka consumer"); } kafkaConsumerProperties = - (KAFKACarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); + (KafkaCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); // Kick off the Kafka consumer - kafkaConsumer = new KafkaConsumer<String, String>(kafkaConsumerProperties.getKafkaConsumerProperties()); + kafkaConsumer = new KafkaConsumer<>(kafkaConsumerProperties.getKafkaConsumerProperties()); kafkaConsumer.subscribe(kafkaConsumerProperties.getConsumerTopicList()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("event receiver for " + this.getClass().getName() + ":" + this.name + " subscribed to topics: " @@ -153,7 +153,7 @@ public class ApexKafkaConsumer implements ApexEventConsumer, Runnable { @Override public void run() { // Kick off the Kafka consumer - kafkaConsumer = new KafkaConsumer<String, String>(kafkaConsumerProperties.getKafkaConsumerProperties()); + kafkaConsumer = new KafkaConsumer<>(kafkaConsumerProperties.getKafkaConsumerProperties()); kafkaConsumer.subscribe(kafkaConsumerProperties.getConsumerTopicList()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("event receiver for " + this.getClass().getName() + ":" + this.name + " subscribed to topics: " diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java index fb851bc70..c83c0ae1e 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java @@ -46,7 +46,7 @@ public class ApexKafkaProducer implements ApexEventProducer { private static final Logger LOGGER = LoggerFactory.getLogger(ApexKafkaProducer.class); // The Kafka parameters read from the parameter service - private KAFKACarrierTechnologyParameters kafkaProducerProperties; + private KafkaCarrierTechnologyParameters kafkaProducerProperties; // The Kafka Producer used to send events using Kafka private Producer<String, Object> kafkaProducer; @@ -63,13 +63,14 @@ public class ApexKafkaProducer implements ApexEventProducer { this.name = producerName; // Check and get the Kafka Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof KAFKACarrierTechnologyParameters)) { - LOGGER.warn("specified producer properties are not applicable to a Kafka producer (" + this.name + ")"); + if (!(producerParameters.getCarrierTechnologyParameters() instanceof KafkaCarrierTechnologyParameters)) { + String message = "specified producer properties are not applicable to a Kafka producer (" + this.name + ")"; + LOGGER.warn(message); throw new ApexEventException( - "specified producer properties are not applicable to a Kafka producer (" + this.name + ")"); + message); } kafkaProducerProperties = - (KAFKACarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + (KafkaCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); } /* @@ -122,7 +123,7 @@ public class ApexKafkaProducer implements ApexEventProducer { // Kafka producer must be started in the same thread as it is stopped, so we must start it here if (kafkaProducer == null) { // Kick off the Kafka producer - kafkaProducer = new KafkaProducer<String, Object>(kafkaProducerProperties.getKafkaProducerProperties()); + kafkaProducer = new KafkaProducer<>(kafkaProducerProperties.getKafkaProducerProperties()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("event producer " + this.name + " is ready to send to topics: " + kafkaProducerProperties.getProducerTopic()); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java index 5ce96662e..9d7cc77f3 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java @@ -33,7 +33,7 @@ import org.onap.policy.common.parameters.ValidationStatus; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameters { +public class KafkaCarrierTechnologyParameters extends CarrierTechnologyParameters { // @formatter:off /** The label of this carrier technology. */ public static final String KAFKA_CARRIER_TECHNOLOGY_LABEL = "KAFKA"; @@ -48,23 +48,23 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter private static final String SPECIFY_AS_STRING_MESSAGE = "not specified, must be specified as a string"; // Default parameter values - private static final String DEFAULT_ACKS = "all"; - private static final String DEFAULT_BOOTSTRAP_SERVERS = "localhost:9092"; - private static final int DEFAULT_RETRIES = 0; - private static final int DEFAULT_BATCH_SIZE = 16384; - private static final int DEFAULT_LINGER_TIME = 1; - private static final long DEFAULT_BUFFER_MEMORY = 33554432; - private static final String DEFAULT_GROUP_ID = "default-group-id"; - private static final boolean DEFAULT_ENABLE_AUTO_COMMIT = true; - private static final int DEFAULT_AUTO_COMMIT_TIME = 1000; - private static final int DEFAULT_SESSION_TIMEOUT = 30000; - private static final String DEFAULT_PRODUCER_TOPIC = "apex-out"; - private static final int DEFAULT_CONSUMER_POLL_TIME = 100; - private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = {"apex-in"}; - private static final String DEFAULT_KEY_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer"; - private static final String DEFAULT_VALUE_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer"; - private static final String DEFAULT_KEY_DESERIALIZER = "org.apache.kafka.common.serialization.StringDeserializer"; - private static final String DEFAULT_VALUE_DESERIALIZER = "org.apache.kafka.common.serialization.StringDeserializer"; + private static final String DEFAULT_ACKS = "all"; + private static final String DEFAULT_BOOT_SERVERS = "localhost:9092"; + private static final int DEFAULT_RETRIES = 0; + private static final int DEFAULT_BATCH_SIZE = 16384; + private static final int DEFAULT_LINGER_TIME = 1; + private static final long DEFAULT_BUFFER_MEMORY = 33554432; + private static final String DEFAULT_GROUP_ID = "default-group-id"; + private static final boolean DEFAULT_ENABLE_AUTOCMIT = true; + private static final int DEFAULT_AUTO_COMMIT_TIME = 1000; + private static final int DEFAULT_SESSION_TIMEOUT = 30000; + private static final String DEFAULT_PROD_TOPIC = "apex-out"; + private static final int DEFAULT_CONS_POLL_TIME = 100; + private static final String[] DEFAULT_CONS_TOPICLIST = {"apex-in"}; + private static final String DEFAULT_KEY_SERZER = "org.apache.kafka.common.serialization.StringSerializer"; + private static final String DEFAULT_VAL_SERZER = "org.apache.kafka.common.serialization.StringSerializer"; + private static final String DEFAULT_KEY_DESZER = "org.apache.kafka.common.serialization.StringDeserializer"; + private static final String DEFAULT_VALUE_DESZER = "org.apache.kafka.common.serialization.StringDeserializer"; // Parameter property map tokens private static final String PROPERTY_BOOTSTRAP_SERVERS = "bootstrap.servers"; @@ -83,30 +83,30 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter private static final String PROPERTY_VALUE_DESERIALIZER = "value.deserializer"; // kafka carrier parameters - private String bootstrapServers = DEFAULT_BOOTSTRAP_SERVERS; + private String bootstrapServers = DEFAULT_BOOT_SERVERS; private String acks = DEFAULT_ACKS; private int retries = DEFAULT_RETRIES; private int batchSize = DEFAULT_BATCH_SIZE; private int lingerTime = DEFAULT_LINGER_TIME; private long bufferMemory = DEFAULT_BUFFER_MEMORY; private String groupId = DEFAULT_GROUP_ID; - private boolean enableAutoCommit = DEFAULT_ENABLE_AUTO_COMMIT; + private boolean enableAutoCommit = DEFAULT_ENABLE_AUTOCMIT; private int autoCommitTime = DEFAULT_AUTO_COMMIT_TIME; private int sessionTimeout = DEFAULT_SESSION_TIMEOUT; - private String producerTopic = DEFAULT_PRODUCER_TOPIC; - private int consumerPollTime = DEFAULT_CONSUMER_POLL_TIME; - private String[] consumerTopicList = DEFAULT_CONSUMER_TOPIC_LIST; - private String keySerializer = DEFAULT_KEY_SERIALIZER; - private String valueSerializer = DEFAULT_VALUE_SERIALIZER; - private String keyDeserializer = DEFAULT_KEY_DESERIALIZER; - private String valueDeserializer = DEFAULT_VALUE_DESERIALIZER; + private String producerTopic = DEFAULT_PROD_TOPIC; + private int consumerPollTime = DEFAULT_CONS_POLL_TIME; + private String[] consumerTopicList = DEFAULT_CONS_TOPICLIST; + private String keySerializer = DEFAULT_KEY_SERZER; + private String valueSerializer = DEFAULT_VAL_SERZER; + private String keyDeserializer = DEFAULT_KEY_DESZER; + private String valueDeserializer = DEFAULT_VALUE_DESZER; // @formatter:on /** * Constructor to create a kafka carrier technology parameters instance and register the instance with the parameter * service. */ - public KAFKACarrierTechnologyParameters() { + public KafkaCarrierTechnologyParameters() { super(); // Set the carrier technology properties for the kafka carrier technology @@ -394,7 +394,7 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter return result; } - + private void validateConsumerTopicList(final GroupValidationResult result) { if (consumerTopicList == null || consumerTopicList.length == 0) { result.setResult("consumerTopicList", ValidationStatus.INVALID, @@ -414,6 +414,6 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter } private boolean isNullOrBlank(final String stringValue) { - return stringValue == null || stringValue.trim().length() == 0; + return stringValue == null || stringValue.trim().length() == 0; } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java index af5d4d861..13edea8a6 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java @@ -52,7 +52,7 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable { private static final long REST_CLIENT_WAIT_SLEEP_TIME = 50; // The REST parameters read from the parameter service - private RESTClientCarrierTechnologyParameters restConsumerProperties; + private RestClientCarrierTechnologyParameters restConsumerProperties; // The event receiver that will receive events from this consumer private ApexEventReceiver eventReceiver; @@ -77,22 +77,22 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable { this.name = consumerName; // Check and get the REST Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RESTClientCarrierTechnologyParameters)) { + if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RestClientCarrierTechnologyParameters)) { final String errorMessage = "specified consumer properties are not applicable to REST client consumer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - restConsumerProperties = (RESTClientCarrierTechnologyParameters) consumerParameters + restConsumerProperties = (RestClientCarrierTechnologyParameters) consumerParameters .getCarrierTechnologyParameters(); // Check if the HTTP method has been set if (restConsumerProperties.getHttpMethod() == null) { - restConsumerProperties.setHttpMethod(RESTClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD); + restConsumerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD); } if (!restConsumerProperties.getHttpMethod() - .equalsIgnoreCase(RESTClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD)) { + .equalsIgnoreCase(RestClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD)) { final String errorMessage = "specified HTTP method of \"" + restConsumerProperties.getHttpMethod() + "\" is invalid, only HTTP method \"GET\" " + "is supported for event reception on REST client consumer (" + this.name + ")"; @@ -214,17 +214,17 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable { } // Get the event we received - final String eventJSONString = response.readEntity(String.class); + final String eventJsonString = response.readEntity(String.class); // Check there is content - if (eventJSONString == null || eventJSONString.trim().length() == 0) { + if (eventJsonString == null || eventJsonString.trim().length() == 0) { final String errorMessage = "received an empty event from URL \"" + restConsumerProperties.getUrl() + "\""; throw new ApexEventRuntimeException(errorMessage); } // Send the event into Apex - eventReceiver.receiveEvent(eventJSONString); + eventReceiver.receiveEvent(eventJsonString); } catch (final Exception e) { LOGGER.warn("error receiving events on thread {}", consumerThread.getName(), e); } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java index 2765fe9e7..82c3cf331 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java @@ -51,7 +51,7 @@ public class ApexRestClientProducer implements ApexEventProducer { private Client client; // The REST carrier properties - private RESTClientCarrierTechnologyParameters restProducerProperties; + private RestClientCarrierTechnologyParameters restProducerProperties; // The name for this producer private String name = null; @@ -67,29 +67,29 @@ public class ApexRestClientProducer implements ApexEventProducer { */ @Override public void init(final String producerName, final EventHandlerParameters producerParameters) - throws ApexEventException { + throws ApexEventException { this.name = producerName; // Check and get the REST Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof RESTClientCarrierTechnologyParameters)) { - final String errorMessage = - "specified consumer properties are not applicable to REST client producer (" + this.name + ")"; + if (!(producerParameters.getCarrierTechnologyParameters() instanceof RestClientCarrierTechnologyParameters)) { + final String errorMessage = "specified consumer properties are not applicable to REST client producer (" + + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - restProducerProperties = - (RESTClientCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + restProducerProperties = (RestClientCarrierTechnologyParameters) producerParameters + .getCarrierTechnologyParameters(); // Check if the HTTP method has been set if (restProducerProperties.getHttpMethod() == null) { - restProducerProperties.setHttpMethod(RESTClientCarrierTechnologyParameters.DEFAULT_PRODUCER_HTTP_METHOD); + restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.DEFAULT_PRODUCER_HTTP_METHOD); } if (!restProducerProperties.getHttpMethod().equalsIgnoreCase("POST") - && !restProducerProperties.getHttpMethod().equalsIgnoreCase("PUT")) { + && !restProducerProperties.getHttpMethod().equalsIgnoreCase("PUT")) { final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod() - + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted for event sending on REST client producer (" - + this.name + ")"; + + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted " + + "for event sending on REST client producer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } @@ -139,8 +139,8 @@ public class ApexRestClientProducer implements ApexEventProducer { @Override public void sendEvent(final long executionId, final String eventName, final Object event) { // Check if this is a synchronized event, if so we have received a reply - final SynchronousEventCache synchronousEventCache = - (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS); + final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap + .get(EventHandlerPeeredMode.SYNCHRONOUS); if (synchronousEventCache != null) { synchronousEventCache.removeCachedEventToApexIfExists(executionId); } @@ -151,15 +151,16 @@ public class ApexRestClientProducer implements ApexEventProducer { // Check that the request worked if (response.getStatus() != Response.Status.OK.getStatusCode()) { final String errorMessage = "send of event to URL \"" + restProducerProperties.getUrl() + "\" using HTTP \"" - + restProducerProperties.getHttpMethod() + "\" failed with status code " + response.getStatus() - + " and message \"" + response.readEntity(String.class) + "\", event:\n" + event; + + restProducerProperties.getHttpMethod() + "\" failed with status code " + + response.getStatus() + " and message \"" + response.readEntity(String.class) + + "\", event:\n" + event; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } if (LOGGER.isTraceEnabled()) { LOGGER.trace("event sent from engine using {} to URL {} with HTTP {} : {} and response {} ", this.name, - restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response); + restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response); } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java index d260cbeca..86c8bb4cf 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java @@ -37,7 +37,7 @@ import org.onap.policy.common.parameters.ValidationStatus; * * @author Joss Armstrong (joss.armstrong@ericsson.com) */ -public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyParameters { +public class RestClientCarrierTechnologyParameters extends CarrierTechnologyParameters { /** The label of this carrier technology. */ public static final String RESTCLIENT_CARRIER_TECHNOLOGY_LABEL = "RESTCLIENT"; @@ -61,7 +61,7 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter * service. */ - public RESTClientCarrierTechnologyParameters() { + public RestClientCarrierTechnologyParameters() { super(); // Set the carrier technology properties for the web socket carrier technology @@ -83,10 +83,10 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara /** * Sets the URL for the REST request. * - * @param incomingURL the URL + * @param incomingUrl the URL */ - public void setURL(final String incomingURL) { - this.url = incomingURL; + public void setUrl(final String incomingUrl) { + this.url = incomingUrl; } /** diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java index 12b9a695c..4b16d30d4 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequest.java @@ -31,32 +31,67 @@ public class ApexRestRequest { private Object event; private long timestamp; + /** + * Instantiates a new apex rest request. + * + * @param executionId the execution id + * @param eventName the event name + * @param event the event + */ public ApexRestRequest(final long executionId, final String eventName, final Object event) { this.executionId = executionId; this.eventName = eventName; this.event = event; } + /** + * Gets the execution id. + * + * @return the execution id + */ public long getExecutionId() { return executionId; } + /** + * Gets the event name. + * + * @return the event name + */ public String getEventName() { return eventName; } + /** + * Gets the event. + * + * @return the event + */ public Object getEvent() { return event; } + /** + * Gets the timestamp. + * + * @return the timestamp + */ public long getTimestamp() { return timestamp; } + /** + * Sets the timestamp. + * + * @param timestamp the new timestamp + */ public void setTimestamp(final long timestamp) { this.timestamp = timestamp; } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ @Override public String toString() { return "ApexRestRequest [executionId=" + executionId + ", eventName=" + eventName + ", event=" + event diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java index 9998349db..dea839ebb 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java @@ -49,8 +49,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * This class implements an Apex event consumer that issues a REST request and returns the REST - * response to APEX as an event. + * This class implements an Apex event consumer that issues a REST request and returns the REST response to APEX as an + * event. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -63,10 +63,10 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { private static final long REST_REQUESTOR_WAIT_SLEEP_TIME = 50; // The REST parameters read from the parameter service - private RESTRequestorCarrierTechnologyParameters restConsumerProperties; + private RestRequestorCarrierTechnologyParameters restConsumerProperties; // The timeout for REST requests - private long restRequestTimeout = RESTRequestorCarrierTechnologyParameters.DEFAULT_REST_REQUEST_TIMEOUT; + private long restRequestTimeout = RestRequestorCarrierTechnologyParameters.DEFAULT_REST_REQUEST_TIMEOUT; // The event receiver that will receive events from this consumer private ApexEventReceiver eventReceiver; @@ -99,25 +99,25 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { @Override public void init(final String consumerName, final EventHandlerParameters consumerParameters, - final ApexEventReceiver incomingEventReceiver) throws ApexEventException { + final ApexEventReceiver incomingEventReceiver) throws ApexEventException { this.eventReceiver = incomingEventReceiver; this.name = consumerName; // Check and get the REST Properties if (!(consumerParameters - .getCarrierTechnologyParameters() instanceof RESTRequestorCarrierTechnologyParameters)) { - final String errorMessage = - "specified consumer properties are not applicable to REST Requestor consumer (" + this.name + ")"; + .getCarrierTechnologyParameters() instanceof RestRequestorCarrierTechnologyParameters)) { + final String errorMessage = "specified consumer properties are not applicable to REST Requestor consumer (" + + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - restConsumerProperties = - (RESTRequestorCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); + restConsumerProperties = (RestRequestorCarrierTechnologyParameters) consumerParameters + .getCarrierTechnologyParameters(); // Check if we are in peered mode if (!consumerParameters.isPeeredMode(EventHandlerPeeredMode.REQUESTOR)) { final String errorMessage = "REST Requestor consumer (" + this.name - + ") must run in peered requestor mode with a REST Requestor producer"; + + ") must run in peered requestor mode with a REST Requestor producer"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } @@ -125,7 +125,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { // Check if the HTTP method has been set if (restConsumerProperties.getHttpMethod() == null) { restConsumerProperties - .setHttpMethod(RESTRequestorCarrierTechnologyParameters.DEFAULT_REQUESTOR_HTTP_METHOD); + .setHttpMethod(RestRequestorCarrierTechnologyParameters.DEFAULT_REQUESTOR_HTTP_METHOD); } // Check if the HTTP URL has been set @@ -164,8 +164,8 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { try { incomingRestRequestQueue.add(restRequest); } catch (final Exception e) { - final String errorMessage = - "could not queue request \"" + restRequest + "\" on REST Requestor consumer (" + this.name + ")"; + final String errorMessage = "could not queue request \"" + restRequest + "\" on REST Requestor consumer (" + + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -196,7 +196,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { } /** - * Get the number of events received to date + * Get the number of events received to date. * * @return the number of events received */ @@ -238,8 +238,8 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { while (consumerThread.isAlive() && !stopOrderedFlag) { try { // Take the next event from the queue - final ApexRestRequest restRequest = - incomingRestRequestQueue.poll(REST_REQUESTOR_WAIT_SLEEP_TIME, TimeUnit.MILLISECONDS); + final ApexRestRequest restRequest = incomingRestRequestQueue.poll(REST_REQUESTOR_WAIT_SLEEP_TIME, + TimeUnit.MILLISECONDS); if (restRequest == null) { // Poll timed out, check for request timeouts timeoutExpiredRequests(); @@ -268,7 +268,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { } /** - * This method times out REST requests that have expired + * This method times out REST requests that have expired. */ private void timeoutExpiredRequests() { // Hold a list of timed out requests @@ -284,8 +284,8 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { // Interrupt timed out requests and remove them from the ongoing map for (final ApexRestRequest timedoutRequest : timedoutRequestList) { - final String errorMessage = - "REST Requestor consumer (" + this.name + "), REST request timed out: " + timedoutRequest; + final String errorMessage = "REST Requestor consumer (" + this.name + "), REST request timed out: " + + timedoutRequest; LOGGER.warn(errorMessage); ongoingRestRequestMap.remove(timedoutRequest); @@ -321,7 +321,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { private Thread restRequestThread; /** - * Constructor, initialise the request runner with the request + * Constructor, initialise the request runner with the request. * * @param request the request this runner will issue */ @@ -341,28 +341,29 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { try { // Execute the REST request - final Response response = sendEventAsRESTRequest(); + final Response response = sendEventAsRestRequest(); // Check that the event request worked if (response.getStatus() != Response.Status.OK.getStatusCode()) { final String errorMessage = "reception of response to \"" + request + "\" from URL \"" - + restConsumerProperties.getUrl() + "\" failed with status code " + response.getStatus() - + " and message \"" + response.readEntity(String.class) + "\""; + + restConsumerProperties.getUrl() + "\" failed with status code " + + response.getStatus() + " and message \"" + response.readEntity(String.class) + + "\""; throw new ApexEventRuntimeException(errorMessage); } // Get the event we received - final String eventJSONString = response.readEntity(String.class); + final String eventJsonString = response.readEntity(String.class); // Check there is content - if (eventJSONString == null || eventJSONString.trim().length() == 0) { + if (eventJsonString == null || eventJsonString.trim().length() == 0) { final String errorMessage = "received an enpty response to \"" + request + "\" from URL \"" - + restConsumerProperties.getUrl() + "\""; + + restConsumerProperties.getUrl() + "\""; throw new ApexEventRuntimeException(errorMessage); } // Send the event into Apex - eventReceiver.receiveEvent(request.getExecutionId(), eventJSONString); + eventReceiver.receiveEvent(request.getExecutionId(), eventJsonString); synchronized (eventsReceivedLock) { eventsReceived++; @@ -376,7 +377,7 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { } /** - * Stop the REST request + * Stop the REST request. */ private void stop() { restRequestThread.interrupt(); @@ -387,21 +388,24 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { * * @return the response to the REST request */ - public Response sendEventAsRESTRequest() { + public Response sendEventAsRestRequest() { switch (restConsumerProperties.getHttpMethod()) { case GET: return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON).get(); case PUT: return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON) - .put(Entity.json(request.getEvent())); + .put(Entity.json(request.getEvent())); case POST: return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON) - .post(Entity.json(request.getEvent())); + .post(Entity.json(request.getEvent())); case DELETE: return client.target(restConsumerProperties.getUrl()).request(APPLICATION_JSON).delete(); + + default: + break; } return null; diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java index 721dfb683..69ad05b27 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorProducer.java @@ -44,7 +44,7 @@ public class ApexRestRequestorProducer implements ApexEventProducer { private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestRequestorProducer.class); // The REST carrier properties - private RESTRequestorCarrierTechnologyParameters restProducerProperties; + private RestRequestorCarrierTechnologyParameters restProducerProperties; // The name for this producer private String name = null; @@ -68,14 +68,14 @@ public class ApexRestRequestorProducer implements ApexEventProducer { // Check and get the REST Properties if (!(producerParameters - .getCarrierTechnologyParameters() instanceof RESTRequestorCarrierTechnologyParameters)) { + .getCarrierTechnologyParameters() instanceof RestRequestorCarrierTechnologyParameters)) { final String errorMessage = "specified consumer properties are not applicable to REST requestor producer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } restProducerProperties = - (RESTRequestorCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + (RestRequestorCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); // Check if we are in peered mode if (!producerParameters.isPeeredMode(EventHandlerPeeredMode.REQUESTOR)) { diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java index 65eb731ed..acd5e52e8 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java @@ -37,9 +37,9 @@ import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnolo * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyParameters { +public class RestRequestorCarrierTechnologyParameters extends CarrierTechnologyParameters { /** The supported HTTP methods. */ - public enum HTTP_METHOD { + public enum HttpMethod { GET, PUT, POST, DELETE } @@ -55,19 +55,19 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP ApexRestRequestorConsumer.class.getCanonicalName(); /** The default HTTP method for request events. */ - public static final HTTP_METHOD DEFAULT_REQUESTOR_HTTP_METHOD = HTTP_METHOD.GET; + public static final HttpMethod DEFAULT_REQUESTOR_HTTP_METHOD = HttpMethod.GET; /** The default timeout for REST requests. */ public static final long DEFAULT_REST_REQUEST_TIMEOUT = 500; private String url = null; - private HTTP_METHOD httpMethod = null; + private HttpMethod httpMethod = null; /** * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter * service. */ - public RESTRequestorCarrierTechnologyParameters() { + public RestRequestorCarrierTechnologyParameters() { super(); // Set the carrier technology properties for the web socket carrier technology @@ -88,10 +88,10 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP /** * Sets the URL for the REST request. * - * @param incomingURL the URL + * @param incomingUrl the URL */ - public void setURL(final String incomingURL) { - this.url = incomingURL; + public void setUrl(final String incomingUrl) { + this.url = incomingUrl; } /** @@ -99,7 +99,7 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP * * @return the HTTP method */ - public HTTP_METHOD getHttpMethod() { + public HttpMethod getHttpMethod() { return httpMethod; } @@ -108,7 +108,7 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP * * @param httpMethod the HTTP method */ - public void setHttpMethod(final HTTP_METHOD httpMethod) { + public void setHttpMethod(final HttpMethod httpMethod) { this.httpMethod = httpMethod; } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestor.java index 3db0f1467..051647339 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestor.java @@ -48,7 +48,10 @@ import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.service.engine.main.ApexMain; -public class TestRESTRequestor { +/** + * The Class TestRestRequestor. + */ +public class TestRestRequestor { private static final String BASE_URI = "http://localhost:32801/TestRESTRequestor"; private static HttpServer server; @@ -58,6 +61,11 @@ public class TestRESTRequestor { private final PrintStream stdout = System.out; private final PrintStream stderr = System.err; + /** + * Sets the up. + * + * @throws Exception the exception + */ @BeforeClass public static void setUp() throws Exception { final ResourceConfig rc = new ResourceConfig(TestRestRequestorEndpoint.class); @@ -68,6 +76,11 @@ public class TestRESTRequestor { } } + /** + * Tear down. + * + * @throws Exception the exception + */ @AfterClass public static void tearDown() throws Exception { server.shutdownNow(); @@ -77,16 +90,27 @@ public class TestRESTRequestor { new File("src/test/resources/events/EventsOutMulti1.json").delete(); } + /** + * Reset counters. + */ @Before public void resetCounters() { TestRestRequestorEndpoint.resetCounters(); } + /** + * Test rest requestor get. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testRESTRequestorGet() throws MessagingException, ApexException, IOException { + public void testRestRequestorGet() throws MessagingException, ApexException, IOException { final Client client = ClientBuilder.newClient(); - final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGet.json" }; + final String[] args = + { "src/test/resources/prodcons/File2RESTRequest2FileGet.json" }; final ApexMain apexMain = new ApexMain(args); // Wait for the required amount of events to be received or for 10 seconds @@ -95,7 +119,7 @@ public class TestRESTRequestor { ThreadUtilities.sleep(100); final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); final String responseString = response.readEntity(String.class); @@ -115,11 +139,19 @@ public class TestRESTRequestor { assertEquals(Double.valueOf(50.0), getsSoFar); } + /** + * Test REST requestor put. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testRESTRequestorPut() throws MessagingException, ApexException, IOException { + public void testRestRequestorPut() throws MessagingException, ApexException, IOException { final Client client = ClientBuilder.newClient(); - final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FilePut.json" }; + final String[] args = + { "src/test/resources/prodcons/File2RESTRequest2FilePut.json" }; final ApexMain apexMain = new ApexMain(args); // Wait for the required amount of events to be received or for 10 seconds @@ -128,7 +160,7 @@ public class TestRESTRequestor { ThreadUtilities.sleep(100); final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); final String responseString = response.readEntity(String.class); @@ -148,11 +180,19 @@ public class TestRESTRequestor { assertEquals(Double.valueOf(50.0), putsSoFar); } + /** + * Test REST requestor post. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testRESTRequestorPost() throws MessagingException, ApexException, IOException { + public void testRestRequestorPost() throws MessagingException, ApexException, IOException { final Client client = ClientBuilder.newClient(); - final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FilePost.json" }; + final String[] args = + { "src/test/resources/prodcons/File2RESTRequest2FilePost.json" }; final ApexMain apexMain = new ApexMain(args); // Wait for the required amount of events to be received or for 10 seconds @@ -161,7 +201,7 @@ public class TestRESTRequestor { ThreadUtilities.sleep(100); final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); final String responseString = response.readEntity(String.class); @@ -181,11 +221,19 @@ public class TestRESTRequestor { assertEquals(Double.valueOf(50.0), postsSoFar); } + /** + * Test REST requestor delete. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testRESTRequestorDelete() throws MessagingException, ApexException, IOException { + public void testRestRequestorDelete() throws MessagingException, ApexException, IOException { final Client client = ClientBuilder.newClient(); - final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileDelete.json" }; + final String[] args = + { "src/test/resources/prodcons/File2RESTRequest2FileDelete.json" }; final ApexMain apexMain = new ApexMain(args); // Wait for the required amount of events to be received or for 10 seconds @@ -194,7 +242,7 @@ public class TestRESTRequestor { ThreadUtilities.sleep(100); final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); final String responseString = response.readEntity(String.class); @@ -214,11 +262,19 @@ public class TestRESTRequestor { assertEquals(Double.valueOf(50.0), deletesSoFar); } + /** + * Test REST requestor multi inputs. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testRESTRequestorMultiInputs() throws MessagingException, ApexException, IOException { + public void testRestRequestorMultiInputs() throws MessagingException, ApexException, IOException { final Client client = ClientBuilder.newClient(); - final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json" }; + final String[] args = + { "src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json" }; final ApexMain apexMain = new ApexMain(args); // Wait for the required amount of events to be received or for 10 seconds @@ -227,7 +283,7 @@ public class TestRESTRequestor { ThreadUtilities.sleep(100); final Response response = client.target("http://localhost:32801/TestRESTRequestor/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); final String responseString = response.readEntity(String.class); @@ -249,12 +305,20 @@ public class TestRESTRequestor { ThreadUtilities.sleep(1000); } + /** + * Test REST requestor producer alone. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testRESTRequestorProducerAlone() throws MessagingException, ApexException, IOException { + public void testRestRequestorProducerAlone() throws MessagingException, ApexException, IOException { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json" }; + final String[] args = + { "src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json" }; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(200); @@ -265,16 +329,24 @@ public class TestRESTRequestor { System.setOut(stdout); System.setErr(stderr); - assertTrue(outString.contains( - "REST Requestor producer (RestRequestorProducer) must run in peered requestor mode with a REST Requestor consumer")); + assertTrue(outString.contains("REST Requestor producer (RestRequestorProducer) " + + "must run in peered requestor mode with a REST Requestor consumer")); } + /** + * Test REST requestor consumer alone. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test - public void testRESTRequestorConsumerAlone() throws MessagingException, ApexException, IOException { + public void testRestRequestorConsumerAlone() throws MessagingException, ApexException, IOException { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json" }; + final String[] args = + { "src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json" }; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(200); @@ -285,7 +357,7 @@ public class TestRESTRequestor { System.setOut(stdout); System.setErr(stderr); - assertTrue(outString.contains( - "peer \"RestRequestorProducer for peered mode REQUESTOR does not exist or is not defined with the same peered mode")); + assertTrue(outString.contains("peer \"RestRequestorProducer for peered mode REQUESTOR " + + "does not exist or is not defined with the same peered mode")); } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java index 4977b3efb..0de34eb9b 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRestRequestorEndpoint.java @@ -34,6 +34,9 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.core.Response; +/** + * The Class TestRestRequestorEndpoint. + */ @Path("/apex") public class TestRestRequestorEndpoint { @@ -50,6 +53,9 @@ public class TestRestRequestorEndpoint { + "\"TestMatchCase\": 2,\n" + "\"TestTimestamp\": " + System.currentTimeMillis() + ",\n" + "\"TestTemperature\": 9080.866\n" + "}"; + /** + * Reset counters. + */ public static void resetCounters() { postMessagesReceived = 0; putMessagesReceived = 0; @@ -58,6 +64,11 @@ public class TestRestRequestorEndpoint { deleteMessagesReceived = 0; } + /** + * Service get stats. + * + * @return the response + */ @Path("/event/Stats") @GET public Response serviceGetStats() { @@ -71,6 +82,11 @@ public class TestRestRequestorEndpoint { .build(); } + /** + * Service get event. + * + * @return the response + */ @Path("/event/GetEvent") @GET public Response serviceGetEvent() { @@ -81,18 +97,34 @@ public class TestRestRequestorEndpoint { return Response.status(200).entity(EVENT_STRING).build(); } + /** + * Service get empty event. + * + * @return the response + */ @Path("/event/GetEmptyEvent") @GET public Response serviceGetEmptyEvent() { return Response.status(200).build(); } + /** + * Service get event bad response. + * + * @return the response + */ @Path("/event/GetEventBadResponse") @GET public Response serviceGetEventBadResponse() { return Response.status(400).build(); } + /** + * Service post request. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/PostEvent") @POST public Response servicePostRequest(final String jsonString) { @@ -111,12 +143,24 @@ public class TestRestRequestorEndpoint { return Response.status(200).entity(EVENT_STRING).build(); } + /** + * Service post request bad response. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/PostEventBadResponse") @POST public Response servicePostRequestBadResponse(final String jsonString) { return Response.status(400).build(); } + /** + * Service put request. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/PutEvent") @PUT public Response servicePutRequest(final String jsonString) { @@ -135,6 +179,12 @@ public class TestRestRequestorEndpoint { return Response.status(200).entity(EVENT_STRING).build(); } + /** + * Service delete request. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/DeleteEvent") @DELETE public Response serviceDeleteRequest(final String jsonString) { @@ -145,6 +195,12 @@ public class TestRestRequestorEndpoint { return Response.status(200).entity(EVENT_STRING).build(); } + /** + * Service delete request bad response. + * + * @param jsonString the json string + * @return the response + */ @Path("/event/DeleteEventBadResponse") @DELETE public Response serviceDeleteRequestBadResponse(final String jsonString) { diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json index 6e12c0b1f..46da3970a 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileDelete.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -29,7 +29,7 @@ "RestRequestorConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRESTRequestor/apex/event/DeleteEvent", "httpMethod": "DELETE", @@ -49,7 +49,7 @@ "RestRequestorProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json index d0879eb73..3c1d314fe 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGet.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -29,7 +29,7 @@ "RestRequestorConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent", "httpMethod": "GET", @@ -49,7 +49,7 @@ "RestRequestorProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json index b957b61de..9ebe89df5 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -29,7 +29,7 @@ "RestRequestorConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent", "httpMethod": "GET", @@ -49,7 +49,7 @@ "RestRequestorProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json index ba1c997f5..424d2b454 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetMulti.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -29,7 +29,7 @@ "RestRequestorConsumer0": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent", "httpMethod": "GET", @@ -58,7 +58,7 @@ "RestRequestorConsumer1": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent", "httpMethod": "GET", @@ -78,7 +78,7 @@ "RestRequestorProducer0": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" @@ -103,7 +103,7 @@ "RestRequestorProducer1": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json index a635e6c72..4fcbf59d9 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -31,7 +31,7 @@ "RestRequestorProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json index 9db89ce89..fe5af67ee 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePost.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -29,7 +29,7 @@ "RestRequestorConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRESTRequestor/apex/event/PostEvent", "httpMethod": "POST", @@ -49,7 +49,7 @@ "RestRequestorProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json index 3eebe3d8a..e78446447 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/prodcons/File2RESTRequest2FilePut.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -29,7 +29,7 @@ "RestRequestorConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRESTRequestor/apex/event/PutEvent", "httpMethod": "PUT", @@ -49,7 +49,7 @@ "RestRequestorProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java index 8cf0c8f9c..94063af20 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java @@ -56,9 +56,6 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { // The amount of time to wait in milliseconds between checks that the consumer thread has stopped private static final long REST_SERVER_CONSUMER_WAIT_SLEEP_TIME = 50; - // The REST parameters read from the parameter service - private RESTServerCarrierTechnologyParameters restConsumerProperties; - // The event receiver that will receive events from this consumer private ApexEventReceiver eventReceiver; @@ -84,7 +81,7 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { * * @return the next candidate value for a Execution ID */ - private static synchronized long getNextExecutionID() { + private static synchronized long getNextExecutionId() { return nextExecutionID.getAndIncrement(); } @@ -102,14 +99,16 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { this.name = consumerName; // Check and get the REST Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RESTServerCarrierTechnologyParameters)) { + if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RestServerCarrierTechnologyParameters)) { final String errorMessage = "specified consumer properties are not applicable to REST Server consumer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - restConsumerProperties = - (RESTServerCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); + + // The REST parameters read from the parameter service + RestServerCarrierTechnologyParameters restConsumerProperties = + (RestServerCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); // Check if we are in synchronous mode if (!consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) { @@ -131,12 +130,12 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { } // Compose the URI for the standalone server - final String baseURI = String.format(BASE_URI_TEMPLATE, restConsumerProperties.getHost(), + final String baseUrl = String.format(BASE_URI_TEMPLATE, restConsumerProperties.getHost(), restConsumerProperties.getPort()); // Instantiate the standalone server final ResourceConfig rc = new ResourceConfig(RestServerEndpoint.class, AccessControlFilter.class); - server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseURI), rc); + server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUrl), rc); while (!server.isStarted()) { ThreadUtilities.sleep(REST_SERVER_CONSUMER_WAIT_SLEEP_TIME); @@ -201,10 +200,11 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { */ public Response receiveEvent(final String event) { // Get an execution ID for the event - final long executionId = getNextExecutionID(); + final long executionId = getNextExecutionId(); if (LOGGER.isDebugEnabled()) { - LOGGER.debug(name + ": sending event " + name + '_' + executionId + " to Apex, event=" + event); + String message = name + ": sending event " + name + '_' + executionId + " to Apex, event=" + event; + LOGGER.debug(message); } try { @@ -222,7 +222,8 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { // Wait until the event is in the cache of events sent to apex do { ThreadUtilities.sleep(REST_SERVER_CONSUMER_WAIT_SLEEP_TIME); - } while (!synchronousEventCache.existsEventToApex(executionId)); + } + while (!synchronousEventCache.existsEventToApex(executionId)); // Now wait for the reply or for the event to time put do { @@ -238,7 +239,8 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { // Return the event as a response to the call return Response.status(Response.Status.OK.getStatusCode()).entity(responseEvent.toString()).build(); } - } while (synchronousEventCache.existsEventToApex(executionId)); + } + while (synchronousEventCache.existsEventToApex(executionId)); // The event timed out final String errorMessage = "processing of event on event consumer " + name + " timed out, event=" + event; diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java index e51482ce4..cacdb3408 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java @@ -41,9 +41,6 @@ import org.slf4j.LoggerFactory; public class ApexRestServerProducer implements ApexEventProducer { private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestServerProducer.class); - // The REST carrier properties - private RESTServerCarrierTechnologyParameters restProducerProperties; - // The name for this producer private String name = null; @@ -62,14 +59,16 @@ public class ApexRestServerProducer implements ApexEventProducer { this.name = producerName; // Check and get the REST Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof RESTServerCarrierTechnologyParameters)) { + if (!(producerParameters.getCarrierTechnologyParameters() instanceof RestServerCarrierTechnologyParameters)) { final String errorMessage = "specified producer properties are not applicable to REST Server producer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - restProducerProperties = - (RESTServerCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + + // The REST carrier properties + RestServerCarrierTechnologyParameters restProducerProperties = + (RestServerCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); // Check if host and port are defined if (restProducerProperties.getHost() != null || restProducerProperties.getPort() != -1 @@ -131,7 +130,8 @@ public class ApexRestServerProducer implements ApexEventProducer { @Override public void sendEvent(final long executionId, final String eventName, final Object event) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug(name + ": event " + executionId + ':' + eventName + " recevied from Apex, event=" + event); + String message = name + ": event " + executionId + ':' + eventName + " recevied from Apex, event=" + event; + LOGGER.debug(message); } // If we are not synchronized, then exit @@ -163,5 +163,7 @@ public class ApexRestServerProducer implements ApexEventProducer { * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#stop() */ @Override - public void stop() {} + public void stop() { + // Implementation not required on this class + } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java index cd7f388f2..76ec577b8 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java @@ -27,7 +27,7 @@ import org.onap.policy.common.parameters.ValidationStatus; /** * Apex parameters for REST as an event carrier technology with Apex as a REST client. * - * The parameters for this plugin are: + * <p>The parameters for this plugin are: * <ol> * <li>standalone: A flag indicating if APEX should start a standalone HTTP server to process REST requests (true) or * whether it should use an underlying servlet infrastructure such as Apache Tomcat (False). This parameter is legal @@ -40,7 +40,7 @@ import org.onap.policy.common.parameters.ValidationStatus; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyParameters { +public class RestServerCarrierTechnologyParameters extends CarrierTechnologyParameters { // @formatter:off private static final int MIN_USER_PORT = 1024; private static final int MAX_USER_PORT = 65535; @@ -64,7 +64,7 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter * service. */ - public RESTServerCarrierTechnologyParameters() { + public RestServerCarrierTechnologyParameters() { super(); // Set the carrier technology properties for the web socket carrier technology diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java index beee10fd0..f8524fcfd 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java @@ -57,21 +57,21 @@ public class RestServerEndpoint { // This map is used to hold all the REST server event inputs. This is used to determine which consumer to send input // events to private static Map<String, ApexRestServerConsumer> consumerMap = - new LinkedHashMap<String, ApexRestServerConsumer>(); + new LinkedHashMap<>(); // The ID of this event input. This gets injected from the URL. @PathParam("eventInput") - private String eventInputID = null; + private String eventInputId = null; /** * Register an Apex consumer with the REST server end point. * - * @param consumerEventInputID The event input ID that indicates this consumer shoud be used + * @param consumerEventInputId The event input ID that indicates this consumer shoud be used * @param consumer The consumer to register */ - public static void registerApexRestServerConsumer(final String consumerEventInputID, + public static void registerApexRestServerConsumer(final String consumerEventInputId, final ApexRestServerConsumer consumer) { - consumerMap.put(consumerEventInputID, consumer); + consumerMap.put(consumerEventInputId, consumer); } /** @@ -102,7 +102,8 @@ public class RestServerEndpoint { postEventMessagesReceived++; if (LOGGER.isDebugEnabled()) { - LOGGER.debug("event input " + eventInputID + ", received POST of event \"" + jsonString + "\""); + String message = "event input " + eventInputId + ", received POST of event \"" + jsonString + "\""; + LOGGER.debug(message); } // Common handler method for POST and PUT requests @@ -121,7 +122,8 @@ public class RestServerEndpoint { putEventMessagesReceived++; if (LOGGER.isDebugEnabled()) { - LOGGER.debug("event input \"" + eventInputID + "\", received PUT of event \"" + jsonString + "\""); + String message = "event input \"" + eventInputId + "\", received PUT of event \"" + jsonString + "\""; + LOGGER.debug(message); } // Common handler method for POST and PUT requests @@ -136,10 +138,10 @@ public class RestServerEndpoint { */ private Response handleEvent(final String jsonString) { // Find the correct consumer for this REST message - final ApexRestServerConsumer eventConsumer = consumerMap.get(eventInputID); + final ApexRestServerConsumer eventConsumer = consumerMap.get(eventInputId); if (eventConsumer == null) { final String errorMessage = - "event input " + eventInputID + " is not defined in the Apex configuration file"; + "event input " + eventInputId + " is not defined in the Apex configuration file"; LOGGER.warn(errorMessage); return Response.status(Response.Status.BAD_REQUEST.getStatusCode()) .entity("{'errorMessage', '" + errorMessage + "'}").build(); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java index e80efa2ee..fe3e47b82 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java @@ -50,9 +50,6 @@ public class ApexWebSocketConsumer implements ApexEventConsumer, WsStringMessage // Get a reference to the logger private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketConsumer.class); - // The Web Socket properties - private WEBSOCKETCarrierTechnologyParameters webSocketConsumerProperties; - // The web socket messager, may be WS a server or a client private WsStringMessager wsStringMessager; @@ -79,12 +76,14 @@ public class ApexWebSocketConsumer implements ApexEventConsumer, WsStringMessage this.name = consumerName; // Check and get the Kafka Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof WEBSOCKETCarrierTechnologyParameters)) { + if (!(consumerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) { LOGGER.warn("specified consumer properties are not applicable to a web socket consumer"); throw new ApexEventException("specified consumer properties are not applicable to a web socket consumer"); } - webSocketConsumerProperties = - (WEBSOCKETCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); + + // The Web Socket properties + WebSocketCarrierTechnologyParameters webSocketConsumerProperties = + (WebSocketCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); // Check if this is a server or a client Web Socket if (webSocketConsumerProperties.isWsClient()) { diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java index 6be8a3d1a..7dd1ab947 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java @@ -46,9 +46,6 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage // Get a reference to the logger private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketProducer.class); - // The Web Socket properties - private WEBSOCKETCarrierTechnologyParameters webSocketProducerProperties; - // The web socket messager, may be WS a server or a client private WsStringMessager wsStringMessager; @@ -60,23 +57,25 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage @Override public void init(final String producerName, final EventHandlerParameters producerParameters) - throws ApexEventException { + throws ApexEventException { this.name = producerName; // Check and get the web socket Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof WEBSOCKETCarrierTechnologyParameters)) { - LOGGER.warn( - "specified producer properties for " + this.name + "are not applicable to a web socket producer"); + if (!(producerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) { + String message = "specified producer properties for " + this.name + + "are not applicable to a web socket producer"; + LOGGER.warn(message); throw new ApexEventException("specified producer properties are not applicable to a web socket producer"); } - webSocketProducerProperties = - (WEBSOCKETCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + // The Web Socket properties + WebSocketCarrierTechnologyParameters webSocketProducerProperties = + (WebSocketCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); // Check if this is a server or a client Web Socket if (webSocketProducerProperties.isWsClient()) { // Create a WS client wsStringMessager = new WsStringMessageClient(webSocketProducerProperties.getHost(), - webSocketProducerProperties.getPort()); + webSocketProducerProperties.getPort()); } else { wsStringMessager = new WsStringMessageServer(webSocketProducerProperties.getPort()); } @@ -85,7 +84,8 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage try { wsStringMessager.start(this); } catch (final MessagingException e) { - LOGGER.warn("could not start web socket producer (" + this.name + ")"); + String message = "could not start web socket producer (" + this.name + ")"; + LOGGER.warn(message); } } @@ -130,8 +130,8 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage @Override public void sendEvent(final long executionId, final String eventName, final Object event) { // Check if this is a synchronized event, if so we have received a reply - final SynchronousEventCache synchronousEventCache = - (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS); + final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap + .get(EventHandlerPeeredMode.SYNCHRONOUS); if (synchronousEventCache != null) { synchronousEventCache.removeCachedEventToApexIfExists(executionId); } @@ -160,7 +160,8 @@ public class ApexWebSocketProducer implements ApexEventProducer, WsStringMessage */ @Override public void receiveString(final String messageString) { - LOGGER.warn("received message \"" + messageString + "\" on web socket producer (" + this.name - + ") , no messages should be received on a web socket producer"); + String message = "received message \"" + messageString + "\" on web socket producer (" + this.name + + ") , no messages should be received on a web socket producer"; + LOGGER.warn(message); } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java index e04a81d1d..9febeb45b 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WebSocketCarrierTechnologyParameters.java @@ -29,7 +29,7 @@ import org.onap.policy.common.parameters.ValidationStatus; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParameters { +public class WebSocketCarrierTechnologyParameters extends CarrierTechnologyParameters { // @formatter:off private static final int MIN_USER_PORT = 1024; private static final int MAX_USER_PORT = 65535; @@ -57,7 +57,7 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam * Constructor to create a web socket carrier technology parameters instance and register the instance with the * parameter service. */ - public WEBSOCKETCarrierTechnologyParameters() { + public WebSocketCarrierTechnologyParameters() { super(); // Set the carrier technology properties for the web socket carrier technology diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java index 6c21070c2..ca02709fe 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSObjectEventConverter.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java @@ -33,24 +33,23 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * The Class Apex2JMSObjectEventConverter converts {@link ApexEvent} instances into string instances of - * object message events for JMS. + * The Class Apex2JMSObjectEventConverter converts {@link ApexEvent} instances into string instances of object message + * events for JMS. * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConverter { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JMSObjectEventConverter.class); +public final class Apex2JmsObjectEventConverter implements ApexEventProtocolConverter { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JmsObjectEventConverter.class); // JMS event protocol parameters on the consumer (JMS->Apex) sides - private JMSObjectEventProtocolParameters eventProtocolParameters = null; + private JmsObjectEventProtocolParameters eventProtocolParameters = null; /** * Constructor to create the Apex to JMS Object converter. * - * @throws ApexEventException - * the apex event exception + * @throws ApexEventException the apex event exception */ - public Apex2JMSObjectEventConverter() throws ApexEventException { + public Apex2JmsObjectEventConverter() throws ApexEventException { // Nothing specific to initiate for this plugin } @@ -59,13 +58,13 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv // Check if properties have been set for JMS object event conversion as a consumer. They may not be set because // JMS may not be in use // on both sides of Apex - if (!(parameters instanceof JMSObjectEventProtocolParameters)) { + if (!(parameters instanceof JmsObjectEventProtocolParameters)) { final String errormessage = "specified Event Protocol Parameters properties of type \"" + parameters.getClass().getCanonicalName() + "\" are not applicable to a " - + Apex2JMSObjectEventConverter.class.getName() + " converter"; + + Apex2JmsObjectEventConverter.class.getName() + " converter"; LOGGER.error(errormessage); } else { - this.eventProtocolParameters = (JMSObjectEventProtocolParameters) parameters; + this.eventProtocolParameters = (JmsObjectEventProtocolParameters) parameters; } } @@ -101,7 +100,8 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv // Check that the consumer parameters for JMS->Apex messaging have been set if (eventProtocolParameters == null) { - final String errorMessage = "consumer parameters for JMS events consumed by Apex are not set in the Apex configuration for this engine"; + final String errorMessage = "consumer parameters for JMS events consumed by " + + "Apex are not set in the Apex configuration for this engine"; LOGGER.debug(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -114,7 +114,7 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv jmsIncomingObject.toString().getClass().getPackage().getName(), eventProtocolParameters.getIncomingEventSource(), eventProtocolParameters.getIncomingEventTarget()); - // @formattter:on + // @formatter:on // Set the data on the apex event as the incoming object apexEvent.put(jmsIncomingObject.getClass().getSimpleName(), jmsIncomingObject); @@ -128,7 +128,8 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv /* * (non-Javadoc) * - * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent(org.onap.policy.apex.service.engine.event.ApexEvent) + * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent + * (org.onap.policy.apex.service.engine.event.ApexEvent) */ @Override public Object fromApexEvent(final ApexEvent apexEvent) throws ApexEventException { @@ -140,7 +141,8 @@ public final class Apex2JMSObjectEventConverter implements ApexEventProtocolConv // Check that the Apex event has a single parameter if (apexEvent.size() != 1) { - final String errorMessage = "event processing failed, Apex event must have one and only one parameter for JMS Object handling"; + final String errorMessage = "event processing failed, " + + "Apex event must have one and only one parameter for JMS Object handling"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java index e845a4a08..1c44dd111 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JMSTextEventConverter.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsTextEventConverter.java @@ -26,26 +26,19 @@ import java.util.List; import org.onap.policy.apex.service.engine.event.ApexEvent; import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** * The Class Apex2JMSTextEventConverter converts {@link ApexEvent} instances into string instances of * text message events for JMS. It is a proxy for the built in - * {@link org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter} plugin. + * {@link org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter} plugin. * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public final class Apex2JMSTextEventConverter extends Apex2JSONEventConverter { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JMSTextEventConverter.class); - - /** - * Constructor to create the Apex to JMS Object converter. - * - * @throws ApexEventException the apex event exception - */ - public Apex2JMSTextEventConverter() throws ApexEventException {} +public final class Apex2JmsTextEventConverter extends Apex2JsonEventConverter { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JmsTextEventConverter.class); /* * (non-Javadoc) diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java index 83aef4e9d..3c15a7825 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSObjectEventProtocolParameters.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsObjectEventProtocolParameters.java @@ -25,8 +25,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame /** * Event protocol parameters for JMS Object messages as an event protocol. * - * <p> - * On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows: + * <p>On reception of an a JMS {@code javax.jms.ObjectMessage}, the JMS Object plugin unmarshals the message as follows: * <ol> * <li>It extracts the Java object from the {@code javax.jms.ObjectMessage} instance.</li> * <li>It creates an {@link org.onap.policy.apex.service.engine.event.ApexEvent} instance to hold the java object.</li> @@ -40,11 +39,11 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame * <li>It puts a single entry into the Apex event map with the the simple class name of the incoming Java object being * the key of the entry and the actual incoming object as the value of the entry.</li> * </ol> - * <p> - * When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin marshals - * the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance. - * <p> - * The parameters for this plugin are: + * + * <p>When sending an object to JMS, the plugin expects to receive an Apex event with a single entry. The plugin + * marshals the value of that entry to an object that can be sent by JMS as a {@code javax.jms.ObjectMessage} instance. + * + * <p>The parameters for this plugin are: * <ol> * <li>incomingEventSuffix: The suffix to append to the simple name of incoming Java class instances when they are * encapsulated in Apex events. The parameter defaults to the string value {@code IncomingEvent}.</li> @@ -58,7 +57,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class JMSObjectEventProtocolParameters extends EventProtocolParameters { +public class JmsObjectEventProtocolParameters extends EventProtocolParameters { /** The label of this event protocol. */ public static final String JMS_OBJECT_EVENT_PROTOCOL_LABEL = "JMSOBJECT"; @@ -77,16 +76,17 @@ public class JMSObjectEventProtocolParameters extends EventProtocolParameters { //@formatter:off /** - * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter service. + * Constructor to create a JSON event protocol parameter instance and register the instance with the + * parameter service. */ - public JMSObjectEventProtocolParameters() { - super(JMSObjectEventProtocolParameters.class.getCanonicalName()); + public JmsObjectEventProtocolParameters() { + super(JmsObjectEventProtocolParameters.class.getCanonicalName()); // Set the event protocol properties for the JMS Text event protocol this.setLabel(JMS_OBJECT_EVENT_PROTOCOL_LABEL); // Set the event protocol plugin class - this.setEventProtocolPluginClass(Apex2JMSObjectEventConverter.class.getCanonicalName()); + this.setEventProtocolPluginClass(Apex2JmsObjectEventConverter.class.getCanonicalName()); } /** diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java index b3a9154ff..67b211a08 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JMSTextEventProtocolParameters.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/JmsTextEventProtocolParameters.java @@ -20,23 +20,23 @@ package org.onap.policy.apex.plugins.event.protocol.jms; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; /** * Event protocol parameters for JMS Text messages as an event protocol. - * <p> - * Text messages received and sent over JMS in ~Text format are assumed to be in a JSON format that Apex can understand. - * Therefore this plugin is a subclass of the built in JSON event protocol plugin. - * <p> - * On reception of a JMS {@code javax.jms.TextMessage} message, the JMS Text plugin unmarshals the message the JMS text - * message and passes it to its JSON superclass unmarshaling for processing. - * <p> - * When sending an Apex event, the plugin uses its underlying JSON superclass to marshal the event to a JSON string and - * passes that string to the JSON carrier plugin for sending. + * + * <p>Text messages received and sent over JMS in ~Text format are assumed to be in a JSON format that Apex can + * understand. Therefore this plugin is a subclass of the built in JSON event protocol plugin. + * + * <p>On reception of a JMS {@code javax.jms.TextMessage} message, the JMS Text plugin unmarshals the message the JMS + * text message and passes it to its JSON superclass unmarshaling for processing. + * + * <p>When sending an Apex event, the plugin uses its underlying JSON superclass to marshal the event to a JSON string + * and passes that string to the JSON carrier plugin for sending. * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class JMSTextEventProtocolParameters extends JSONEventProtocolParameters { +public class JmsTextEventProtocolParameters extends JsonEventProtocolParameters { /** The label of this event protocol. */ public static final String JMS_TEXT_EVENT_PROTOCOL_LABEL = "JMSTEXT"; @@ -44,13 +44,13 @@ public class JMSTextEventProtocolParameters extends JSONEventProtocolParameters * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter * service. */ - public JMSTextEventProtocolParameters() { - super(JMSTextEventProtocolParameters.class.getCanonicalName(), JMS_TEXT_EVENT_PROTOCOL_LABEL); + public JmsTextEventProtocolParameters() { + super(JmsTextEventProtocolParameters.class.getCanonicalName(), JMS_TEXT_EVENT_PROTOCOL_LABEL); // Set the event protocol properties for the JMS Text event protocol this.setLabel(JMS_TEXT_EVENT_PROTOCOL_LABEL); // Set the event protocol plugin class - this.setEventProtocolPluginClass(Apex2JMSTextEventConverter.class.getCanonicalName()); + this.setEventProtocolPluginClass(Apex2JmsTextEventConverter.class.getCanonicalName()); } } diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XMLEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java index 76bae6833..767c24fdd 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XMLEventConverter.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java @@ -56,8 +56,8 @@ import org.xml.sax.SAXException; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public final class Apex2XMLEventConverter implements ApexEventProtocolConverter { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2XMLEventConverter.class); +public final class Apex2XmlEventConverter implements ApexEventProtocolConverter { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2XmlEventConverter.class); private static final String MODEL_SCHEMA_NAME = "xml/apex-event.xsd"; @@ -71,11 +71,11 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter * * @throws ApexEventException the apex event exception */ - public Apex2XMLEventConverter() throws ApexEventException { + public Apex2XmlEventConverter() throws ApexEventException { try { - final URL schemaURL = ResourceUtils.getUrlResource(MODEL_SCHEMA_NAME); + final URL schemaUrl = ResourceUtils.getUrlResource(MODEL_SCHEMA_NAME); final Schema apexEventSchema = - SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaURL); + SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl); final JAXBContext jaxbContext = JAXBContext.newInstance(XMLApexEvent.class); @@ -101,7 +101,9 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter * parameters. eventprotocol.EventProtocolParameters) */ @Override - public void init(final EventProtocolParameters parameters) {} + public void init(final EventProtocolParameters parameters) { + // No initialization necessary on this class + } /* * (non-Javadoc) @@ -149,7 +151,7 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter } // Return the event in a single element - final ArrayList<ApexEvent> eventList = new ArrayList<ApexEvent>(); + final ArrayList<ApexEvent> eventList = new ArrayList<>(); eventList.add(apexEvent); return eventList; } @@ -170,7 +172,7 @@ public final class Apex2XMLEventConverter implements ApexEventProtocolConverter } // Get the Apex event data - final List<XMLApexEventData> xmlDataList = new ArrayList<XMLApexEventData>(); + final List<XMLApexEventData> xmlDataList = new ArrayList<>(); try { for (final Entry<String, Object> apexDataEntry : apexEvent.entrySet()) { diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventProtocolParameters.java index 0eeb497a1..9f0ee0795 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventProtocolParameters.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventProtocolParameters.java @@ -27,7 +27,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTo * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class XMLEventProtocolParameters extends EventProtocolTextTokenDelimitedParameters { +public class XmlEventProtocolParameters extends EventProtocolTextTokenDelimitedParameters { /** The label of this carrier technology. */ public static final String XML_EVENT_PROTOCOL_LABEL = "XML"; @@ -38,8 +38,8 @@ public class XMLEventProtocolParameters extends EventProtocolTextTokenDelimitedP * Constructor to create a JSON event protocol parameter instance and register the instance with the parameter * service. */ - public XMLEventProtocolParameters() { - super(XMLEventProtocolParameters.class.getCanonicalName()); + public XmlEventProtocolParameters() { + super(XmlEventProtocolParameters.class.getCanonicalName()); // Set the event protocol properties for the XML event protocol this.setLabel(XML_EVENT_PROTOCOL_LABEL); @@ -48,6 +48,6 @@ public class XMLEventProtocolParameters extends EventProtocolTextTokenDelimitedP this.setStartDelimiterToken(XML_TEXT_DELIMITER_TOKEN); // Set the event protocol plugin class - this.setEventProtocolPluginClass(Apex2XMLEventConverter.class.getCanonicalName()); + this.setEventProtocolPluginClass(Apex2XmlEventConverter.class.getCanonicalName()); } } diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLEventHandler.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlEventHandler.java index a62cc24cf..1e42bef30 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLEventHandler.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlEventHandler.java @@ -38,8 +38,8 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestXMLEventHandler { - private static final XLogger logger = XLoggerFactory.getXLogger(TestXMLEventHandler.class); +public class TestXmlEventHandler { + private static final XLogger logger = XLoggerFactory.getXLogger(TestXmlEventHandler.class); /** * Test XML to apex event. @@ -47,16 +47,16 @@ public class TestXMLEventHandler { * @throws ApexException on Apex event handling errors */ @Test - public void testXMLtoApexEvent() throws ApexException { + public void testXmltoApexEvent() throws ApexException { try { - final Apex2XMLEventConverter xmlEventConverter = new Apex2XMLEventConverter(); + final Apex2XmlEventConverter xmlEventConverter = new Apex2XmlEventConverter(); assertNotNull(xmlEventConverter); - final String apexEventXMLStringIn = XMLEventGenerator.xmlEvent(); + final String apexEventXmlStringIn = XmlEventGenerator.xmlEvent(); - logger.debug("input event\n" + apexEventXMLStringIn); + logger.debug("input event\n" + apexEventXmlStringIn); - for (final ApexEvent apexEvent : xmlEventConverter.toApexEvent("XMLEventName", apexEventXMLStringIn)) { + for (final ApexEvent apexEvent : xmlEventConverter.toApexEvent("XMLEventName", apexEventXmlStringIn)) { assertNotNull(apexEvent); logger.debug(apexEvent.toString()); @@ -83,9 +83,9 @@ public class TestXMLEventHandler { * @throws ApexException on Apex event handling errors */ @Test - public void testApexEventToXML() throws ApexException { + public void testApexEventToXml() throws ApexException { try { - final Apex2XMLEventConverter xmlEventConverter = new Apex2XMLEventConverter(); + final Apex2XmlEventConverter xmlEventConverter = new Apex2XmlEventConverter(); assertNotNull(xmlEventConverter); final Date event0000StartTime = new Date(); @@ -99,16 +99,16 @@ public class TestXMLEventHandler { new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.sample.events", "test", "apex"); apexEvent0000.putAll(event0000DataMap); - final String apexEvent0000XMLString = xmlEventConverter.fromApexEvent(apexEvent0000); + final String apexEvent0000XmlString = xmlEventConverter.fromApexEvent(apexEvent0000); - logger.debug(apexEvent0000XMLString); + logger.debug(apexEvent0000XmlString); - assertTrue(apexEvent0000XMLString.contains("<name>Event0000</name>")); - assertTrue(apexEvent0000XMLString.contains("<version>0.0.1</version>")); - assertTrue(apexEvent0000XMLString.contains("<value>This is a test slogan</value>")); - assertTrue(apexEvent0000XMLString.contains("<value>12345</value>")); - assertTrue(apexEvent0000XMLString.contains("<value>" + event0000StartTime.getTime() + "</value>")); - assertTrue(apexEvent0000XMLString.contains("<value>34.5445667</value>")); + assertTrue(apexEvent0000XmlString.contains("<name>Event0000</name>")); + assertTrue(apexEvent0000XmlString.contains("<version>0.0.1</version>")); + assertTrue(apexEvent0000XmlString.contains("<value>This is a test slogan</value>")); + assertTrue(apexEvent0000XmlString.contains("<value>12345</value>")); + assertTrue(apexEvent0000XmlString.contains("<value>" + event0000StartTime.getTime() + "</value>")); + assertTrue(apexEvent0000XmlString.contains("<value>34.5445667</value>")); final Date event0004StartTime = new Date(1434363272000L); final Map<String, Object> event0004DataMap = new HashMap<String, Object>(); @@ -129,16 +129,16 @@ public class TestXMLEventHandler { new ApexEvent("Event0004", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex"); apexEvent0004.putAll(event0004DataMap); - final String apexEvent0004XMLString = xmlEventConverter.fromApexEvent(apexEvent0004); + final String apexEvent0004XmlString = xmlEventConverter.fromApexEvent(apexEvent0004); - logger.debug(apexEvent0004XMLString); + logger.debug(apexEvent0004XmlString); - assertTrue(apexEvent0004XMLString.contains("<name>Event0004</name>")); - assertTrue(apexEvent0004XMLString.contains("<version>0.0.1</version>")); - assertTrue(apexEvent0004XMLString.contains("<value>Test slogan for External Event</value>")); - assertTrue(apexEvent0004XMLString.contains("<value>1434370506078</value>")); - assertTrue(apexEvent0004XMLString.contains("<value>" + event0004StartTime.getTime() + "</value>")); - assertTrue(apexEvent0004XMLString.contains("<value>1064.43</value>")); + assertTrue(apexEvent0004XmlString.contains("<name>Event0004</name>")); + assertTrue(apexEvent0004XmlString.contains("<version>0.0.1</version>")); + assertTrue(apexEvent0004XmlString.contains("<value>Test slogan for External Event</value>")); + assertTrue(apexEvent0004XmlString.contains("<value>1434370506078</value>")); + assertTrue(apexEvent0004XmlString.contains("<value>" + event0004StartTime.getTime() + "</value>")); + assertTrue(apexEvent0004XmlString.contains("<value>1064.43</value>")); } catch (final Exception e) { e.printStackTrace(); throw new ApexException("Exception reading Apex event xml file", e); diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLTaggedEventConsumer.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlTaggedEventConsumer.java index e02c86a45..475373a7c 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXMLTaggedEventConsumer.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/TestXmlTaggedEventConsumer.java @@ -34,9 +34,15 @@ import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.TextBlock; /** - * @author Liam Fallon (liam.fallon@ericsson.com) + * The Class TestXmlTaggedEventConsumer. */ -public class TestXMLTaggedEventConsumer { +public class TestXmlTaggedEventConsumer { + + /** + * Test garbage text line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testGarbageTextLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream("hello there".getBytes()); @@ -49,10 +55,15 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test partial event line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testPartialEventLine() throws IOException { - final InputStream xmlInputStream = - new ByteArrayInputStream("1469781869268</TestTimestamp></MainTag>".getBytes()); + final InputStream xmlInputStream = new ByteArrayInputStream( + "1469781869268</TestTimestamp></MainTag>".getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); @@ -62,23 +73,33 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test full event line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes()); + "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>"); + assertEquals("<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>", textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full event garbage before line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventGarbageBeforeLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes()); + "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); @@ -87,10 +108,16 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test full event garbage before after line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventGarbageBeforeAfterLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish".getBytes()); + "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish" + .getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); @@ -99,20 +126,30 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test full event garbage after line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventGarbageAfterLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish".getBytes()); + "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish".getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish"); + assertEquals("<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test garbage text multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testGarbageTextMultiLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream("hello\nthere".getBytes()); @@ -124,10 +161,15 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test partial event multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testPartialEventMultiLine() throws IOException { - final InputStream xmlInputStream = - new ByteArrayInputStream("1469781869268\n</TestTimestamp>\n</MainTag>".getBytes()); + final InputStream xmlInputStream = new ByteArrayInputStream( + "1469781869268\n</TestTimestamp>\n</MainTag>".getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); @@ -136,68 +178,95 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test full event multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventMultiLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n".getBytes()); + "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n".getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full event garbage before multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventGarbageBeforeMultiLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n".getBytes()); + "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n" + .getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full event garbage before after multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventGarbageBeforeAfterMultiLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish\n\n" - .getBytes()); + String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>" + + "\n</MainTag>\nRubbish\n\n"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full event garbage after multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventGarbageAfterMultiLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish".getBytes()); + "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish" + .getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test partial events line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testPartialEventsLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "1469781869268</TestTimestamp></MainTag><?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>" - .getBytes()); + String garbageString = "1469781869268</TestTimestamp></MainTag><?xml><MainTag>" + + "<TestTimestamp>1469781869268</TestTimestamp>"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); @@ -206,11 +275,16 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test full events garbage before line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventsGarbageBeforeLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag><?xml><MainTag><TestTimestamp>" - .getBytes()); + String garbageString = "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>" + + "<?xml><MainTag><TestTimestamp>"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); @@ -219,11 +293,16 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test full events garbage before after line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventsGarbageBeforeAfterLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish<?xml><MainTag><TestTimestamp>\nRefuse" - .getBytes()); + String garbageString = "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>" + + "</MainTag>Rubbish<?xml><MainTag><TestTimestamp>\nRefuse"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); @@ -232,105 +311,136 @@ public class TestXMLTaggedEventConsumer { assertTrue(textBlock.isEndOfText()); } + /** + * Test full events garbage after line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventsGarbageAfterLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish<?xml><MainTag><TestTimestamp>Refuse" - .getBytes()); + String garbageString = "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>" + + "</MainTag>Rubbish<?xml><MainTag><TestTimestamp>Refuse"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish<?xml><MainTag><TestTimestamp>Refuse"); + assertEquals(textBlock.getText(), garbageString); assertTrue(textBlock.isEndOfText()); } + /** + * Test partial events multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testPartialEventsMultiLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "1469781869268\n</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>".getBytes()); + "1469781869268\n</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>".getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), "<?xml>\n<MainTag>\n<TestTimestamp>"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>", textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full events multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventsMultiLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n" - .getBytes()); + String garbageString = "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n" + + "</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>", + textBlock.getText()); assertFalse(textBlock.isEndOfText()); textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full events garbage before multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventsGarbageBeforeMultiLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n" - .getBytes()); + String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n" + + "</MainTag>\n\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>", + textBlock.getText()); assertFalse(textBlock.isEndOfText()); textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full events garbage before after multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventsGarbageBeforeAfterMultiLine() throws IOException { - final InputStream xmlInputStream = new ByteArrayInputStream( - "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse\n" - .getBytes()); + String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n" + + "</MainTag>\nRubbish\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n" + + "</MainTag>\nRefuse\n"; + final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish", + textBlock.getText()); assertFalse(textBlock.isEndOfText()); textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } + /** + * Test full events garbage after multi line. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testFullEventsGarbageAfterMultiLine() throws IOException { final InputStream xmlInputStream = new ByteArrayInputStream( - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish".getBytes()); + "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish" + .getBytes()); final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true); xmlTaggedReader.init(xmlInputStream); final TextBlock textBlock = xmlTaggedReader.readTextBlock(); - assertEquals(textBlock.getText(), - "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"); + assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish", + textBlock.getText()); assertTrue(textBlock.isEndOfText()); } } diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventGenerator.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventGenerator.java index 765f098de..f85d9119e 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XMLEventGenerator.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventGenerator.java @@ -23,11 +23,17 @@ package org.onap.policy.apex.plugins.event.protocol.xml; import java.util.Random; /** - * @author Liam Fallon (liam.fallon@ericsson.com) + * The Class XmlEventGenerator. */ -public class XMLEventGenerator { +public class XmlEventGenerator { private static int nextEventNo = 0; + /** + * Xml events. + * + * @param eventCount the event count + * @return the string + */ public static String xmlEvents(final int eventCount) { final StringBuilder builder = new StringBuilder(); @@ -41,6 +47,11 @@ public class XMLEventGenerator { return builder.toString(); } + /** + * Xml event. + * + * @return the string + */ public static String xmlEvent() { final Random rand = new Random(); @@ -65,7 +76,7 @@ public class XMLEventGenerator { builder.append(" </data>\n"); builder.append(" <data>\n"); builder.append(" <key>TestMatchCase</key>\n"); - builder.append(" <value>" + nextMatchCase + "</value>\n"); + builder.append(" <value>" + nextMatchCase + "</value>\n"); builder.append(" </data>\n"); builder.append(" <data>\n"); builder.append(" <key>TestTimestamp</key>\n"); @@ -80,6 +91,11 @@ public class XMLEventGenerator { return builder.toString(); } + /** + * The main method. + * + * @param args the arguments + */ public static void main(final String[] args) { if (args.length != 1) { System.err.println("usage EventGenerator #events"); @@ -98,6 +114,11 @@ public class XMLEventGenerator { System.out.println(xmlEvents(eventCount)); } + /** + * Gets the next event no. + * + * @return the next event no + */ public static int getNextEventNo() { return nextEventNo; } diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java index f81c3a914..4bf10e4ae 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java @@ -38,9 +38,8 @@ import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import org.yaml.snakeyaml.Yaml; - import org.yaml.snakeyaml.DumperOptions.FlowStyle; +import org.yaml.snakeyaml.Yaml; /** * The Class Apex2YamlEventConverter converts {@link ApexEvent} instances to and from YAML string representations of @@ -104,11 +103,10 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { // If the incoming YAML did not create a map it is a primitive type or a collection so we // convert it into a map for processing Map<?, ?> yamlMap; - if (yamlObject != null && yamlObject instanceof Map) { + if (yamlObject instanceof Map) { // We already have a map so just cast the object yamlMap = (Map<?, ?>) yamlObject; - } - else { + } else { // Create a single entry map, new map creation and assignment is to avoid a // type checking warning LinkedHashMap<String, Object> newYamlMap = new LinkedHashMap<>(); @@ -173,7 +171,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { continue; } - yamlMap.put(fieldName, apexEvent.get(fieldName)); + yamlMap.put(fieldName, apexEvent.get(fieldName)); } // Use Snake YAML to convert the APEX event to YAML @@ -187,11 +185,9 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { * @param eventName the name of the event * @param yamlMap the YAML map that holds the event * @return the apex event that we have converted the JSON object into - * @throws ApexEventException - * thrown on unmarshaling exceptions + * @throws ApexEventException thrown on unmarshaling exceptions */ - private ApexEvent yamlMap2ApexEvent(final String eventName, final Map<?, ?> yamlMap) - throws ApexEventException { + private ApexEvent yamlMap2ApexEvent(final String eventName, final Map<?, ?> yamlMap) throws ApexEventException { // Process the mandatory Apex header final ApexEvent apexEvent = processApexEventHeader(eventName, yamlMap); @@ -236,16 +232,10 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { * @throws ApexEventRuntimeException the apex event runtime exception * @throws ApexEventException on invalid events with missing header fields */ - private ApexEvent processApexEventHeader(final String eventName, final Map<?, ?> yamlMap) + private ApexEvent processApexEventHeader(final String eventName, final Map<?, ?> yamlMap) throws ApexEventException { - // Get the event header fields - // @formatter:off - String name = getYamlStringField(yamlMap, ApexEvent.NAME_HEADER_FIELD, yamlPars.getNameAlias(), ApexEvent.NAME_REGEXP, false); - String version = getYamlStringField(yamlMap, ApexEvent.VERSION_HEADER_FIELD, yamlPars.getVersionAlias(), ApexEvent.VERSION_REGEXP, false); - String namespace = getYamlStringField(yamlMap, ApexEvent.NAMESPACE_HEADER_FIELD, yamlPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false); - String source = getYamlStringField(yamlMap, ApexEvent.SOURCE_HEADER_FIELD, yamlPars.getSourceAlias(), ApexEvent.SOURCE_REGEXP, false); - String target = getYamlStringField(yamlMap, ApexEvent.TARGET_HEADER_FIELD, yamlPars.getTargetAlias(), ApexEvent.TARGET_REGEXP, false); - // @formatter:on + String name = getYamlStringField(yamlMap, ApexEvent.NAME_HEADER_FIELD, yamlPars.getNameAlias(), + ApexEvent.NAME_REGEXP, false); // Check that an event name has been specified if (name == null && eventName == null) { @@ -256,14 +246,16 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { // Check if an event name was specified on the event parameters if (eventName != null) { if (name != null && !eventName.equals(name)) { - LOGGER.warn("The incoming event name \"{}\" does not match the configured event name \"{}\", using configured event name", - name, eventName); + LOGGER.warn("The incoming event name \"{}\" does not match the configured event name \"{}\", " + + "using configured event name", name, eventName); } name = eventName; } // Now, find the event definition in the model service. If version is null, the newest event // definition in the model service is used + String version = getYamlStringField(yamlMap, ApexEvent.VERSION_HEADER_FIELD, yamlPars.getVersionAlias(), + ApexEvent.VERSION_REGEXP, false); final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(name, version); if (eventDefinition == null) { throw new ApexEventRuntimeException("an event definition for an event named \"" + name @@ -276,6 +268,8 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { } // Check the name space is OK if it is defined, if not, use the name space from the model + String namespace = getYamlStringField(yamlMap, ApexEvent.NAMESPACE_HEADER_FIELD, yamlPars.getNameSpaceAlias(), + ApexEvent.NAMESPACE_REGEXP, false); if (namespace != null) { if (!namespace.equals(eventDefinition.getNameSpace())) { throw new ApexEventRuntimeException("namespace \"" + namespace + "\" on event \"" + name @@ -287,11 +281,15 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { } // For source, use the defined source only if the source is not found on the incoming event + String source = getYamlStringField(yamlMap, ApexEvent.SOURCE_HEADER_FIELD, yamlPars.getSourceAlias(), + ApexEvent.SOURCE_REGEXP, false); if (source == null) { source = eventDefinition.getSource(); } // For target, use the defined source only if the source is not found on the incoming event + String target = getYamlStringField(yamlMap, ApexEvent.TARGET_HEADER_FIELD, yamlPars.getTargetAlias(), + ApexEvent.TARGET_REGEXP, false); if (target == null) { target = eventDefinition.getTarget(); } @@ -302,22 +300,16 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { /** * This method gets an event string field from a JSON object. * - * @param yamlMap - * the YAML containing the YAML representation of the incoming event - * @param fieldName - * the field name to find in the event - * @param fieldAlias - * the alias for the field to find in the event, overrides the field name if it is not null - * @param fieldRE - * the regular expression to check the field against for validity - * @param mandatory - * true if the field is mandatory + * @param yamlMap the YAML containing the YAML representation of the incoming event + * @param fieldName the field name to find in the event + * @param fieldAlias the alias for the field to find in the event, overrides the field name if it is not null + * @param fieldRegexp the regular expression to check the field against for validity + * @param mandatory true if the field is mandatory * @return the value of the field in the JSON object or null if the field is optional - * @throws ApexEventRuntimeException - * the apex event runtime exception + * @throws ApexEventRuntimeException the apex event runtime exception */ private String getYamlStringField(final Map<?, ?> yamlMap, final String fieldName, final String fieldAlias, - final String fieldRE, final boolean mandatory) { + final String fieldRegexp, final boolean mandatory) { // Get the YAML field for the string field final Object yamlField = getYamlField(yamlMap, fieldName, fieldAlias, mandatory); @@ -335,12 +327,12 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { final String fieldValueString = (String) yamlField; // Is regular expression checking required - if (fieldRE == null) { + if (fieldRegexp == null) { return fieldValueString; } // Check the event field against its regular expression - if (!fieldValueString.matches(fieldRE)) { + if (!fieldValueString.matches(fieldRegexp)) { throw new ApexEventRuntimeException( "field \"" + fieldName + "\" with value \"" + fieldValueString + "\" is invalid"); } @@ -351,17 +343,12 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter { /** * This method gets an event field from a YAML object. * - * @param yamlMap - * the YAML containing the YAML representation of the incoming event - * @param fieldName - * the field name to find in the event - * @param fieldAlias - * the alias for the field to find in the event, overrides the field name if it is not null - * @param mandatory - * true if the field is mandatory + * @param yamlMap the YAML containing the YAML representation of the incoming event + * @param fieldName the field name to find in the event + * @param fieldAlias the alias for the field to find in the event, overrides the field name if it is not null + * @param mandatory true if the field is mandatory * @return the value of the field in the YAML object or null if the field is optional - * @throws ApexEventRuntimeException - * the apex event runtime exception + * @throws ApexEventRuntimeException the apex event runtime exception */ private Object getYamlField(final Map<?, ?> yamlMap, final String fieldName, final String fieldAlias, final boolean mandatory) { diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java index 861e9cd8f..09a7f54aa 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java @@ -25,7 +25,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTo /** * Event protocol parameters for YAML as an event protocol. * - * The parameters for this plugin are: + * <p>The parameters for this plugin are: * <ol> * <li>nameAlias: The field in a YAML event to use as an alias for the event name. This parameter is * optional. diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java index c5f6cb781..1d2a1d9f7 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java @@ -49,7 +49,16 @@ import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.TextBlock; import org.onap.policy.common.parameters.ParameterService; +/** + * The Class TestYamlEventProtocol. + */ public class TestYamlEventProtocol { + + /** + * Register test events and schemas. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @BeforeClass public static void registerTestEventsAndSchemas() throws IOException { SchemaParameters schemaParameters = new SchemaParameters(); @@ -62,20 +71,20 @@ public class TestYamlEventProtocol { "java.lang.Integer"); schemas.getSchemasMap().put(simpleIntSchema.getKey(), simpleIntSchema); - AxContextSchema simpleDoubleSchema = new AxContextSchema(new AxArtifactKey("SimpleDoubleSchema", "0.0.1"), "JAVA", - "java.lang.Double"); + AxContextSchema simpleDoubleSchema = new AxContextSchema(new AxArtifactKey("SimpleDoubleSchema", "0.0.1"), + "JAVA", "java.lang.Double"); schemas.getSchemasMap().put(simpleDoubleSchema.getKey(), simpleDoubleSchema); - AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), "JAVA", - "java.lang.String"); + AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"), + "JAVA", "java.lang.String"); schemas.getSchemasMap().put(simpleStringSchema.getKey(), simpleStringSchema); AxContextSchema arrayListSchema = new AxContextSchema(new AxArtifactKey("ArrayListSchema", "0.0.1"), "JAVA", "java.util.ArrayList"); schemas.getSchemasMap().put(arrayListSchema.getKey(), arrayListSchema); - AxContextSchema linkedHashMapSchema = new AxContextSchema(new AxArtifactKey("LinkedHashMapSchema", "0.0.1"), "JAVA", - "java.util.LinkedHashMap"); + AxContextSchema linkedHashMapSchema = new AxContextSchema(new AxArtifactKey("LinkedHashMapSchema", "0.0.1"), + "JAVA", "java.util.LinkedHashMap"); schemas.getSchemasMap().put(linkedHashMapSchema.getKey(), linkedHashMapSchema); ModelService.registerModel(AxContextSchemas.class, schemas); @@ -105,11 +114,9 @@ public class TestYamlEventProtocol { AxEvent testEvent3 = new AxEvent(new AxArtifactKey("TestEvent3", "0.0.1")); testEvent3.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml"); - AxField te3Field0 = new AxField(new AxReferenceKey(testEvent3.getKey(), "american"), - arrayListSchema.getKey()); + AxField te3Field0 = new AxField(new AxReferenceKey(testEvent3.getKey(), "american"), arrayListSchema.getKey()); testEvent3.getParameterMap().put("american", te3Field0); - AxField te3Field1 = new AxField(new AxReferenceKey(testEvent3.getKey(), "national"), - arrayListSchema.getKey()); + AxField te3Field1 = new AxField(new AxReferenceKey(testEvent3.getKey(), "national"), arrayListSchema.getKey()); testEvent3.getParameterMap().put("national", te3Field1); events.getEventMap().put(testEvent3.getKey(), testEvent3); @@ -139,24 +146,19 @@ public class TestYamlEventProtocol { AxEvent testEvent7 = new AxEvent(new AxArtifactKey("TestEvent7", "0.0.1")); testEvent7.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml"); - AxField te7Field0 = new AxField(new AxReferenceKey(testEvent7.getKey(), "time"), - simpleIntSchema.getKey()); + AxField te7Field0 = new AxField(new AxReferenceKey(testEvent7.getKey(), "time"), simpleIntSchema.getKey()); testEvent7.getParameterMap().put("time", te7Field0); - AxField te7Field1 = new AxField(new AxReferenceKey(testEvent7.getKey(), "player"), - simpleStringSchema.getKey()); + AxField te7Field1 = new AxField(new AxReferenceKey(testEvent7.getKey(), "player"), simpleStringSchema.getKey()); testEvent7.getParameterMap().put("player", te7Field1); - AxField te7Field2 = new AxField(new AxReferenceKey(testEvent7.getKey(), "action"), - simpleStringSchema.getKey()); + AxField te7Field2 = new AxField(new AxReferenceKey(testEvent7.getKey(), "action"), simpleStringSchema.getKey()); testEvent7.getParameterMap().put("action", te7Field2); events.getEventMap().put(testEvent7.getKey(), testEvent7); AxEvent testEvent8 = new AxEvent(new AxArtifactKey("TestEvent8", "0.0.1")); testEvent8.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml"); - AxField te8Field0 = new AxField(new AxReferenceKey(testEvent8.getKey(), "hr"), - arrayListSchema.getKey()); + AxField te8Field0 = new AxField(new AxReferenceKey(testEvent8.getKey(), "hr"), arrayListSchema.getKey()); testEvent8.getParameterMap().put("hr", te8Field0); - AxField te8Field1 = new AxField(new AxReferenceKey(testEvent8.getKey(), "rbi"), - arrayListSchema.getKey()); + AxField te8Field1 = new AxField(new AxReferenceKey(testEvent8.getKey(), "rbi"), arrayListSchema.getKey()); testEvent8.getParameterMap().put("rbi", te8Field1); events.getEventMap().put(testEvent8.getKey(), testEvent8); @@ -196,12 +198,21 @@ public class TestYamlEventProtocol { ModelService.registerModel(AxEvents.class, events); } + /** + * Unregister test events and schemas. + */ @AfterClass public static void unregisterTestEventsAndSchemas() { ModelService.clear(); ParameterService.clear(); } + /** + * Test yaml processing. + * + * @throws ApexEventException the apex event exception + * @throws IOException Signals that an I/O exception has occurred. + */ @Test public void testYamlProcessing() throws ApexEventException, IOException { try { @@ -227,8 +238,18 @@ public class TestYamlEventProtocol { testYamlDecodeEncode("TestEvent11", 1, 4, "TOSCA0"); } - private void testYamlDecodeEncode(final String eventName, final int eventCount, final int parCount, final String fileName) - throws ApexEventException, IOException { + /** + * Test yaml decode encode. + * + * @param eventName the event name + * @param eventCount the event count + * @param parCount the par count + * @param fileName the file name + * @throws ApexEventException the apex event exception + * @throws IOException Signals that an I/O exception has occurred. + */ + private void testYamlDecodeEncode(final String eventName, final int eventCount, final int parCount, + final String fileName) throws ApexEventException, IOException { YamlEventProtocolParameters parameters = new YamlEventProtocolParameters(); parameters.setDelimiterAtStart(false); @@ -239,16 +260,17 @@ public class TestYamlEventProtocol { FileInputStream fileInputStream = new FileInputStream(new File(filePath)); HeaderDelimitedTextBlockReader reader = new HeaderDelimitedTextBlockReader(parameters); reader.init(fileInputStream); - + List<ApexEvent> eventList = new ArrayList<>(); - + TextBlock textBlock; do { - textBlock = reader.readTextBlock(); - - eventList.addAll(converter.toApexEvent(eventName, textBlock.getText())); - } while (!textBlock.isEndOfText()); - + textBlock = reader.readTextBlock(); + + eventList.addAll(converter.toApexEvent(eventName, textBlock.getText())); + } + while (!textBlock.isEndOfText()); + fileInputStream.close(); assertEquals(eventCount, eventList.size()); @@ -257,7 +279,8 @@ public class TestYamlEventProtocol { assertEquals(parCount, eventList.get(0).size()); String eventYaml = (String) converter.fromApexEvent(eventList.get(eventNo)); - String expectedYaml = TextFileUtils.getTextFileAsString("src/test/resources/yaml_out/" + fileName + '_' + eventNo + ".yaml"); + String expectedYaml = TextFileUtils + .getTextFileAsString("src/test/resources/yaml_out/" + fileName + '_' + eventNo + ".yaml"); assertEquals(expectedYaml.replaceAll("\\s*", ""), eventYaml.replaceAll("\\s*", "")); } } diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java index 57b4b72d6..d033de56d 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java @@ -17,6 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ + package org.onap.policy.apex.plugins.event.protocol.yaml; import static org.junit.Assert.assertEquals; @@ -44,9 +45,17 @@ import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; import org.onap.policy.common.parameters.ParameterService; +/** + * The Class TestYamlPluginStability. + */ public class TestYamlPluginStability { static AxEvent testEvent; + /** + * Register test events and schemas. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @BeforeClass public static void registerTestEventsAndSchemas() throws IOException { SchemaParameters schemaParameters = new SchemaParameters(); @@ -69,8 +78,6 @@ public class TestYamlPluginStability { ModelService.registerModel(AxContextSchemas.class, schemas); - AxEvents events = new AxEvents(); - testEvent = new AxEvent(new AxArtifactKey("TestEvent", "0.0.1")); testEvent.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml"); AxField teField0 = new AxField(new AxReferenceKey(testEvent.getKey(), "intValue"), simpleIntSchema.getKey()); @@ -81,17 +88,27 @@ public class TestYamlPluginStability { AxField teField2 = new AxField(new AxReferenceKey(testEvent.getKey(), "stringValue"), simpleStringSchema.getKey(), true); testEvent.getParameterMap().put("stringValue", teField2); + + AxEvents events = new AxEvents(); events.getEventMap().put(testEvent.getKey(), testEvent); ModelService.registerModel(AxEvents.class, events); } + /** + * Unregister test events and schemas. + */ @AfterClass public static void unregisterTestEventsAndSchemas() { ModelService.clear(); ParameterService.clear(); } + /** + * Test stability. + * + * @throws ApexEventException the apex event exception + */ @Test public void testStability() throws ApexEventException { Apex2YamlEventConverter converter = new Apex2YamlEventConverter(); @@ -220,7 +237,8 @@ public class TestYamlPluginStability { e.getMessage().substring(0, 77)); } - yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + "stringValue: org.onap.policy.apex.plugins.event.protocol.yaml"; + yamlInputString = "doubleValue: 123.45\n" + "intValue: 123\n" + + "stringValue: org.onap.policy.apex.plugins.event.protocol.yaml"; eventList = converter.toApexEvent("TestEvent", yamlInputString); assertEquals("org.onap.policy.apex.plugins.event.protocol.yaml", eventList.get(0).getNameSpace()); @@ -249,7 +267,7 @@ public class TestYamlPluginStability { } pars.setTargetAlias(null); - yamlInputString = "doubleValue: 123.45\n" + "intValue: ~\n"+ "stringValue: MyString"; + yamlInputString = "doubleValue: 123.45\n" + "intValue: ~\n" + "stringValue: MyString"; try { converter.toApexEvent("TestEvent", yamlInputString); fail("this test should throw an exception"); diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java index 4fff29092..8577d18fb 100644 --- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java +++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java @@ -65,17 +65,17 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor { /** * Executes the executor for the state finalizer logic in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields for finalisation * @return The state output for the state * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public String execute(final long executionID, final Map<String, Object> incomingFields) + public String execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Check and execute the Java logic boolean returnValue = false; @@ -84,7 +84,7 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor { // StateFinalizerExecutionContext executor) throws ApexException" // to invoke the // task logic in the Java class - final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput", + final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput", (Class[]) new Class[] { StateFinalizerExecutionContext.class }); returnValue = (boolean) method.invoke(stateFinalizerLogicObject, getExecutionContext()); } catch (final Exception e) { diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java index 753f08b7e..829434dc3 100644 --- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java +++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java @@ -66,17 +66,17 @@ public class JavaTaskExecutor extends TaskExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields * @return The outgoing fields * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public Map<String, Object> execute(final long executionID, final Map<String, Object> incomingFields) + public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Check and execute the Java logic boolean returnValue = false; @@ -84,7 +84,7 @@ public class JavaTaskExecutor extends TaskExecutor { // Find and call the method with the signature "public boolean getEvent(final TaskExecutionContext executor) // throws ApexException" to invoke the // task logic in the Java class - final Method method = taskLogicObject.getClass().getDeclaredMethod("getEvent", + final Method method = taskLogicObject.getClass().getDeclaredMethod("getEvent", (Class[]) new Class[] { TaskExecutionContext.class }); returnValue = (boolean) method.invoke(taskLogicObject, getExecutionContext()); } catch (final Exception e) { diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java index a42ff2cfa..e642972af 100644 --- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java +++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java @@ -66,17 +66,17 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingEvent the incoming event * @return The outgoing event * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public AxArtifactKey execute(final long executionID, final EnEvent incomingEvent) + public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingEvent); + executePre(executionId, incomingEvent); // Check and execute the Java logic boolean returnValue = false; @@ -84,7 +84,7 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor { // Find and call the method with the signature "public boolean getTask(final TaskSelectionExecutionContext // executor)" to invoke the task selection // logic in the Java class - final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask", + final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask", (Class[]) new Class[] { TaskSelectionExecutionContext.class }); returnValue = (boolean) method.invoke(taskSelectionLogicObject, getExecutionContext()); } catch (final Exception e) { diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java index 7b91c5975..bc3062d13 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutor.java @@ -70,17 +70,17 @@ public class JavascriptStateFinalizerExecutor extends StateFinalizerExecutor { /** * Executes the executor for the state finalizer logic in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields for finalisation * @return The state output for the state * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public String execute(final long executionID, final Map<String, Object> incomingFields) + public String execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Set up the Javascript engine engine.put("executor", getExecutionContext()); diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java index 38be929c0..14e4ba384 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java @@ -69,17 +69,17 @@ public class JavascriptTaskExecutor extends TaskExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields * @return The outgoing fields * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public Map<String, Object> execute(final long executionID, final Map<String, Object> incomingFields) + public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Set up the Javascript engine engine.put("executor", getExecutionContext()); diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java index 570b33b2a..adeb73f88 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutor.java @@ -44,6 +44,10 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(JavascriptTaskSelectExecutor.class); + // Recurring string constants + private static final String TSL_FAILED_PREFIX = + "execute: task selection logic failed to set a return value for state \""; + // Javascript engine private ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); private CompiledScript compiled = null; @@ -61,9 +65,9 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { compiled = ((Compilable) engine).compile(getSubject().getTaskSelectionLogic().getLogic()); } catch (final ScriptException e) { LOGGER.error("execute: task selection logic failed to compile for state \"" + getSubject().getKey().getId() - + "\""); - throw new StateMachineException( - "task selection logic failed to compile for state \"" + getSubject().getKey().getId() + "\"", e); + + "\""); + throw new StateMachineException("task selection logic failed to compile for state \"" + + getSubject().getKey().getId() + "\"", e); } } @@ -71,17 +75,17 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingEvent the incoming event * @return The outgoing event * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public AxArtifactKey execute(final long executionID, final EnEvent incomingEvent) - throws StateMachineException, ContextException { + public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent) + throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingEvent); + executePre(executionId, incomingEvent); // Set up the Javascript engine engine.put("executor", getExecutionContext()); @@ -95,27 +99,24 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { compiled.eval(engine.getContext()); } } catch (final ScriptException e) { - LOGGER.error( - "execute: task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\""); + LOGGER.error("execute: task selection logic failed to run for state \"" + getSubject().getKey().getId() + + "\""); throw new StateMachineException( - "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"", e); + "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"", + e); } try { final Object ret = engine.get("returnValue"); if (ret == null) { - LOGGER.error("execute: task selection logic failed to set a return value for state \"" - + getSubject().getKey().getId() + "\""); - throw new StateMachineException( - "execute: task selection logic failed to set a return value for state \"" - + getSubject().getKey().getId() + "\""); + LOGGER.error(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\""); + throw new StateMachineException(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\""); } returnValue = (Boolean) ret; } catch (NullPointerException | ClassCastException e) { LOGGER.error("execute: task selection logic failed to set a correct return value for state \"" - + getSubject().getKey().getId() + "\"", e); - throw new StateMachineException("execute: task selection logic failed to set a return value for state \"" - + getSubject().getKey().getId() + "\"", e); + + getSubject().getKey().getId() + "\"", e); + throw new StateMachineException(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\"", e); } // Do the execution post work @@ -137,8 +138,8 @@ public class JavascriptTaskSelectExecutor extends TaskSelectExecutor { @Override public void cleanUp() throws StateMachineException { LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + "," - + getSubject().getTaskSelectionLogic().getLogicFlavour() + "," - + getSubject().getTaskSelectionLogic().getLogic()); + + getSubject().getTaskSelectionLogic().getLogicFlavour() + "," + + getSubject().getTaskSelectionLogic().getLogic()); engine = null; } } diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java index f8f66e5d2..9e9024401 100644 --- a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java +++ b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java @@ -70,17 +70,17 @@ public class JrubyStateFinalizerExecutor extends StateFinalizerExecutor { /** * Executes the executor for the state finalizer logic in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields for finalisation * @return The state output for the state * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public String execute(final long executionID, final Map<String, Object> incomingFields) + public String execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Check and execute the JRuby logic container.put("executor", getExecutionContext()); diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java index 56b28d02e..d49423486 100644 --- a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java +++ b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java @@ -70,17 +70,17 @@ public class JrubyTaskExecutor extends TaskExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields * @return The outgoing fields * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public Map<String, Object> execute(final long executionID, final Map<String, Object> incomingFields) + public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Check and execute the JRuby logic container.put("executor", getExecutionContext()); diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java index 8405f4e60..b3ce7e0fd 100644 --- a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java +++ b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java @@ -71,17 +71,17 @@ public class JrubyTaskSelectExecutor extends TaskSelectExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingEvent the incoming event * @return The outgoing event * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public AxArtifactKey execute(final long executionID, final EnEvent incomingEvent) + public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingEvent); + executePre(executionId, incomingEvent); // Check and execute the JRuby logic container.put("executor", getExecutionContext()); diff --git a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonStateFinalizerExecutor.java index ea8f027c5..ecd9f7ae1 100644 --- a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonStateFinalizerExecutor.java +++ b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonStateFinalizerExecutor.java @@ -75,20 +75,20 @@ public class JythonStateFinalizerExecutor extends StateFinalizerExecutor { /** * Executes the executor for the state finalizer logic in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields for finalisation * @return The state output for the state * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public String execute(final long executionID, final Map<String, Object> incomingFields) + public String execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { boolean returnValue = false; // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); try { diff --git a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java index e1c0f096a..39ca0dc43 100644 --- a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java +++ b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java @@ -77,20 +77,20 @@ public class JythonTaskExecutor extends TaskExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields * @return The outgoing fields * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public Map<String, Object> execute(final long executionID, final Map<String, Object> incomingFields) + public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { boolean returnValue = false; // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); try { diff --git a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java index 4f4d38a19..3ff061fa4 100644 --- a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java +++ b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java @@ -43,6 +43,10 @@ import org.slf4j.ext.XLoggerFactory; public class JythonTaskSelectExecutor extends TaskSelectExecutor { private static final XLogger LOGGER = XLoggerFactory.getXLogger(JythonTaskSelectExecutor.class); + // Recurring string constants + private static final String TSL_FAILED_PREFIX = + "execute: task selection logic failed to set a return value for state \""; + // The Jython interpreter private final PythonInterpreter interpreter = new PythonInterpreter(); private PyCode compiled = null; @@ -77,20 +81,20 @@ public class JythonTaskSelectExecutor extends TaskSelectExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingEvent the incoming event * @return The outgoing event * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public AxArtifactKey execute(final long executionID, final EnEvent incomingEvent) + public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent) throws StateMachineException, ContextException { boolean returnValue = false; // Do execution pre work - executePre(executionID, incomingEvent); + executePre(executionId, incomingEvent); try { // Check and execute the Jython logic @@ -103,10 +107,10 @@ public class JythonTaskSelectExecutor extends TaskSelectExecutor { try { final Object ret = interpreter.get("returnValue", java.lang.Boolean.class); if (ret == null) { - LOGGER.error("execute: task selection logic failed to set a return value for state \"" + LOGGER.error(TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\""); throw new StateMachineException( - "execute: task selection logic failed to set a return value for state \"" + TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\""); } returnValue = (Boolean) ret; @@ -114,7 +118,7 @@ public class JythonTaskSelectExecutor extends TaskSelectExecutor { LOGGER.error("execute: task selection logic failed to set a correct return value for state \"" + getSubject().getKey().getId() + "\"", e); throw new StateMachineException( - "execute: task selection logic failed to set a return value for state \"" + TSL_FAILED_PREFIX + getSubject().getKey().getId() + "\"", e); } diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MVELExecutorParameters.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParameters.java index 21d124212..7b57ad446 100644 --- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MVELExecutorParameters.java +++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelExecutorParameters.java @@ -30,11 +30,11 @@ import org.onap.policy.apex.core.engine.ExecutorParameters; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class MVELExecutorParameters extends ExecutorParameters { +public class MvelExecutorParameters extends ExecutorParameters { /** * Constructor that sets the abstract implementation classes. */ - public MVELExecutorParameters() { + public MvelExecutorParameters() { this.setTaskExecutorPluginClass(MvelTaskExecutor.class.getCanonicalName()); this.setTaskSelectionExecutorPluginClass(MvelTaskSelectExecutor.class.getCanonicalName()); this.setStateFinalizerExecutorPluginClass(MvelStateFinalizerExecutor.class.getCanonicalName()); diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java index ea39c6d74..5086259a8 100644 --- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java +++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java @@ -68,17 +68,17 @@ public class MvelStateFinalizerExecutor extends StateFinalizerExecutor { /** * Executes the executor for the state finalizer logic in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields for finalisation * @return The state output for the state * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public String execute(final long executionID, final Map<String, Object> incomingFields) + public String execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Check and execute the MVEL logic argumentNotNull(compiled, "MVEL state finalizer logic not compiled."); diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java index 966a8004a..457539411 100644 --- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java +++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java @@ -68,17 +68,17 @@ public class MvelTaskExecutor extends TaskExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingFields the incoming fields * @return The outgoing fields * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public Map<String, Object> execute(final long executionID, final Map<String, Object> incomingFields) + public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingFields); + executePre(executionId, incomingFields); // Check and execute the MVEL logic argumentNotNull(compiled, "MVEL task not compiled."); diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java index 4991fbade..b07c5e260 100644 --- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java +++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java @@ -69,17 +69,17 @@ public class MvelTaskSelectExecutor extends TaskSelectExecutor { /** * Executes the executor for the task in a sequential manner. * - * @param executionID the execution ID for the current APEX policy execution + * @param executionId the execution ID for the current APEX policy execution * @param incomingEvent the incoming event * @return The outgoing event * @throws StateMachineException on an execution error * @throws ContextException on context errors */ @Override - public AxArtifactKey execute(final long executionID, final EnEvent incomingEvent) + public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent) throws StateMachineException, ContextException { // Do execution pre work - executePre(executionID, incomingEvent); + executePre(executionId, incomingEvent); // Check and execute the MVEL logic argumentNotNull(compiled, "MVEL task not compiled."); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java index 3840e915d..a9b862d41 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java @@ -20,6 +20,8 @@ package org.onap.policy.apex.service.engine.engdep; +import com.google.common.eventbus.Subscribe; + import java.util.Collection; import java.util.List; import java.util.concurrent.BlockingQueue; @@ -50,17 +52,14 @@ import org.onap.policy.apex.service.engine.runtime.EngineService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import com.google.common.eventbus.Subscribe; - /** - * The listener interface for receiving engDepMessage events. The class that is interested in - * processing a engDepMessage event implements this interface, and the object created with that - * class is registered with a component using the component's <code>addEngDepMessageListener</code> - * method. When the engDepMessage event occurs, that object's appropriate method is invoked. + * The listener interface for receiving engDepMessage events. The class that is interested in processing a engDepMessage + * event implements this interface, and the object created with that class is registered with a component using the + * component's <code>addEngDepMessageListener</code> method. When the engDepMessage event occurs, that object's + * appropriate method is invoked. * - * <p>This class uses a queue to buffer incoming messages. When the listener is called, it places the - * incoming message on the queue. A thread runs which removes the messages from the queue and - * forwards them to the Apex engine. + * <p>This class uses a queue to buffer incoming messages. When the listener is called, it places the incoming message + * on the queue. A thread runs which removes the messages from the queue and forwards them to the Apex engine. * * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com) */ @@ -83,9 +82,8 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable private final BlockingQueue<MessageBlock<Message>> messageQueue = new LinkedBlockingDeque<>(); /** - * Instantiates a new EngDep message listener for listening for messages coming in from the - * Deployment client. The <code>apexService</code> is the Apex service to send the messages - * onto. + * Instantiates a new EngDep message listener for listening for messages coming in from the Deployment client. The + * <code>apexService</code> is the Apex service to send the messages onto. * * @param apexService the Apex engine service */ @@ -94,8 +92,8 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable } /** - * This method is an implementation of the message listener. It receives a message and places it - * on the queue for processing by the message listening thread. + * This method is an implementation of the message listener. It receives a message and places it on the queue for + * processing by the message listening thread. * * @param data the data * @see org.onap.policy.apex.core.infrastructure.messaging.MessageListener#onMessage @@ -106,8 +104,8 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable public void onMessage(final MessageBlock<Message> data) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("message received from client application {} port {}", - data.getConnection().getRemoteSocketAddress().getAddress(), - data.getConnection().getRemoteSocketAddress().getPort()); + data.getConnection().getRemoteSocketAddress().getAddress(), + data.getConnection().getRemoteSocketAddress().getPort()); } messageQueue.add(data); } @@ -115,8 +113,7 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable /* * (non-Javadoc) * - * @see org.onap.policy.apex.core.infrastructure.messaging.MessageListener#onMessage(java.lang. - * String) + * @see org.onap.policy.apex.core.infrastructure.messaging.MessageListener#onMessage(java.lang. String) */ @Override public void onMessage(final String messageString) { @@ -148,8 +145,7 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable } /** - * Runs the message listening thread. Here, the messages come in on the message queue and are - * processed one by one + * Runs the message listening thread. Here, the messages come in on the message queue and are processed one by one */ @Override public void run() { @@ -173,8 +169,8 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable } /** - * This method handles EngDep messages as they come in. It uses the inevitable switch statement - * to handle the messages. + * This method handles EngDep messages as they come in. It uses the inevitable switch statement to handle the + * messages. * * @param message the incoming EngDep message * @param webSocket the web socket on which the message came in @@ -195,7 +191,7 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable enDepAction = (EngDepAction) message.getAction(); } else { throw new ApexException(message.getAction().getClass().getName() - + "action on received message invalid, action must be of type \"EnDepAction\""); + + "action on received message invalid, action must be of type \"EnDepAction\""); } // Handle each incoming message using the inevitable switch statement for the EngDep @@ -204,12 +200,12 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable case GET_ENGINE_SERVICE_INFO: final GetEngineServiceInfo engineServiceInformationMessage = (GetEngineServiceInfo) message; LOGGER.debug("getting engine service information for engine service " + apexService.getKey().getId() - + " . . ."); + + " . . ."); // Send a reply with the engine service information sendServiceInfoReply(webSocket, engineServiceInformationMessage, apexService.getKey(), - apexService.getEngineKeys(), apexService.getApexModelKey()); - LOGGER.debug( - "returned engine service information for engine service " + apexService.getKey().getId()); + apexService.getEngineKeys(), apexService.getApexModelKey()); + LOGGER.debug("returned engine service information for engine service " + + apexService.getKey().getId()); break; case UPDATE_MODEL: @@ -217,10 +213,10 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable LOGGER.debug("updating model in engine {} . . .", updateModelMessage.getTarget().getId()); // Update the model apexService.updateModel(updateModelMessage.getTarget(), updateModelMessage.getMessageData(), - updateModelMessage.isForceInstall()); + updateModelMessage.isForceInstall()); // Send a reply indicating the message action worked sendReply(webSocket, updateModelMessage, true, - "updated model in engine " + updateModelMessage.getTarget().getId()); + "updated model in engine " + updateModelMessage.getTarget().getId()); LOGGER.debug("updated model in engine service {}", updateModelMessage.getTarget().getId()); break; @@ -231,7 +227,7 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable apexService.start(startEngineMessage.getTarget()); // Send a reply indicating the message action worked sendReply(webSocket, startEngineMessage, true, - "started engine " + startEngineMessage.getTarget().getId()); + "started engine " + startEngineMessage.getTarget().getId()); LOGGER.debug("started engine {}", startEngineMessage.getTarget().getId()); break; @@ -242,33 +238,33 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable apexService.stop(stopEngineMessage.getTarget()); // Send a reply indicating the message action worked sendReply(webSocket, stopEngineMessage, true, - "stopped engine " + stopEngineMessage.getTarget().getId()); + "stopped engine " + stopEngineMessage.getTarget().getId()); LOGGER.debug("stopping engine {}", stopEngineMessage.getTarget().getId()); break; case START_PERIODIC_EVENTS: final StartPeriodicEvents startPeriodicEventsMessage = (StartPeriodicEvents) message; LOGGER.debug("starting periodic events on engine {} . . .", - startPeriodicEventsMessage.getTarget().getId()); + startPeriodicEventsMessage.getTarget().getId()); // Start periodic events with the period specified in the message final Long period = Long.parseLong(startPeriodicEventsMessage.getMessageData()); apexService.startPeriodicEvents(period); // Send a reply indicating the message action worked - sendReply(webSocket, startPeriodicEventsMessage, true, "started periodic events on engine " - + startPeriodicEventsMessage.getTarget().getId() + " with period " + period); - LOGGER.debug("started periodic events on engine " + startPeriodicEventsMessage.getTarget().getId() - + " with period " + period); + String periodicStartedMessage = "started periodic events on engine " + + startPeriodicEventsMessage.getTarget().getId() + " with period " + period; + sendReply(webSocket, startPeriodicEventsMessage, true, periodicStartedMessage); + LOGGER.debug(periodicStartedMessage); break; case STOP_PERIODIC_EVENTS: final StopPeriodicEvents stopPeriodicEventsMessage = (StopPeriodicEvents) message; LOGGER.debug("stopping periodic events on engine {} . . .", - stopPeriodicEventsMessage.getTarget().getId()); + stopPeriodicEventsMessage.getTarget().getId()); // Stop periodic events apexService.stopPeriodicEvents(); // Send a reply indicating the message action worked - sendReply(webSocket, stopPeriodicEventsMessage, true, - "stopped periodic events on engine " + stopPeriodicEventsMessage.getTarget().getId()); + sendReply(webSocket, stopPeriodicEventsMessage, true, "stopped periodic events on engine " + + stopPeriodicEventsMessage.getTarget().getId()); LOGGER.debug("stopped periodic events on engine " + stopPeriodicEventsMessage.getTarget().getId()); break; @@ -277,7 +273,7 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable LOGGER.debug("getting status for engine{} . . .", getEngineStatusMessage.getTarget().getId()); // Send a reply with the engine status sendReply(webSocket, getEngineStatusMessage, true, - apexService.getStatus(getEngineStatusMessage.getTarget())); + apexService.getStatus(getEngineStatusMessage.getTarget())); LOGGER.debug("returned status for engine {}", getEngineStatusMessage.getTarget().getId()); break; @@ -313,7 +309,7 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable * @param messageData the message data */ private void sendReply(final WebSocket client, final Message requestMessage, final boolean result, - final String messageData) { + final String messageData) { LOGGER.entry(result, messageData); if (client == null || !client.isOpen()) { @@ -321,8 +317,9 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable return; } - LOGGER.debug("sending {} to web socket {}", requestMessage.getAction(), - client.getRemoteSocketAddress().toString()); + String replyString = "sending " + requestMessage.getAction() + " to web socket " + + client.getRemoteSocketAddress().toString(); + LOGGER.debug(replyString); final Response responseMessage = new Response(requestMessage.getTarget(), result, requestMessage); responseMessage.setMessageData(messageData); @@ -344,14 +341,15 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable * @param apexModelKey the apex model key */ private void sendServiceInfoReply(final WebSocket client, final Message requestMessage, - final AxArtifactKey engineServiceKey, final Collection<AxArtifactKey> engineKeyCollection, - final AxArtifactKey apexModelKey) { + final AxArtifactKey engineServiceKey, final Collection<AxArtifactKey> engineKeyCollection, + final AxArtifactKey apexModelKey) { LOGGER.entry(); - LOGGER.debug("sending {} to web socket {}", requestMessage.getAction(), - client.getRemoteSocketAddress().toString()); + String sendingMessage = "sending " + requestMessage.getAction() + " to web socket " + + client.getRemoteSocketAddress().toString(); + LOGGER.debug(sendingMessage); - final EngineServiceInfoResponse responseMessage = - new EngineServiceInfoResponse(requestMessage.getTarget(), true, requestMessage); + final EngineServiceInfoResponse responseMessage = new EngineServiceInfoResponse(requestMessage.getTarget(), + true, requestMessage); responseMessage.setMessageData("engine service information"); responseMessage.setEngineServiceKey(engineServiceKey); responseMessage.setEngineKeyArray(engineKeyCollection); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java index 86589ac81..7ebcad830 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java @@ -22,14 +22,13 @@ package org.onap.policy.apex.service.engine.engdep; import java.net.InetSocketAddress; -import org.onap.policy.apex.service.engine.runtime.EngineService; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - import org.onap.policy.apex.core.infrastructure.messaging.MessagingService; import org.onap.policy.apex.core.infrastructure.messaging.MessagingServiceFactory; import org.onap.policy.apex.core.infrastructure.messaging.util.MessagingUtils; import org.onap.policy.apex.core.protocols.Message; +import org.onap.policy.apex.service.engine.runtime.EngineService; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; /** * The Class EngDepMessagingService is used to encapsulate the server side of EngDep communication. diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java index 38762ea97..8c7911bce 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java @@ -37,6 +37,9 @@ import org.slf4j.ext.XLoggerFactory; * @author Liam Fallon (liam.fallon@ericsson.com) */ public class ApexEvent extends HashMap<String, Object> implements Serializable { + // Recurring string constants + private static final String EVENT_PREAMBLE = "event \""; + private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEvent.class); private static final long serialVersionUID = -4451918242101961685L; @@ -111,7 +114,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { // An identifier for the current event execution. The default value here will always be unique // in a single JVM - private long executionID = ApexEvent.getNextExecutionID(); + private long executionId = ApexEvent.getNextExecutionId(); // A string holding a message that indicates why processing of this event threw an exception private String exceptionMessage; @@ -122,7 +125,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { * * @return the next candidate value for a Execution ID */ - private static synchronized long getNextExecutionID() { + private static synchronized long getNextExecutionId() { return nextExecutionID.getAndIncrement(); } @@ -139,11 +142,11 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { public ApexEvent(final String name, final String version, final String nameSpace, final String source, final String target) throws ApexEventException { // @formatter:off - this.name = validateField("name", name, NAME_REGEXP); - this.version = validateField("version", version, VERSION_REGEXP); - this.nameSpace = validateField("nameSpace", nameSpace, NAMESPACE_REGEXP); - this.source = validateField("source", source, SOURCE_REGEXP); - this.target = validateField("target", target, TARGET_REGEXP); + this.name = validateField(NAME_HEADER_FIELD, name, NAME_REGEXP); + this.version = validateField(VERSION_HEADER_FIELD, version, VERSION_REGEXP); + this.nameSpace = validateField(NAMESPACE_HEADER_FIELD, nameSpace, NAMESPACE_REGEXP); + this.source = validateField(SOURCE_HEADER_FIELD, source, SOURCE_REGEXP); + this.target = validateField(TARGET_HEADER_FIELD, target, TARGET_REGEXP); // @formatter:on } @@ -161,10 +164,10 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { if (fieldValue.matches(fieldRegexp)) { return fieldValue; } else { - LOGGER.warn("event \"" + name + ": field \"" + fieldName + "=" + fieldValue - + "\" is illegal. It doesn't match regex '" + fieldRegexp + "'"); - throw new ApexEventException( - "event \"" + name + ": field \"" + fieldName + "=" + fieldValue + "\" is illegal"); + String message = EVENT_PREAMBLE + name + ": field \"" + fieldName + "=" + fieldValue + + "\" is illegal. It doesn't match regex '" + fieldRegexp + "'"; + LOGGER.warn(message); + throw new ApexEventException(message); } } @@ -179,8 +182,9 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { if (key.matches(AxReferenceKey.LOCAL_NAME_REGEXP)) { return key; } else { - LOGGER.warn("event \"" + name + ": key \"" + key + "\" is illegal"); - throw new ApexEventException("event \"" + name + ": key \"" + key + "\" is illegal"); + String message = EVENT_PREAMBLE + name + ": key \"" + key + "\" is illegal"; + LOGGER.warn(message); + throw new ApexEventException(message); } } @@ -234,8 +238,8 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { * * @return the executionID */ - public long getExecutionID() { - return executionID; + public long getExecutionId() { + return executionId; } /** @@ -243,10 +247,10 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { * unique in the current JVM. For some applications/deployments this executionID may need to * globally unique * - * @param executionID the executionID + * @param executionId the executionID */ - public void setExecutionID(final long executionID) { - this.executionID = executionID; + public void setExecutionId(final long executionId) { + this.executionId = executionId; } /** @@ -330,7 +334,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable { builder.append(",target="); builder.append(target); builder.append(",executionID="); - builder.append(executionID); + builder.append(executionId); builder.append(",exceptionMessage="); builder.append(exceptionMessage); builder.append(","); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java index b34d5185c..32f87a7cc 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java @@ -86,7 +86,7 @@ public class ApexPeriodicEventGenerator extends TimerTask { private final EngineServiceEventInterface engineServiceEventInterface; // Timing information - private long period = 0; + private long eventGeneratorPeriod = 0; private long firstEventTime = 0; private long lastEventTime = 0; private long eventCount = 0; @@ -102,7 +102,7 @@ public class ApexPeriodicEventGenerator extends TimerTask { final long period) { // Save the engine service reference and delay this.engineServiceEventInterface = engineServiceEventInterface; - this.period = period; + this.eventGeneratorPeriod = period; timer = new Timer(ApexPeriodicEventGenerator.class.getSimpleName(), true); timer.schedule(this, period, period); @@ -128,7 +128,7 @@ public class ApexPeriodicEventGenerator extends TimerTask { eventCount++; // Set the fields in the periodic event - periodicEventMap.put(PERIODIC_DELAY, period); + periodicEventMap.put(PERIODIC_DELAY, eventGeneratorPeriod); periodicEventMap.put(PERIODIC_FIRST_TIME, firstEventTime); periodicEventMap.put(PERIODIC_LAST_TIME, lastEventTime); periodicEventMap.put(PERIODIC_CURRENT_TIME, currentEventTime); @@ -170,7 +170,7 @@ public class ApexPeriodicEventGenerator extends TimerTask { */ @Override public String toString() { - return "ApexPeriodicEventGenerator [period=" + period + ", firstEventTime=" + firstEventTime + return "ApexPeriodicEventGenerator [period=" + eventGeneratorPeriod + ", firstEventTime=" + firstEventTime + ", lastEventTime=" + lastEventTime + ", eventCount=" + eventCount + "]"; } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java index 1830fc0e5..5e48a5894 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java @@ -33,9 +33,8 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * This class holds a cache of the synchronous events sent into Apex and that have not yet been - * replied to. It runs a thread to time out events that have not been replied to in the specified - * timeout. + * This class holds a cache of the synchronous events sent into Apex and that have not yet been replied to. It runs a + * thread to time out events that have not been replied to in the specified timeout. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -55,11 +54,10 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { private long synchronousEventTimeout = DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT; // Map holding outstanding synchronous events - private final Map<Long, SimpleEntry<Long, Object>> toApexEventMap = new HashMap<Long, SimpleEntry<Long, Object>>(); + private final Map<Long, SimpleEntry<Long, Object>> toApexEventMap = new HashMap<>(); // Map holding reply events - private final Map<Long, SimpleEntry<Long, Object>> fromApexEventMap = - new HashMap<Long, SimpleEntry<Long, Object>>(); + private final Map<Long, SimpleEntry<Long, Object>> fromApexEventMap = new HashMap<>(); // The message listener thread and stopping flag private final Thread synchronousEventCacheThread; @@ -71,11 +69,10 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { * @param peeredMode the peered mode for which to return the reference * @param consumer the consumer that is populating the cache * @param producer the producer that is emptying the cache - * @param synchronousEventTimeout the time in milliseconds to wait for the reply to a sent - * synchronous event + * @param synchronousEventTimeout the time in milliseconds to wait for the reply to a sent synchronous event */ public SynchronousEventCache(final EventHandlerPeeredMode peeredMode, final ApexEventConsumer consumer, - final ApexEventProducer producer, final long synchronousEventTimeout) { + final ApexEventProducer producer, final long synchronousEventTimeout) { super(peeredMode, consumer, producer); if (synchronousEventTimeout != 0) { @@ -211,7 +208,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { // Check if there are any unprocessed events if (!toApexEventMap.isEmpty()) { - LOGGER.warn(toApexEventMap.size() + " synchronous events dropped due to system shutdown"); + String message = toApexEventMap.size() + " synchronous events dropped due to system shutdown"; + LOGGER.warn(message); } toApexEventMap.clear(); @@ -226,7 +224,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { * @param event the event to cache */ private void cacheSynchronizedEvent(final Map<Long, SimpleEntry<Long, Object>> eventCacheMap, - final long executionId, final Object event) { + final long executionId, final Object event) { LOGGER.entry("Adding event with execution ID: " + executionId); // Check if the event is already in the cache @@ -234,7 +232,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { // If there was no sent event then the event timed out or some unexpected event was // received final String errorMessage = "an event with ID " + executionId - + " already exists in the synchronous event cache, execution IDs must be unique in the system"; + + " already exists in the synchronous event cache, " + + "execution IDs must be unique in the system"; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -243,7 +242,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { eventCacheMap.put(executionId, new SimpleEntry<Long, Object>(System.currentTimeMillis(), event)); if (LOGGER.isDebugEnabled()) { - LOGGER.debug("event has been cached:" + event); + String message = "event has been cached:" + event; + LOGGER.debug(message); } LOGGER.exit("Added: " + executionId); @@ -257,7 +257,7 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { * @return The removed event */ private Object removeCachedEventIfExists(final Map<Long, SimpleEntry<Long, Object>> eventCacheMap, - final long executionId) { + final long executionId) { LOGGER.entry("Removing: " + executionId); final SimpleEntry<Long, Object> removedEventEntry = eventCacheMap.remove(executionId); @@ -273,8 +273,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { } /** - * Time out events on an event cache map. Events that have a timeout longer than the configured - * timeout are timed out. + * Time out events on an event cache map. Events that have a timeout longer than the configured timeout are timed + * out. * * @param eventCacheMap the event cache to operate on */ @@ -293,12 +293,13 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { } // Remove timed out events from the map - for (final long timedoutEventExecutionID : timedOutEventSet) { + for (final long timedoutEventExecutionId : timedOutEventSet) { // Remove the map entry and issue a warning - final SimpleEntry<Long, Object> timedOutEventEntry = eventCacheMap.remove(timedoutEventExecutionID); + final SimpleEntry<Long, Object> timedOutEventEntry = eventCacheMap.remove(timedoutEventExecutionId); - LOGGER.warn("synchronous event timed out, reply not received in " + synchronousEventTimeout - + " milliseconds on event " + timedOutEventEntry.getValue()); + String message = "synchronous event timed out, reply not received in " + synchronousEventTimeout + + " milliseconds on event " + timedOutEventEntry.getValue(); + LOGGER.warn(message); } } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventConsumerFactory.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventConsumerFactory.java index 8f54c049b..5c44f2d7d 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventConsumerFactory.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventConsumerFactory.java @@ -37,11 +37,6 @@ public class EventConsumerFactory { private static final XLogger LOGGER = XLoggerFactory.getXLogger(EventConsumerFactory.class); /** - * Empty constructor with no generic overloading. - */ - public EventConsumerFactory() {} - - /** * Create an event consumer of the required type for the specified consumer technology. * * @param name the name of the consumer diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventProducerFactory.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventProducerFactory.java index 9bbbad362..727f77995 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventProducerFactory.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/EventProducerFactory.java @@ -37,11 +37,6 @@ public class EventProducerFactory { private static final XLogger LOGGER = XLoggerFactory.getXLogger(EventProducerFactory.class); /** - * Empty constructor with no generic overloading. - */ - public EventProducerFactory() {} - - /** * Create an event producer of the required type for the specified producer technology. * * @param name the name of the producer diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java index 34690cc7d..5fce2c89f 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java @@ -23,19 +23,18 @@ package org.onap.policy.apex.service.engine.event.impl.enevent; import java.util.ArrayList; import java.util.List; -import org.onap.policy.apex.service.engine.event.ApexEvent; -import org.onap.policy.apex.service.engine.event.ApexEventConverter; -import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - import org.onap.policy.apex.core.engine.engine.ApexEngine; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.service.ModelService; import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; import org.onap.policy.apex.model.eventmodel.concepts.AxEvents; +import org.onap.policy.apex.service.engine.event.ApexEvent; +import org.onap.policy.apex.service.engine.event.ApexEventConverter; +import org.onap.policy.apex.service.engine.event.ApexEventException; +import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; /** * The Class ApexEvent2EnEventConverter converts externally facing {@link ApexEvent} instances to @@ -90,7 +89,7 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter { axEvent.getNameSpace(), axEvent.getSource(), axEvent.getTarget()); // Copy the ExecutionID from the EnEvent into the ApexEvent - apexEvent.setExecutionID(enEvent.getExecutionId()); + apexEvent.setExecutionId(enEvent.getExecutionId()); // Copy he exception message to the Apex event if it is set if (enEvent.getExceptionMessage() != null) { @@ -101,7 +100,7 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter { apexEvent.putAll(enEvent); // Return the event in a single element - final ArrayList<ApexEvent> eventList = new ArrayList<ApexEvent>(); + final ArrayList<ApexEvent> eventList = new ArrayList<>(); eventList.add(apexEvent); return eventList; } @@ -136,7 +135,7 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter { enEvent.putAll(apexEvent); // copy the ExecutionID from the ApexEvent into the EnEvent - enEvent.setExecutionId(apexEvent.getExecutionID()); + enEvent.setExecutionId(apexEvent.getExecutionId()); return enEvent; } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java index 84d19fc62..cbfe18016 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java @@ -31,22 +31,17 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * This class holds the parameters that allows transport of events into and out of Apex using files and standard input * and output. * - * <p> - * The following parameters are defined: - * <ol> - * <li>fileName: The full path to the file from which to read events or to which to write events. - * <li>standardIO: If this flag is set to true, then standard input is used to read events in or standard output is used - * to write events and the fileName parameter is ignored if present - * <li>standardError: If this flag is set to true, then standard error is used to write events - * <li>streamingMode: If this flag is set to true, then streaming mode is set for reading events and event handling will - * wait on the input stream for events until the stream is closed. If streaming model is off, then event reading - * completes when the end of input is detected. - * <li>startDelay: The amount of milliseconds to wait at startup startup before processing the first event. - * </ol> + * <p>The following parameters are defined: <ol> <li>fileName: The full path to the file from which to read events or to + * which to write events. <li>standardIO: If this flag is set to true, then standard input is used to read events in or + * standard output is used to write events and the fileName parameter is ignored if present <li>standardError: If this + * flag is set to true, then standard error is used to write events <li>streamingMode: If this flag is set to true, then + * streaming mode is set for reading events and event handling will wait on the input stream for events until the stream + * is closed. If streaming model is off, then event reading completes when the end of input is detected. <li>startDelay: + * The amount of milliseconds to wait at startup startup before processing the first event. </ol> * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters { +public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters { // @formatter:off /** The label of this carrier technology. */ public static final String FILE_CARRIER_TECHNOLOGY_LABEL = "FILE"; @@ -58,7 +53,7 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters public static final String FILE_EVENT_CONSUMER_PLUGIN_CLASS = ApexFileEventConsumer.class.getCanonicalName(); private String fileName; - private boolean standardIO = false; + private boolean standardIo = false; private boolean standardError = false; private boolean streamingMode = false; private long startDelay = 0; @@ -68,7 +63,7 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters * Constructor to create a file carrier technology parameters instance and register the instance with the parameter * service. */ - public FILECarrierTechnologyParameters() { + public FileCarrierTechnologyParameters() { super(); // Set the carrier technology properties for the FILE carrier technology @@ -91,8 +86,8 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters * * @return true, if standard IO should be used for input or output */ - public boolean isStandardIO() { - return standardIO; + public boolean isStandardIo() { + return standardIo; } /** @@ -125,10 +120,10 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters /** * Sets if standard IO should be used for event input or output. * - * @param standardIO if standard IO should be used for event input or output + * @param standardIo if standard IO should be used for event input or output */ - public void setStandardIO(final boolean standardIO) { - this.standardIO = standardIO; + public void setStandardIo(final boolean standardIo) { + this.standardIo = standardIo; } /** @@ -174,7 +169,7 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters */ @Override public String toString() { - return "FILECarrierTechnologyParameters [fileName=" + fileName + ", standardIO=" + standardIO + return "FILECarrierTechnologyParameters [fileName=" + fileName + ", standardIO=" + standardIo + ", standardError=" + standardError + ", streamingMode=" + streamingMode + ", startDelay=" + startDelay + "]"; } @@ -198,12 +193,12 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters public GroupValidationResult validate() { final GroupValidationResult result = super.validate(); - if (!standardIO && !standardError && (fileName == null || fileName.trim().length() == 0)) { - result.setResult("fileName", ValidationStatus.INVALID, - "fileName not specified or is blank or null, it must be specified as a valid file location"); + if (!standardIo && !standardError && (fileName == null || fileName.trim().length() == 0)) { + result.setResult("fileName", ValidationStatus.INVALID, "fileName not specified or is blank or null, " + + "it must be specified as a valid file location"); } - if (standardIO || standardError) { + if (standardIo || standardError) { streamingMode = true; } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java index 7521c3a08..0f0996fb8 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java @@ -33,23 +33,25 @@ 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.PeeredReference; -import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters; +import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters; 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; /** - * Concrete implementation an Apex event consumer that reads events from a file. This consumer also - * implements ApexEventProducer and therefore can be used as a synchronous consumer. + * Concrete implementation an Apex event consumer that reads events from a file. This consumer also implements + * ApexEventProducer and therefore can be used as a synchronous consumer. * * @author Liam Fallon (liam.fallon@ericsson.com) */ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable { - // Get a reference to the logger private static final Logger LOGGER = LoggerFactory.getLogger(ApexFileEventConsumer.class); + // Recurring string constants + private static final String APEX_FILE_CONSUMER_PREAMBLE = "ApexFileConsumer \""; + // The input stream to read events from private InputStream eventInputStream; @@ -66,35 +68,34 @@ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable { private String consumerName = null; // The specific carrier technology parameters for this consumer - private FILECarrierTechnologyParameters fileCarrierTechnologyParameters; + private FileCarrierTechnologyParameters fileCarrierTechnologyParameters; // The peer references for this event handler - private final Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = - new EnumMap<>(EventHandlerPeeredMode.class); + private final Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>( + EventHandlerPeeredMode.class); // Holds the next identifier for event execution. private static AtomicLong nextExecutionID = new AtomicLong(0L); /** - * Private utility to get the next candidate value for a Execution ID. This value will always be - * unique in a single JVM + * Private utility to get the next candidate value for a Execution ID. This value will always be unique in a single + * JVM * * @return the next candidate value for a Execution ID */ - private static synchronized long getNextExecutionID() { + private static synchronized long getNextExecutionId() { return nextExecutionID.getAndIncrement(); } /* * (non-Javadoc) * - * @see - * org.onap.policy.apex.apps.uservice.consumer.ApexEventConsumer#init(org.onap.policy.apex.apps. + * @see org.onap.policy.apex.apps.uservice.consumer.ApexEventConsumer#init(org.onap.policy.apex.apps. * uservice.consumer.ApexEventReceiver) */ @Override public void init(final String name, final EventHandlerParameters consumerParameters, - final ApexEventReceiver incomingEventReceiver) throws ApexEventException { + final ApexEventReceiver incomingEventReceiver) throws ApexEventException { this.eventReceiver = incomingEventReceiver; this.consumerName = name; @@ -106,18 +107,18 @@ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable { } // Check and get the file Properties - if (!(consumerParameters.getCarrierTechnologyParameters() instanceof FILECarrierTechnologyParameters)) { + if (!(consumerParameters.getCarrierTechnologyParameters() instanceof FileCarrierTechnologyParameters)) { final String errorMessage = "specified consumer properties for ApexFileConsumer \"" + consumerName - + "\" are not applicable to a File consumer"; + + "\" are not applicable to a File consumer"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - fileCarrierTechnologyParameters = - (FILECarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters(); + fileCarrierTechnologyParameters = (FileCarrierTechnologyParameters) consumerParameters + .getCarrierTechnologyParameters(); // Open the file producing events try { - if (fileCarrierTechnologyParameters.isStandardIO()) { + if (fileCarrierTechnologyParameters.isStandardIo()) { eventInputStream = System.in; } else { eventInputStream = new FileInputStream(fileCarrierTechnologyParameters.getFileName()); @@ -125,10 +126,11 @@ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable { // Get an event composer for our event source textBlockReader = new TextBlockReaderFactory().getTaggedReader(eventInputStream, - consumerParameters.getEventProtocolParameters()); + consumerParameters.getEventProtocolParameters()); } catch (final IOException e) { - final String errorMessage = "ApexFileConsumer \"" + consumerName + "\" failed to open file for reading: \"" - + fileCarrierTechnologyParameters.getFileName() + "\""; + final String errorMessage = APEX_FILE_CONSUMER_PREAMBLE + consumerName + + "\" failed to open file for reading: \"" + fileCarrierTechnologyParameters.getFileName() + + "\""; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -195,7 +197,7 @@ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable { // Check that we have been initialized in async or sync mode if (eventReceiver == null) { LOGGER.warn("\"{}\" has not been initilaized for either asynchronous or synchronous event handling", - consumerName); + consumerName); return; } @@ -209,18 +211,19 @@ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable { // Process the event from the text block if there is one there if (textBlock.getText() != null) { - eventReceiver.receiveEvent(getNextExecutionID(), textBlock.getText()); + eventReceiver.receiveEvent(getNextExecutionId(), textBlock.getText()); } - } while (!textBlock.isEndOfText()); + } + while (!textBlock.isEndOfText()); } catch (final Exception e) { LOGGER.warn("\"" + consumerName + "\" failed to read event from file: \"" - + fileCarrierTechnologyParameters.getFileName() + "\"", e); + + fileCarrierTechnologyParameters.getFileName() + "\"", e); } finally { try { eventInputStream.close(); } catch (final IOException e) { - LOGGER.warn("ApexFileConsumer \"" + consumerName + "\" failed to close file: \"" - + fileCarrierTechnologyParameters.getFileName() + "\"", e); + LOGGER.warn(APEX_FILE_CONSUMER_PREAMBLE + consumerName + "\" failed to close file: \"" + + fileCarrierTechnologyParameters.getFileName() + "\"", e); } } @@ -236,8 +239,8 @@ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable { try { eventInputStream.close(); } catch (final IOException e) { - LOGGER.warn("ApexFileConsumer \"" + consumerName + "\" failed to close file for reading: \"" - + fileCarrierTechnologyParameters.getFileName() + "\"", e); + LOGGER.warn(APEX_FILE_CONSUMER_PREAMBLE + consumerName + "\" failed to close file for reading: \"" + + fileCarrierTechnologyParameters.getFileName() + "\"", e); } if (consumerThread.isAlive() && !consumerThread.isInterrupted()) { diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java index b286f8afe..bd7310d0a 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java @@ -93,12 +93,29 @@ public class CharacterDelimitedTextBlockReader implements TextBlockReader { return new TextBlock(eofOnInputStream, null); } - // The initial nesting level of incoming text blocks is always zero - int nestingLevel = 0; + // Read the block of text + final StringBuilder textBlockBuilder = readTextBlockText(); + // Condition the text block and return it + final String textBlock = textBlockBuilder.toString().trim(); + if (textBlock.length() > 0) { + return new TextBlock(eofOnInputStream, textBlock); + } else { + return new TextBlock(eofOnInputStream, null); + } + } + + /** + * Read a block of text. + * @return A string builder containing the text + * @throws IOException on read errors + */ + private StringBuilder readTextBlockText() throws IOException { // Holder for the text block final StringBuilder textBlockBuilder = new StringBuilder(); + int nestingLevel = 0; + // Read the next text block while (true) { final char nextChar = (char) inputStream.read(); @@ -106,13 +123,13 @@ public class CharacterDelimitedTextBlockReader implements TextBlockReader { // Check for EOF if (nextChar == (char) -1) { eofOnInputStream = true; - break; + return textBlockBuilder; } if (nextChar == startTagChar) { nestingLevel++; } else if (nestingLevel == 0 && !Character.isWhitespace(nextChar)) { - LOGGER.warn("invalid input on consumer: " + nextChar); + LOGGER.warn("invalid input on consumer: {}", nextChar); continue; } @@ -125,17 +142,9 @@ public class CharacterDelimitedTextBlockReader implements TextBlockReader { } if (nestingLevel == 0) { - break; + return textBlockBuilder; } } } - - // Condition the text block and return it - final String textBlock = textBlockBuilder.toString().trim(); - if (textBlock.length() > 0) { - return new TextBlock(eofOnInputStream, textBlock); - } else { - return new TextBlock(eofOnInputStream, null); - } } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java index 07185c024..982044022 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java @@ -162,7 +162,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable // Condition the text block and return it final String textBlock = textBlockBuilder.toString().trim(); - final boolean endOfText = (eofOnInputStream && textLineQueue.isEmpty() ? true : false); + final boolean endOfText = eofOnInputStream && textLineQueue.isEmpty(); if (textBlock.length() > 0) { return new TextBlock(endOfText, textBlock); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java index d5f9ff1b2..e12b772df 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java @@ -32,7 +32,7 @@ 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.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters; +import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; import org.slf4j.Logger; @@ -74,20 +74,20 @@ public class ApexFileEventProducer implements ApexEventProducer { } // Check and get the file Properties - if (!(producerParameters.getCarrierTechnologyParameters() instanceof FILECarrierTechnologyParameters)) { + if (!(producerParameters.getCarrierTechnologyParameters() instanceof FileCarrierTechnologyParameters)) { final String errorMessage = "specified producer properties for ApexFileProducer \"" + producerName + "\" are not applicable to a FILE producer"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } - final FILECarrierTechnologyParameters fileCarrierTechnologyParameters = - (FILECarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); + final FileCarrierTechnologyParameters fileCarrierTechnologyParameters = + (FileCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters(); // Now we create a writer for events try { if (fileCarrierTechnologyParameters.isStandardError()) { eventOutputStream = System.err; - } else if (fileCarrierTechnologyParameters.isStandardIO()) { + } else if (fileCarrierTechnologyParameters.isStandardIo()) { eventOutputStream = System.out; } else { eventOutputStream = diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JSONEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java index 30e9db722..ce511be7f 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JSONEventConverter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java @@ -20,6 +20,11 @@ package org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + import java.util.ArrayList; import java.util.List; @@ -37,48 +42,40 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - /** - * The Class Apex2JSONEventConverter converts {@link ApexEvent} instances to and from JSON string - * representations of Apex events. + * The Class Apex2JSONEventConverter converts {@link ApexEvent} instances to and from JSON string representations of + * Apex events. * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class Apex2JSONEventConverter implements ApexEventProtocolConverter { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JSONEventConverter.class); +public class Apex2JsonEventConverter implements ApexEventProtocolConverter { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(Apex2JsonEventConverter.class); // The parameters for the JSON event protocol - private JSONEventProtocolParameters jsonPars; + private JsonEventProtocolParameters jsonPars; /* * (non-Javadoc) * - * @see - * org.onap.policy.apex.service.engine.event.ApexEventProtocolConverter#init(org.onap.policy. + * @see org.onap.policy.apex.service.engine.event.ApexEventProtocolConverter#init(org.onap.policy. * apex.service.parameters.eventprotocol.EventProtocolParameters) */ @Override public void init(final EventProtocolParameters parameters) { // Check and get the JSON parameters - if (!(parameters instanceof JSONEventProtocolParameters)) { + if (!(parameters instanceof JsonEventProtocolParameters)) { final String errorMessage = "specified consumer properties are not applicable to the JSON event protocol"; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } - jsonPars = (JSONEventProtocolParameters) parameters; + jsonPars = (JsonEventProtocolParameters) parameters; } /* * (non-Javadoc) * - * @see - * org.onap.policy.apex.service.engine.event.ApexEventConverter#toApexEvent(java.lang.String, - * java.lang.Object) + * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#toApexEvent(java.lang.String, java.lang.Object) */ @Override public List<ApexEvent> toApexEvent(final String eventName, final Object eventObject) throws ApexEventException { @@ -104,8 +101,8 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { try { // We may have a single JSON object with a single event or an array of JSON objects - final Object decodedJsonObject = - new GsonBuilder().serializeNulls().create().fromJson(jsonEventString, Object.class); + final Object decodedJsonObject = new GsonBuilder().serializeNulls().create().fromJson(jsonEventString, + Object.class); // Check if we have a list of objects if (decodedJsonObject instanceof List) { @@ -121,15 +118,15 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { eventList.add(jsonObject2ApexEvent(eventName, (JsonObject) jsonListObject)); } else { throw new ApexEventException("incoming event (" + jsonEventString - + ") is a JSON object array containing an invalid object " + jsonListObject); + + ") is a JSON object array containing an invalid object " + jsonListObject); } } } else { eventList.add(jsonStringApexEvent(eventName, jsonEventString)); } } catch (final Exception e) { - final String errorString = - "Failed to unmarshal JSON event: " + e.getMessage() + ", event=" + jsonEventString; + final String errorString = "Failed to unmarshal JSON event: " + e.getMessage() + ", event=" + + jsonEventString; LOGGER.warn(errorString, e); throw new ApexEventException(errorString, e); } @@ -141,8 +138,7 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { /* * (non-Javadoc) * - * @see - * org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent(org.onap.policy. + * @see org.onap.policy.apex.service.engine.event.ApexEventConverter#fromApexEvent(org.onap.policy. * apex.service.engine.event.ApexEvent) */ @Override @@ -154,8 +150,8 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { } // Get the event definition for the event from the model service - final AxEvent eventDefinition = - ModelService.getModel(AxEvents.class).get(apexEvent.getName(), apexEvent.getVersion()); + final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(apexEvent.getName(), + apexEvent.getVersion()); // Use a GSON Json object to marshal the Apex event to JSON final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().create(); @@ -177,7 +173,7 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { if (!apexEvent.containsKey(fieldName)) { if (!eventField.getOptional()) { final String errorMessage = "error parsing " + eventDefinition.getId() + " event to Json. " - + "Field \"" + fieldName + "\" is missing, but is mandatory. Fields: " + apexEvent; + + "Field \"" + fieldName + "\" is missing, but is mandatory. Fields: " + apexEvent; LOGGER.debug(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -187,8 +183,8 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { final Object fieldValue = apexEvent.get(fieldName); // Get the schema helper - final SchemaHelper fieldSchemaHelper = - new SchemaHelperFactory().createSchemaHelper(eventField.getKey(), eventField.getSchema()); + final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(), + eventField.getSchema()); jsonObject.add(fieldName, (JsonElement) fieldSchemaHelper.marshal2Object(fieldValue)); } @@ -205,14 +201,14 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { * @throws ApexEventException thrown on unmarshaling exceptions */ private ApexEvent jsonStringApexEvent(final String eventName, final String jsonEventString) - throws ApexEventException { + throws ApexEventException { // Use GSON to read the event string - final JsonObject jsonObject = - new GsonBuilder().serializeNulls().create().fromJson(jsonEventString, JsonObject.class); + final JsonObject jsonObject = new GsonBuilder().serializeNulls().create().fromJson(jsonEventString, + JsonObject.class); if (jsonObject == null || !jsonObject.isJsonObject()) { throw new ApexEventException( - "incoming event (" + jsonEventString + ") is not a JSON object or an JSON object array"); + "incoming event (" + jsonEventString + ") is not a JSON object or an JSON object array"); } return jsonObject2ApexEvent(eventName, jsonObject); @@ -227,33 +223,33 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { * @throws ApexEventException thrown on unmarshaling exceptions */ private ApexEvent jsonObject2ApexEvent(final String eventName, final JsonObject jsonObject) - throws ApexEventException { + throws ApexEventException { // Process the mandatory Apex header final ApexEvent apexEvent = processApexEventHeader(eventName, jsonObject); // Get the event definition for the event from the model service - final AxEvent eventDefinition = - ModelService.getModel(AxEvents.class).get(apexEvent.getName(), apexEvent.getVersion()); + final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(apexEvent.getName(), + apexEvent.getVersion()); // Iterate over the input fields in the event for (final AxField eventField : eventDefinition.getFields()) { final String fieldName = eventField.getKey().getLocalName(); - if (!hasJSONField(jsonObject, fieldName)) { + if (!hasJsonField(jsonObject, fieldName)) { if (!eventField.getOptional()) { final String errorMessage = "error parsing " + eventDefinition.getId() + " event from Json. " - + "Field \"" + fieldName + "\" is missing, but is mandatory."; + + "Field \"" + fieldName + "\" is missing, but is mandatory."; LOGGER.debug(errorMessage); throw new ApexEventException(errorMessage); } continue; } - final JsonElement fieldValue = getJSONField(jsonObject, fieldName, null, !eventField.getOptional()); + final JsonElement fieldValue = getJsonField(jsonObject, fieldName, null, !eventField.getOptional()); if (fieldValue != null && !fieldValue.isJsonNull()) { // Get the schema helper - final SchemaHelper fieldSchemaHelper = - new SchemaHelperFactory().createSchemaHelper(eventField.getKey(), eventField.getSchema()); + final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(), + eventField.getSchema()); apexEvent.put(fieldName, fieldSchemaHelper.createNewInstance(fieldValue)); } else { apexEvent.put(fieldName, null); @@ -273,46 +269,32 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { * @throws ApexEventException on invalid events with missing header fields */ private ApexEvent processApexEventHeader(final String eventName, final JsonObject jsonObject) - throws ApexEventException { - // Get the event header fields - // @formatter:off - String name = getJSONStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD, - jsonPars.getNameAlias(), ApexEvent.NAME_REGEXP, false); - String version = getJSONStringField(jsonObject, ApexEvent.VERSION_HEADER_FIELD, - jsonPars.getVersionAlias(), ApexEvent.VERSION_REGEXP, false); - String namespace = getJSONStringField(jsonObject, ApexEvent.NAMESPACE_HEADER_FIELD, - jsonPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false); - String source = getJSONStringField(jsonObject, ApexEvent.SOURCE_HEADER_FIELD, - jsonPars.getSourceAlias(), ApexEvent.SOURCE_REGEXP, false); - String target = getJSONStringField(jsonObject, ApexEvent.TARGET_HEADER_FIELD, - jsonPars.getTargetAlias(), ApexEvent.TARGET_REGEXP, false); - // @formatter:on + throws ApexEventException { + String name = getJsonStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD, jsonPars.getNameAlias(), + ApexEvent.NAME_REGEXP, false); // Check that an event name has been specified if (name == null && eventName == null) { throw new ApexEventRuntimeException( - "event received without mandatory parameter \"name\" on configuration or on event"); + "event received without mandatory parameter \"name\" on configuration or on event"); } // Check if an event name was specified on the event parameters if (eventName != null) { if (name != null && !eventName.equals(name)) { LOGGER.warn("The incoming event name \"{}\" does not match the configured event name \"{}\"," - + " using configured event name", name, eventName); + + " using configured event name", name, eventName); } name = eventName; } // Now, find the event definition in the model service. If version is null, the newest event // definition in the model service is used + String version = getJsonStringField(jsonObject, ApexEvent.VERSION_HEADER_FIELD, jsonPars.getVersionAlias(), + ApexEvent.VERSION_REGEXP, false); final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(name, version); if (eventDefinition == null) { - if (version == null) { - throw new ApexEventRuntimeException( - "an event definition for an event named \"" + name + "\" not found in Apex model"); - } - throw new ApexEventRuntimeException("an event definition for an event named \"" + name - + "\" with version \"" + version + "\" not found in Apex model"); + throwVersionException(name, version); } // Use the defined event version if no version is specified on the incoming fields @@ -321,22 +303,28 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { } // Check the name space is OK if it is defined, if not, use the name space from the model + String namespace = getJsonStringField(jsonObject, ApexEvent.NAMESPACE_HEADER_FIELD, + jsonPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false); if (namespace != null) { if (!namespace.equals(eventDefinition.getNameSpace())) { - throw new ApexEventRuntimeException( - "namespace \"" + namespace + "\" on event \"" + name + "\" does not match namespace \"" - + eventDefinition.getNameSpace() + "\" for that event in the Apex model"); + throw new ApexEventRuntimeException("namespace \"" + namespace + "\" on event \"" + name + + "\" does not match namespace \"" + eventDefinition.getNameSpace() + + "\" for that event in the Apex model"); } } else { namespace = eventDefinition.getNameSpace(); } // For source, use the defined source only if the source is not found on the incoming event + String source = getJsonStringField(jsonObject, ApexEvent.SOURCE_HEADER_FIELD, jsonPars.getSourceAlias(), + ApexEvent.SOURCE_REGEXP, false); if (source == null) { source = eventDefinition.getSource(); } // For target, use the defined source only if the source is not found on the incoming event + String target = getJsonStringField(jsonObject, ApexEvent.TARGET_HEADER_FIELD, jsonPars.getTargetAlias(), + ApexEvent.TARGET_REGEXP, false); if (target == null) { target = eventDefinition.getTarget(); } @@ -345,21 +333,36 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { } /** + * Throw an exception on event name and/or version with the correct text. + * @param name The event name + * @param version The event version + */ + private void throwVersionException(String name, String version) { + if (version == null) { + throw new ApexEventRuntimeException( + "an event definition for an event named \"" + name + "\" not found in Apex model"); + } + else { + throw new ApexEventRuntimeException("an event definition for an event named \"" + name + + "\" with version \"" + version + "\" not found in Apex model"); + } + } + + /** * This method gets an event string field from a JSON object. * * @param jsonObject the JSON object containing the JSON representation of the incoming event * @param fieldName the field name to find in the event - * @param fieldAlias the alias for the field to find in the event, overrides the field name if - * it is not null - * @param fieldRE the regular expression to check the field against for validity + * @param fieldAlias the alias for the field to find in the event, overrides the field name if it is not null + * @param fieldRegexp the regular expression to check the field against for validity * @param mandatory true if the field is mandatory * @return the value of the field in the JSON object or null if the field is optional * @throws ApexEventRuntimeException the apex event runtime exception */ - private String getJSONStringField(final JsonObject jsonObject, final String fieldName, final String fieldAlias, - final String fieldRE, final boolean mandatory) { + private String getJsonStringField(final JsonObject jsonObject, final String fieldName, final String fieldAlias, + final String fieldRegexp, final boolean mandatory) { // Get the JSON field for the string field - final JsonElement jsonField = getJSONField(jsonObject, fieldName, fieldAlias, mandatory); + final JsonElement jsonField = getJsonField(jsonObject, fieldName, fieldAlias, mandatory); // Null strings are allowed if (jsonField == null || jsonField.isJsonNull()) { @@ -373,18 +376,18 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { } catch (final Exception e) { // The element is not a string so throw an error throw new ApexEventRuntimeException("field \"" + fieldName + "\" with type \"" - + jsonField.getClass().getCanonicalName() + "\" is not a string value"); + + jsonField.getClass().getCanonicalName() + "\" is not a string value"); } // Is regular expression checking required - if (fieldRE == null) { + if (fieldRegexp == null) { return fieldValueString; } // Check the event field against its regular expression - if (!fieldValueString.matches(fieldRE)) { + if (!fieldValueString.matches(fieldRegexp)) { throw new ApexEventRuntimeException( - "field \"" + fieldName + "\" with value \"" + fieldValueString + "\" is invalid"); + "field \"" + fieldName + "\" with value \"" + fieldValueString + "\" is invalid"); } return fieldValueString; @@ -395,14 +398,13 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { * * @param jsonObject the JSON object containing the JSON representation of the incoming event * @param fieldName the field name to find in the event - * @param fieldAlias the alias for the field to find in the event, overrides the field name if - * it is not null + * @param fieldAlias the alias for the field to find in the event, overrides the field name if it is not null * @param mandatory true if the field is mandatory * @return the value of the field in the JSON object or null if the field is optional * @throws ApexEventRuntimeException the apex event runtime exception */ - private JsonElement getJSONField(final JsonObject jsonObject, final String fieldName, final String fieldAlias, - final boolean mandatory) { + private JsonElement getJsonField(final JsonObject jsonObject, final String fieldName, final String fieldAlias, + final boolean mandatory) { // Check if we should use the alias for this field String fieldToFind = fieldName; @@ -431,7 +433,7 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { * @return true if the field is present * @throws ApexEventRuntimeException the apex event runtime exception */ - private boolean hasJSONField(final JsonObject jsonObject, final String fieldName) { + private boolean hasJsonField(final JsonObject jsonObject, final String fieldName) { // check for the field return jsonObject.has(fieldName); } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java index 6efcceb43..8e44ec59b 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java @@ -41,7 +41,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextCh * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class JSONEventProtocolParameters extends EventProtocolTextCharDelimitedParameters { +public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedParameters { /** The label of this event protocol. */ public static final String JSON_EVENT_PROTOCOL_LABEL = "JSON"; @@ -62,8 +62,8 @@ public class JSONEventProtocolParameters extends EventProtocolTextCharDelimitedP * Constructor to create a JSON event protocol parameter instance and register the instance with * the parameter service. */ - public JSONEventProtocolParameters() { - this(JSONEventProtocolParameters.class.getCanonicalName(), JSON_EVENT_PROTOCOL_LABEL); + public JsonEventProtocolParameters() { + this(JsonEventProtocolParameters.class.getCanonicalName(), JSON_EVENT_PROTOCOL_LABEL); } /** @@ -73,7 +73,7 @@ public class JSONEventProtocolParameters extends EventProtocolTextCharDelimitedP * @param parameterClassName the class name of a sub class of this class * @param eventProtocolLabel the name of the event protocol for this plugin */ - public JSONEventProtocolParameters(final String parameterClassName, final String eventProtocolLabel) { + public JsonEventProtocolParameters(final String parameterClassName, final String eventProtocolLabel) { super(parameterClassName); // Set the event protocol properties for the JSON event protocol @@ -84,7 +84,7 @@ public class JSONEventProtocolParameters extends EventProtocolTextCharDelimitedP this.setEndChar(JSON_TEXT_BLOCK_END_DELIMITER); // Set the event protocol plugin class - this.setEventProtocolPluginClass(Apex2JSONEventConverter.class.getCanonicalName()); + this.setEventProtocolPluginClass(Apex2JsonEventConverter.class.getCanonicalName()); } /* (non-Javadoc) diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java index d6d278ebf..bdbd82dc2 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java @@ -42,6 +42,8 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * @author Liam Fallon (liam.fallon@ericsson.com) */ public class ApexCommandLineArguments { + // Recurring string constants + private static final String FILE_PREAMBLE = " file \""; private static final int HELP_LINE_LENGTH = 120; // Apache Commons CLI options @@ -181,12 +183,11 @@ public class ApexCommandLineArguments { * @return the help string */ public String help(final String mainClassName) { - final HelpFormatter helpFormatter = new HelpFormatter(); final StringWriter stringWriter = new StringWriter(); - final PrintWriter stringPW = new PrintWriter(stringWriter); + final PrintWriter stringPrintWriter = new PrintWriter(stringWriter); - helpFormatter.printHelp(stringPW, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0, 0, - ""); + new HelpFormatter().printHelp(stringPrintWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", + options, 0, 0, ""); return stringWriter.toString(); } @@ -268,20 +269,20 @@ public class ApexCommandLineArguments { } // The file name can refer to a resource on the local file system or on the class path - final URL fileURL = ResourceUtils.getUrl4Resource(fileName); - if (fileURL == null) { - throw new ApexException(fileTag + " file \"" + fileName + "\" does not exist"); + final URL fileUrl = ResourceUtils.getUrl4Resource(fileName); + if (fileUrl == null) { + throw new ApexException(fileTag + FILE_PREAMBLE + fileName + "\" does not exist"); } - final File theFile = new File(fileURL.getPath()); + final File theFile = new File(fileUrl.getPath()); if (!theFile.exists()) { - throw new ApexException(fileTag + " file \"" + fileName + "\" does not exist"); + throw new ApexException(fileTag + FILE_PREAMBLE + fileName + "\" does not exist"); } if (!theFile.isFile()) { - throw new ApexException(fileTag + " file \"" + fileName + "\" is not a normal file"); + throw new ApexException(fileTag + FILE_PREAMBLE + fileName + "\" is not a normal file"); } if (!theFile.canRead()) { - throw new ApexException(fileTag + " file \"" + fileName + "\" is ureadable"); + throw new ApexException(fileTag + FILE_PREAMBLE + fileName + "\" is ureadable"); } } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java index 9904847aa..532fdb9c7 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java @@ -187,19 +187,19 @@ public class ApexEventMarshaller implements ApexEventListener, Runnable { // Process the next Apex event from the queue final Object event = converter.fromApexEvent(apexEvent); - producer.sendEvent(apexEvent.getExecutionID(), apexEvent.getName(), event); + producer.sendEvent(apexEvent.getExecutionId(), apexEvent.getName(), event); if (LOGGER.isTraceEnabled()) { - LOGGER.trace("event sent : " + apexEvent.toString()); + String message = "event sent : " + apexEvent.toString(); + LOGGER.trace(message); } } catch (final InterruptedException e) { // restore the interrupt status Thread.currentThread().interrupt(); LOGGER.debug("Thread interrupted, Reason {}", e.getMessage()); - break; + stopOrderedFlag = true; } catch (final Exception e) { LOGGER.warn("Error while forwarding events for " + marshallerThread.getName(), e); - continue; } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java index 7b4188ea1..1d1b64e37 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java @@ -44,8 +44,8 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * This event unmarshaler handles events coming into Apex, handles threading, event queuing, - * transformation and receiving using the configured receiving technology. + * This event unmarshaler handles events coming into Apex, handles threading, event queuing, transformation and + * receiving using the configured receiving technology. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -88,7 +88,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { * @param consumerParameters the consumer parameters for this specific unmarshaler */ public ApexEventUnmarshaller(final String name, final EngineServiceParameters engineServiceParameters, - final EventHandlerParameters consumerParameters) { + final EventHandlerParameters consumerParameters) { this.name = name; this.engineServiceParameters = engineServiceParameters; this.consumerParameters = consumerParameters; @@ -97,8 +97,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { /** * Configure the consumer and initialize the thread for event sending. * - * @param incomingEngineServiceHandler the Apex engine service handler for passing events to - * Apex + * @param incomingEngineServiceHandler the Apex engine service handler for passing events to Apex * @throws ApexEventException on errors initializing event handling */ public void init(final ApexEngineServiceHandler incomingEngineServiceHandler) throws ApexEventException { @@ -119,8 +118,8 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { consumer.start(); // Configure and start the event reception thread - final String threadName = - engineServiceParameters.getEngineKey().getName() + ":" + this.getClass().getName() + ":" + name; + final String threadName = engineServiceParameters.getEngineKey().getName() + ":" + this.getClass().getName() + + ":" + name; unmarshallerThread = new ApplicationThreadFactory(threadName).newThread(this); unmarshallerThread.setDaemon(true); unmarshallerThread.start(); @@ -165,7 +164,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { // To connect a synchronous unmarshaler and marshaler, we create a synchronous event // cache on the consumer/producer pair new SynchronousEventCache(peeredMode, consumer, peeredMarshaller.getProducer(), - consumerParameters.getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS)); + consumerParameters.getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS)); return; case REQUESTOR: @@ -180,8 +179,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { /* * (non-Javadoc) * - * @see - * org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(java.lang.Object) + * @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(java.lang.Object) */ @Override public void receiveEvent(final Object event) throws ApexEventException { @@ -191,8 +189,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { /* * (non-Javadoc) * - * @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(long, - * java.lang.Object) + * @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(long, java.lang.Object) */ @Override public void receiveEvent(final long executionId, final Object event) throws ApexEventException { @@ -204,15 +201,15 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { * * @param executionId the execution id the incoming execution ID * @param event the event in its native format - * @param generateExecutionId if true, let Apex generate the execution ID, if false, use the - * incoming execution ID + * @param generateExecutionId if true, let Apex generate the execution ID, if false, use the incoming execution ID * @throws ApexEventException on unmarshaling errors on events */ private void receiveEvent(final long executionId, final Object event, final boolean generateExecutionId) - throws ApexEventException { + throws ApexEventException { // Push the event onto the queue if (LOGGER.isTraceEnabled()) { - LOGGER.trace("onMessage(): event received: {}", event.toString()); + String eventString = "onMessage(): event received: " + event.toString(); + LOGGER.trace(eventString); } // Convert the incoming events to Apex events @@ -222,10 +219,10 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { // Check if we are filtering events on this unmarshaler, if so check the event name // against the filter if (consumerParameters.isSetEventNameFilter() - && !apexEvent.getName().matches(consumerParameters.getEventNameFilter())) { + && !apexEvent.getName().matches(consumerParameters.getEventNameFilter())) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("onMessage(): event {} not processed, filtered out by filter", apexEvent, - consumerParameters.getEventNameFilter()); + consumerParameters.getEventNameFilter()); } // Ignore this event @@ -233,7 +230,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { } if (!generateExecutionId) { - apexEvent.setExecutionID(executionId); + apexEvent.setExecutionId(executionId); } // Enqueue the event @@ -241,22 +238,22 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { // Cache synchronized events that are sent if (consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) { - final SynchronousEventCache synchronousEventCache = - (SynchronousEventCache) consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS); - synchronousEventCache.cacheSynchronizedEventToApex(apexEvent.getExecutionID(), apexEvent); + final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) consumer + .getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS); + synchronousEventCache.cacheSynchronizedEventToApex(apexEvent.getExecutionId(), apexEvent); } } } catch (final ApexException e) { final String errorMessage = "Error while converting event into an ApexEvent for " + name + ": " - + e.getMessage() + ", Event=" + event; + + e.getMessage() + ", Event=" + event; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } } /** - * Run a thread that runs forever (well until system termination anyway) and listens for - * incoming events on the queue. + * Run a thread that runs forever (well until system termination anyway) and listens for incoming events on the + * queue. */ @Override public void run() { @@ -270,7 +267,8 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { } if (LOGGER.isTraceEnabled()) { - LOGGER.trace("event received {}", apexEvent.toString()); + String message = apexEvent.toString(); + LOGGER.trace("event received {}", message); } // Pass the event to the activator for forwarding to Apex @@ -279,10 +277,9 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { // restore the interrupt status Thread.currentThread().interrupt(); LOGGER.warn("BatchProcessor thread interrupted, Reason {}", e.getMessage()); - break; + stopOrderedFlag = true; } catch (final Exception e) { LOGGER.warn("Error while forwarding events for " + unmarshallerThread.getName(), e); - continue; } } @@ -309,10 +306,9 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { stopOrderedFlag = true; // Order a stop on the synchronous cache if one exists - if (consumerParameters != null && consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) { - if (consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS) != null) { - ((SynchronousEventCache) consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)).stop(); - } + if (consumerParameters != null && consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS) + && consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS) != null) { + ((SynchronousEventCache) consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)).stop(); } // Wait for thread shutdown diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java index 436225fc4..2b15b145f 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java @@ -50,7 +50,6 @@ public class ApexMain { * @param args the commaind line arguments */ public ApexMain(final String[] args) { - System.out.println("Starting Apex service with parameters " + Arrays.toString(args) + " . . ."); LOGGER.entry("Starting Apex service with parameters " + Arrays.toString(args) + " . . ."); // Check the arguments @@ -60,16 +59,13 @@ public class ApexMain { final String argumentMessage = arguments.parse(args); if (argumentMessage != null) { LOGGER.info(argumentMessage); - System.out.println(argumentMessage); return; } // Validate that the arguments are sane arguments.validate(); } catch (final ApexException e) { - System.err.println("start of Apex service failed: " + e.getMessage()); LOGGER.error("start of Apex service failed", e); - System.err.println(arguments.help(ApexMain.class.getCanonicalName())); return; } @@ -77,7 +73,6 @@ public class ApexMain { try { parameters = new ApexParameterHandler().getParameters(arguments); } catch (final Exception e) { - System.err.println("start of Apex service failed\n" + e.getMessage()); LOGGER.error("start of Apex service failed", e); return; } @@ -103,8 +98,6 @@ public class ApexMain { try { activator.initialize(); } catch (final ApexActivatorException e) { - System.err.println("start of Apex service failed, used parameters are " + Arrays.toString(args)); - e.printStackTrace(System.err); LOGGER.error("start of Apex service failed, used parameters are " + Arrays.toString(args), e); return; } @@ -112,7 +105,6 @@ public class ApexMain { // Add a shutdown hook to shut everything down in an orderly manner Runtime.getRuntime().addShutdownHook(new ApexMainShutdownHookClass()); LOGGER.exit("Started Apex"); - System.out.println("Started Apex service"); } /** diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java index 1af0c9d1c..ef17a8eab 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java @@ -101,7 +101,7 @@ public interface EngineService { void updateModel(AxArtifactKey engineServiceKey, AxPolicyModel apexModel, boolean forceFlag) throws ApexException; /** - * This method returns the state of an engine service or engine. + * Return the state of an engine service or engine. * * @return The engine service or engine state */ diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java index 04fb8e389..c99987542 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java @@ -63,6 +63,10 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven private static final XLogger LOGGER = XLoggerFactory.getXLogger(EngineServiceImpl.class); private static final boolean DEBUG_ENABLED = LOGGER.isDebugEnabled(); + // Recurring string constants + private static final String ENGINE_KEY_PREAMBLE = "engine with key "; + private static final String NOT_FOUND_SUFFIX = " not found in engine service"; + // Constants for timing private static final long MAX_START_WAIT_TIME = 5000; // 5 seconds private static final long MAX_STOP_WAIT_TIME = 5000; // 5 seconds @@ -96,7 +100,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven * @throws ApexException on worker instantiation errors */ private EngineServiceImpl(final AxArtifactKey engineServiceKey, final int incomingThreadCount, - final long periodicEventPeriod) throws ApexException { + final long periodicEventPeriod) { LOGGER.entry(engineServiceKey, incomingThreadCount); this.engineServiceKey = engineServiceKey; @@ -121,26 +125,6 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven } /** - * Create an Apex Engine Service instance. This method is deprecated and will be removed in the next version. - * - * @param engineServiceKey the engine service key - * @param threadCount the thread count, the number of engine workers to start - * @return the Engine Service instance - * @throws ApexException on worker instantiation errors - * @deprecated Do not use this version. Use {@link #create(EngineServiceParameters)} - */ - @Deprecated - public static EngineServiceImpl create(final AxArtifactKey engineServiceKey, final int threadCount) - throws ApexException { - // Check if the Apex model specified is sane - if (engineServiceKey == null) { - LOGGER.warn("engine service key is null"); - throw new ApexException("engine service key is null"); - } - return new EngineServiceImpl(engineServiceKey, threadCount, 0); - } - - /** * Create an Apex Engine Service instance. This method does not load the policy so * {@link #updateModel(AxArtifactKey, AxPolicyModel, boolean)} or * {@link #updateModel(AxArtifactKey, AxPolicyModel, boolean)} must be used to load a model. This method does not @@ -266,10 +250,10 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven final boolean forceFlag) throws ApexException { // Check if the Apex model specified is sane if (apexModelString == null || apexModelString.trim().length() == 0) { - LOGGER.warn("model for updating on engine service with key " + incomingEngineServiceKey.getId() - + " is empty"); - throw new ApexException("model for updating on engine service with key " + incomingEngineServiceKey.getId() - + " is empty"); + String emptyModelMessage = "model for updating engine service with key " + + incomingEngineServiceKey.getId() + " is empty"; + LOGGER.warn(emptyModelMessage); + throw new ApexException(emptyModelMessage); } // Read the Apex model into memory using the Apex Model Reader @@ -278,15 +262,15 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class); apexPolicyModel = modelReader.read(new ByteArrayInputStream(apexModelString.getBytes())); } catch (final ApexModelException e) { - LOGGER.error("failed to unmarshal the apex model on engine service " + incomingEngineServiceKey.getId(), e); - throw new ApexException( - "failed to unmarshal the apex model on engine service " + incomingEngineServiceKey.getId(), - e); + String message = "failed to unmarshal the apex model on engine service " + incomingEngineServiceKey.getId(); + LOGGER.error(message, e); + throw new ApexException(message, e); } if (apexPolicyModel == null) { - LOGGER.error("apex model null on engine service " + incomingEngineServiceKey.getId()); - throw new ApexException("apex model null on engine service " + incomingEngineServiceKey.getId()); + String message = "apex model null on engine service " + incomingEngineServiceKey.getId(); + LOGGER.error(message); + throw new ApexException(message); } // Update the model @@ -327,43 +311,12 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven // The current policy model may or may not be defined final AxPolicyModel currentModel = ModelService.getModel(AxPolicyModel.class); if (!currentModel.getKey().isCompatible(apexModel.getKey())) { - if (forceFlag) { - LOGGER.warn("apex model update forced, supplied model with key \"" + apexModel.getKey().getId() - + "\" is not a compatible model update from the existing engine model with key \"" - + currentModel.getKey().getId() + "\""); - } else { - throw new ContextException("apex model update failed, supplied model with key \"" - + apexModel.getKey().getId() - + "\" is not a compatible model update from the existing engine model with key \"" - + currentModel.getKey().getId() + "\""); - } + handleIncompatibility(apexModel, forceFlag, currentModel); } } if (!isStopped()) { - // Stop all engines on this engine service - stop(); - final long stoptime = System.currentTimeMillis(); - while (!isStopped() && System.currentTimeMillis() - stoptime < MAX_STOP_WAIT_TIME) { - ThreadUtilities.sleep(ENGINE_SERVICE_STOP_START_WAIT_INTERVAL); - } - // Check if all engines are stopped - final StringBuilder notStoppedEngineIdBuilder = new StringBuilder(); - for (final Entry<AxArtifactKey, EngineService> engineWorkerEntry : engineWorkerMap.entrySet()) { - if (engineWorkerEntry.getValue().getState() != AxEngineState.STOPPED) { - notStoppedEngineIdBuilder.append(engineWorkerEntry.getKey().getId()); - notStoppedEngineIdBuilder.append('('); - notStoppedEngineIdBuilder.append(engineWorkerEntry.getValue().getState()); - notStoppedEngineIdBuilder.append(") "); - } - } - if (notStoppedEngineIdBuilder.length() > 0) { - final String errorString = "cannot update model on engine service with key " - + incomingEngineServiceKey.getId() + ", engines not stopped after " + MAX_STOP_WAIT_TIME - + "ms are: " + notStoppedEngineIdBuilder.toString().trim(); - LOGGER.warn(errorString); - throw new ApexException(errorString); - } + stopEngines(incomingEngineServiceKey); } // Update the engines @@ -400,6 +353,58 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven LOGGER.exit(); } + /** + * Stop engines for a model update. + * @param incomingEngineServiceKey the engine service key for the engines that are to be stopped + * @throws ApexException on errors stopping engines + */ + private void stopEngines(final AxArtifactKey incomingEngineServiceKey) throws ApexException { + // Stop all engines on this engine service + stop(); + final long stoptime = System.currentTimeMillis(); + while (!isStopped() && System.currentTimeMillis() - stoptime < MAX_STOP_WAIT_TIME) { + ThreadUtilities.sleep(ENGINE_SERVICE_STOP_START_WAIT_INTERVAL); + } + // Check if all engines are stopped + final StringBuilder notStoppedEngineIdBuilder = new StringBuilder(); + for (final Entry<AxArtifactKey, EngineService> engineWorkerEntry : engineWorkerMap.entrySet()) { + if (engineWorkerEntry.getValue().getState() != AxEngineState.STOPPED) { + notStoppedEngineIdBuilder.append(engineWorkerEntry.getKey().getId()); + notStoppedEngineIdBuilder.append('('); + notStoppedEngineIdBuilder.append(engineWorkerEntry.getValue().getState()); + notStoppedEngineIdBuilder.append(") "); + } + } + if (notStoppedEngineIdBuilder.length() > 0) { + final String errorString = "cannot update model on engine service with key " + + incomingEngineServiceKey.getId() + ", engines not stopped after " + MAX_STOP_WAIT_TIME + + "ms are: " + notStoppedEngineIdBuilder.toString().trim(); + LOGGER.warn(errorString); + throw new ApexException(errorString); + } + } + + /** + * Issue compatibility warning or error message. + * @param apexModel The model name + * @param forceFlag true if we are forcing the update + * @param currentModel the existing model that is loaded + * @throws ContextException on compatibility errors + */ + private void handleIncompatibility(final AxPolicyModel apexModel, final boolean forceFlag, + final AxPolicyModel currentModel) throws ContextException { + if (forceFlag) { + LOGGER.warn("apex model update forced, supplied model with key \"" + apexModel.getKey().getId() + + "\" is not a compatible model update from the existing engine model with key \"" + + currentModel.getKey().getId() + "\""); + } else { + throw new ContextException("apex model update failed, supplied model with key \"" + + apexModel.getKey().getId() + + "\" is not a compatible model update from the existing engine model with key \"" + + currentModel.getKey().getId() + "\""); + } + } + /* * (non-Javadoc) * @@ -446,8 +451,9 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven // Check if we have this key on our map if (!engineWorkerMap.containsKey(engineKey)) { - LOGGER.warn("engine with key " + engineKey.getId() + " not found in engine service"); - throw new ApexException("engine with key " + engineKey.getId() + " not found in engine service"); + String message = ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX; + LOGGER.warn(message); + throw new ApexException(message); } // Start the engine @@ -487,8 +493,8 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven // Check if we have this key on our map if (!engineWorkerMap.containsKey(engineKey)) { - LOGGER.warn("engine with key " + engineKey.getId() + " not found in engine service"); - throw new ApexException("engine with key " + engineKey.getId() + " not found in engine service"); + LOGGER.warn(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); + throw new ApexException(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); } // Stop the engine @@ -528,8 +534,8 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven // Check if we have this key on our map if (!engineWorkerMap.containsKey(engineKey)) { - LOGGER.warn("engine with key " + engineKey.getId() + " not found in engine service"); - throw new ApexException("engine with key " + engineKey.getId() + " not found in engine service"); + LOGGER.warn(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); + throw new ApexException(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); } // Clear the engine @@ -566,7 +572,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven public boolean isStarted(final AxArtifactKey engineKey) { // Check if we have this key on our map if (!engineWorkerMap.containsKey(engineKey)) { - LOGGER.warn("engine with key " + engineKey.getId() + " not found in engine service"); + LOGGER.warn(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); } return engineWorkerMap.get(engineKey).isStarted(); } @@ -597,7 +603,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven public boolean isStopped(final AxArtifactKey engineKey) { // Check if we have this key on our map if (!engineWorkerMap.containsKey(engineKey)) { - LOGGER.warn("engine with key " + engineKey.getId() + " not found in engine service"); + LOGGER.warn(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); } return engineWorkerMap.get(engineKey).isStopped(); } @@ -611,10 +617,10 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven public void startPeriodicEvents(final long period) throws ApexException { // Check if periodic events are already started if (periodicEventGenerator != null) { - LOGGER.warn("Peiodic event geneation already running on engine " + engineServiceKey.getId() + ", " - + periodicEventGenerator.toString()); - throw new ApexException("Peiodic event geneation already running on engine " + engineServiceKey.getId() - + ", " + periodicEventGenerator.toString()); + String message = "Peiodic event geneation already running on engine " + engineServiceKey.getId() + ", " + + periodicEventGenerator.toString(); + LOGGER.warn(message); + throw new ApexException(message); } // Set up periodic event execution, its a Java Timer/TimerTask @@ -653,8 +659,8 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven public String getStatus(final AxArtifactKey engineKey) throws ApexException { // Check if we have this key on our map if (!engineWorkerMap.containsKey(engineKey)) { - LOGGER.warn("engine with key " + engineKey.getId() + " not found in engine service"); - throw new ApexException("engine with key " + engineKey.getId() + " not found in engine service"); + LOGGER.warn(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); + throw new ApexException(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); } // Return the information for this worker @@ -671,8 +677,8 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven public String getRuntimeInfo(final AxArtifactKey engineKey) throws ApexException { // Check if we have this key on our map if (!engineWorkerMap.containsKey(engineKey)) { - LOGGER.warn("engine with key " + engineKey.getId() + " not found in engine service"); - throw new ApexException("engine with key " + engineKey.getId() + " not found in engine service"); + LOGGER.warn(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); + throw new ApexException(ENGINE_KEY_PREAMBLE + engineKey.getId() + NOT_FOUND_SUFFIX); } // Return the information for this worker diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java index b9a405b44..dc5e91979 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java @@ -75,6 +75,13 @@ final class EngineWorker implements EngineService { // Logger for this class private static final XLogger LOGGER = XLoggerFactory.getXLogger(EngineService.class); + // Recurring string constants + private static final String IS_NULL_SUFFIX = " is null"; + private static final String ENGINE_FOR_KEY_PREFIX = "apex engine for engine key "; + private static final String ENGINE_SUFFIX = " of this engine"; + private static final String BAD_KEY_MATCH_TAG = " does not match the key"; + private static final String ENGINE_KEY_PREFIX = "engine key "; + // The ID of this engine private final AxArtifactKey engineWorkerKey; @@ -102,7 +109,7 @@ final class EngineWorker implements EngineService { * @throws ApexException thrown on errors on worker instantiation */ EngineWorker(final AxArtifactKey engineWorkerKey, final BlockingQueue<ApexEvent> queue, - final ApplicationThreadFactory threadFactory) throws ApexException { + final ApplicationThreadFactory threadFactory) { LOGGER.entry(engineWorkerKey); this.engineWorkerKey = engineWorkerKey; @@ -252,10 +259,10 @@ final class EngineWorker implements EngineService { // Check if the key on the update request is correct if (!engineWorkerKey.equals(engineKey)) { - LOGGER.warn("engine key " + engineKey.getId() + " does not match the key" + engineWorkerKey.getId() - + " of this engine"); - throw new ApexException("engine key " + engineKey.getId() + " does not match the key" - + engineWorkerKey.getId() + " of this engine"); + String message = ENGINE_KEY_PREFIX + engineKey.getId() + BAD_KEY_MATCH_TAG + engineWorkerKey.getId() + + ENGINE_SUFFIX; + LOGGER.warn(message); + throw new ApexException(message); } // Sanity checks on the Apex model @@ -323,23 +330,24 @@ final class EngineWorker implements EngineService { // Check if the key on the start request is correct if (!engineWorkerKey.equals(engineKey)) { - LOGGER.warn("engine key " + engineKey.getId() + " does not match the key" + engineWorkerKey.getId() - + " of this engine"); - throw new ApexException("engine key " + engineKey.getId() + " does not match the key" - + engineWorkerKey.getId() + " of this engine"); + LOGGER.warn(ENGINE_KEY_PREFIX + engineKey.getId() + BAD_KEY_MATCH_TAG + engineWorkerKey.getId() + + ENGINE_SUFFIX); + throw new ApexException(ENGINE_KEY_PREFIX + engineKey.getId() + BAD_KEY_MATCH_TAG + + engineWorkerKey.getId() + ENGINE_SUFFIX); } if (engine == null) { - LOGGER.error("apex engine for engine key" + engineWorkerKey.getId() + " null"); - throw new ApexException("apex engine for engine key" + engineWorkerKey.getId() + " null"); + String message = ENGINE_FOR_KEY_PREFIX + engineWorkerKey.getId() + " is null"; + LOGGER.error(message); + throw new ApexException(message); } // Starts the event processing thread that handles incoming events if (processorThread != null && processorThread.isAlive()) { - LOGGER.error("apex engine for engine key" + engineWorkerKey.getId() + " is already running with state " - + getState()); - throw new ApexException("apex engine for engine key" + engineWorkerKey.getId() - + " is already running with state " + getState()); + String message = ENGINE_FOR_KEY_PREFIX + engineWorkerKey.getId() + " is already running with state " + + getState(); + LOGGER.error(message); + throw new ApexException(message); } // Start the engine @@ -373,22 +381,23 @@ final class EngineWorker implements EngineService { public void stop(final AxArtifactKey engineKey) throws ApexException { // Check if the key on the start request is correct if (!engineWorkerKey.equals(engineKey)) { - LOGGER.warn("engine key " + engineKey.getId() + " does not match the key" + engineWorkerKey.getId() - + " of this engine"); - throw new ApexException("engine key " + engineKey.getId() + " does not match the key" - + engineWorkerKey.getId() + " of this engine"); + LOGGER.warn(ENGINE_KEY_PREFIX + engineKey.getId() + BAD_KEY_MATCH_TAG + engineWorkerKey.getId() + + ENGINE_SUFFIX); + throw new ApexException(ENGINE_KEY_PREFIX + engineKey.getId() + BAD_KEY_MATCH_TAG + + engineWorkerKey.getId() + ENGINE_SUFFIX); } if (engine == null) { - LOGGER.error("apex engine for engine key" + engineWorkerKey.getId() + " null"); - throw new ApexException("apex engine for engine key" + engineWorkerKey.getId() + " null"); + String message = ENGINE_FOR_KEY_PREFIX + engineWorkerKey.getId() + " is null"; + LOGGER.error(message); + throw new ApexException(message); } // Interrupt the worker to stop its thread if (processorThread == null || !processorThread.isAlive()) { processorThread = null; - LOGGER.warn("apex engine for engine key" + engineWorkerKey.getId() + " is already stopped with state " + LOGGER.warn(ENGINE_FOR_KEY_PREFIX + engineWorkerKey.getId() + " is already stopped with state " + getState()); return; } @@ -424,20 +433,20 @@ final class EngineWorker implements EngineService { public void clear(final AxArtifactKey engineKey) throws ApexException { // Check if the key on the start request is correct if (!engineWorkerKey.equals(engineKey)) { - LOGGER.warn("engine key " + engineKey.getId() + " does not match the key" + engineWorkerKey.getId() - + " of this engine"); - throw new ApexException("engine key " + engineKey.getId() + " does not match the key" - + engineWorkerKey.getId() + " of this engine"); + LOGGER.warn(ENGINE_KEY_PREFIX + engineKey.getId() + BAD_KEY_MATCH_TAG + engineWorkerKey.getId() + + ENGINE_SUFFIX); + throw new ApexException(ENGINE_KEY_PREFIX + engineKey.getId() + BAD_KEY_MATCH_TAG + + engineWorkerKey.getId() + ENGINE_SUFFIX); } if (engine == null) { - LOGGER.error("apex engine for engine key" + engineWorkerKey.getId() + " null"); - throw new ApexException("apex engine for engine key" + engineWorkerKey.getId() + " null"); + LOGGER.error(ENGINE_FOR_KEY_PREFIX + engineWorkerKey.getId() + IS_NULL_SUFFIX); + throw new ApexException(ENGINE_FOR_KEY_PREFIX + engineWorkerKey.getId() + IS_NULL_SUFFIX); } // Interrupt the worker to stop its thread if (processorThread != null && !processorThread.isAlive()) { - LOGGER.warn("apex engine for engine key" + engineWorkerKey.getId() + " is not stopped with state " + LOGGER.warn(ENGINE_FOR_KEY_PREFIX + engineWorkerKey.getId() + " is not stopped with state " + getState()); return; } @@ -653,7 +662,7 @@ final class EngineWorker implements EngineService { final JsonElement jsonElement = jsonParser.parse(runtimeJsonStringBuilder.toString()); final String tidiedRuntimeString = gson.toJson(jsonElement); - LOGGER.debug("runtime information=" + tidiedRuntimeString); + LOGGER.debug("runtime information={}", tidiedRuntimeString); return tidiedRuntimeString; } @@ -691,7 +700,8 @@ final class EngineWorker implements EngineService { // Take events from the event processing queue of the worker and pass them to the engine // for processing - while (!processorThread.isInterrupted()) { + boolean stopFlag = false; + while (!processorThread.isInterrupted() && ! stopFlag) { ApexEvent event = null; try { event = eventProcessingQueue.take(); @@ -714,7 +724,7 @@ final class EngineWorker implements EngineService { LOGGER.warn("Engine {} failed to process event {}", engineWorkerKey, event.toString(), e); } catch (final Exception e) { LOGGER.warn("Engine {} terminated processing event {}", engineWorkerKey, event.toString(), e); - break; + stopFlag = true; } } LOGGER.debug("Engine {} completed processing", engineWorkerKey); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java index 2e8e66ae8..4312793e4 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java @@ -20,18 +20,18 @@ package org.onap.policy.apex.service.parameters; -import java.io.FileReader; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import java.io.FileReader; + import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments; import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; -import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParametersJSONAdapter; -import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParametersJSONAdapter; +import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParametersJsonAdapter; +import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParametersJsonAdapter; import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters; -import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParametersJSONAdapter; +import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParametersJsonAdapter; import org.onap.policy.common.parameters.GroupValidationResult; import org.onap.policy.common.parameters.ParameterException; import org.onap.policy.common.parameters.ParameterService; @@ -56,7 +56,7 @@ public class ApexParameterHandler { public ApexParameters getParameters(final ApexCommandLineArguments arguments) throws ParameterException { // Clear all existing parameters ParameterService.clear(); - + ApexParameters parameters = null; // Read the parameters @@ -65,11 +65,11 @@ public class ApexParameterHandler { // @formatter:off final Gson gson = new GsonBuilder() .registerTypeAdapter(EngineParameters .class, - new EngineServiceParametersJSONAdapter()) + new EngineServiceParametersJsonAdapter()) .registerTypeAdapter(CarrierTechnologyParameters.class, - new CarrierTechnologyParametersJSONAdapter()) + new CarrierTechnologyParametersJsonAdapter()) .registerTypeAdapter(EventProtocolParameters .class, - new EventProtocolParametersJSONAdapter()) + new EventProtocolParametersJsonAdapter()) .create(); // @formatter:on parameters = gson.fromJson(new FileReader(arguments.getFullConfigurationFilePath()), ApexParameters.class); @@ -114,12 +114,13 @@ public class ApexParameterHandler { // Register the parameters with the parameter service registerParameters(parameters); - + return parameters; } /** - * Register all the incoming parameters with the parameter service + * Register all the incoming parameters with the parameter service. + * * @param parameters The parameters to register */ private void registerParameters(ApexParameters parameters) { @@ -127,9 +128,13 @@ public class ApexParameterHandler { ParameterService.register(parameters.getEngineServiceParameters()); ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters()); ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters()); - ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getSchemaParameters()); - ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getDistributorParameters()); - ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getLockManagerParameters()); - ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters().getPersistorParameters()); + ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getSchemaParameters()); + ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getDistributorParameters()); + ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getLockManagerParameters()); + ParameterService.register(parameters.getEngineServiceParameters().getEngineParameters().getContextParameters() + .getPersistorParameters()); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java index 87b86a897..907baad40 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java @@ -37,16 +37,11 @@ import org.onap.policy.common.parameters.ValidationStatus; /** * The main container parameter class for an Apex service. * - * <p> - * The following parameters are defined: - * <ol> - * <li>engineServiceParameters: The parameters for the Apex engine service itself, such as the number of engine threads - * to run and the deployment port number to use. - * <li>eventOutputParameters: A map of parameters for event outputs that Apex will use to emit events. Apex emits events - * on all outputs + * <p>The following parameters are defined: <ol> <li>engineServiceParameters: The parameters for the Apex engine service + * itself, such as the number of engine threads to run and the deployment port number to use. <li>eventOutputParameters: + * A map of parameters for event outputs that Apex will use to emit events. Apex emits events on all outputs * <li>eventInputParameters: A map or parameters for event inputs from which Apex will consume events. Apex reads events - * from all its event inputs. - * </ol> + * from all its event inputs. </ol> * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -59,13 +54,13 @@ public class ApexParameters implements ParameterGroup { private static final String EVENT_INPUT_PARAMETERS_STRING = "eventInputParameters"; private static final String EVENT_OUTPUT_PARAMETERS_STRING = "eventOutputParameters"; private static final String FOR_PEERED_MODE_STRING = " for peered mode "; - + /** * Constructor to create an apex parameters instance and register the instance with the parameter service. */ public ApexParameters() { super(); - + // Set the name for the parameters this.name = ApexParameterConstants.MAIN_GROUP_NAME; } @@ -235,9 +230,8 @@ public class ApexParameters implements ParameterGroup { } } else { if (peer != null) { - result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, - messagePreamble + " peer is illegal on " + eventHandlerType + " \"" - + parameterEntry.getKey() + "\" "); + result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, messagePreamble + + " peer is illegal on " + eventHandlerType + " \"" + parameterEntry.getKey() + "\" "); } if (parameterEntry.getValue().getPeerTimeout(peeredMode) != 0) { result.setResult(eventHandlerType, parameterEntry.getKey(), ValidationStatus.INVALID, @@ -315,10 +309,10 @@ public class ApexParameters implements ParameterGroup { final String rightSidePeer = rightModeParameters.getPeer(peeredMode); if (!rightSidePeer.equals(leftModeParameterEntry.getKey())) { result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID, - PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode - + ", value \"" + rightSidePeer + "\" on peer \"" + leftSidePeer - + "\" does not equal event handler \"" + leftModeParameterEntry.getKey() - + "\""); + PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + + peeredMode + ", value \"" + rightSidePeer + "\" on peer \"" + + leftSidePeer + "\" does not equal event handler \"" + + leftModeParameterEntry.getKey() + "\""); } else { // Check for duplicates if (!leftCheckDuplicateSet.add(leftSidePeer)) { @@ -339,12 +333,12 @@ public class ApexParameters implements ParameterGroup { if (!crossCheckPeeredTimeoutValues(leftModeParameters, rightModeParameters, peeredMode)) { result.setResult(handlerMapVariableName, leftModeParameterEntry.getKey(), ValidationStatus.INVALID, - PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + peeredMode - + " timeout " + leftModeParameters.getPeerTimeout(peeredMode) - + " on event handler \"" + leftModeParameters.getName() - + "\" does not equal timeout " - + rightModeParameters.getPeerTimeout(peeredMode) + " on event handler \"" - + rightModeParameters.getName() + "\""); + PEER_STRING + '"' + leftModeParameters.getPeer(peeredMode) + FOR_PEERED_MODE_STRING + + peeredMode + " timeout " + + leftModeParameters.getPeerTimeout(peeredMode) + " on event handler \"" + + leftModeParameters.getName() + "\" does not equal timeout " + + rightModeParameters.getPeerTimeout(peeredMode) + + " on event handler \"" + rightModeParameters.getName() + "\""); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java index 593c6d86f..bab76b59b 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java @@ -29,14 +29,10 @@ import org.onap.policy.common.parameters.ValidationStatus; * The default carrier technology parameter class that may be specialized by carrier technology plugins that require * plugin specific parameters. * - * <p>The following parameters are defined: - * <ol> - * <li>label: The label of the carrier technology. + * <p>The following parameters are defined: <ol> <li>label: The label of the carrier technology. * <li>eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce and emit output - * events for this carrier technology - * <li>eventConsumerPluginClass: The name of the plugin class that will be used by Apex to receive and process input - * events from this carrier technology carrier technology - * </ol> + * events for this carrier technology <li>eventConsumerPluginClass: The name of the plugin class that will be used by + * Apex to receive and process input events from this carrier technology carrier technology </ol> * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -160,7 +156,7 @@ public abstract class CarrierTechnologyParameters implements ParameterGroup { return result; } - + @Override public String getName() { return this.getLabel(); @@ -168,7 +164,8 @@ public abstract class CarrierTechnologyParameters implements ParameterGroup { @Override public void setName(final String name) { - throw new ParameterRuntimeException("the name/label of this carrier technology is always \"" + getLabel() + "\""); + throw new ParameterRuntimeException( + "the name/label of this carrier technology is always \"" + getLabel() + "\""); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java index b4e342f17..5e320b1bb 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java @@ -20,10 +20,6 @@ package org.onap.policy.apex.service.parameters.carriertechnology; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -32,8 +28,12 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; + import org.onap.policy.apex.service.engine.event.impl.eventrequestor.EventRequestorCarrierTechnologyParameters; -import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters; +import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters; import org.onap.policy.common.parameters.ParameterRuntimeException; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -43,9 +43,15 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class CarrierTechnologyParametersJSONAdapter +public class CarrierTechnologyParametersJsonAdapter implements JsonSerializer<CarrierTechnologyParameters>, JsonDeserializer<CarrierTechnologyParameters> { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(CarrierTechnologyParametersJSONAdapter.class); + + private static final XLogger LOGGER = XLoggerFactory.getXLogger(CarrierTechnologyParametersJsonAdapter.class); + + // Recurring string constants + private static final String VALUE_TAG = "\" value \""; + private static final String CARRIER_TECHNOLOGY_PREAMBLE = "carrier technology \""; + private static final String PARAMETER_CLASS_NAME = "parameterClassName"; @@ -57,7 +63,7 @@ public class CarrierTechnologyParametersJSONAdapter static { BUILT_IN_CARRIER_TECHNOLOGY_PARMETER_CLASS_MAP.put("FILE", - FILECarrierTechnologyParameters.class.getCanonicalName()); + FileCarrierTechnologyParameters.class.getCanonicalName()); BUILT_IN_CARRIER_TECHNOLOGY_PARMETER_CLASS_MAP.put("EVENT_REQUESTOR", EventRequestorCarrierTechnologyParameters.class.getCanonicalName()); } @@ -99,7 +105,7 @@ public class CarrierTechnologyParametersJSONAdapter // Get and check the carrier technology label final String carrierTechnologyLabel = labelJsonPrimitive.getAsString().replaceAll("\\s+", ""); if (carrierTechnologyLabel == null || carrierTechnologyLabel.length() == 0) { - final String errorMessage = "carrier technology parameter \"" + CARRIER_TECHNOLOGY_TOKEN + "\" value \"" + final String errorMessage = "carrier technology parameter \"" + CARRIER_TECHNOLOGY_TOKEN + VALUE_TAG + labelJsonPrimitive.getAsString() + "\" invalid in JSON file"; LOGGER.warn(errorMessage); throw new ParameterRuntimeException(errorMessage); @@ -124,8 +130,8 @@ public class CarrierTechnologyParametersJSONAdapter // Check the carrier technology parameter class if (carrierTechnologyParameterClassName == null || carrierTechnologyParameterClassName.length() == 0) { - final String errorMessage = "carrier technology \"" + carrierTechnologyLabel + "\" parameter \"" - + PARAMETER_CLASS_NAME + "\" value \"" + final String errorMessage = CARRIER_TECHNOLOGY_PREAMBLE + carrierTechnologyLabel + "\" parameter \"" + + PARAMETER_CLASS_NAME + VALUE_TAG + (classNameJsonPrimitive != null ? classNameJsonPrimitive.getAsString() : "null") + "\" invalid in JSON file"; LOGGER.warn(errorMessage); @@ -138,8 +144,8 @@ public class CarrierTechnologyParametersJSONAdapter carrierTechnologyParameterClass = Class.forName(carrierTechnologyParameterClassName); } catch (final ClassNotFoundException e) { final String errorMessage = - "carrier technology \"" + carrierTechnologyLabel + "\" parameter \"" + PARAMETER_CLASS_NAME - + "\" value \"" + carrierTechnologyParameterClassName + "\", could not find class"; + CARRIER_TECHNOLOGY_PREAMBLE + carrierTechnologyLabel + "\" parameter \"" + PARAMETER_CLASS_NAME + + VALUE_TAG + carrierTechnologyParameterClassName + "\", could not find class"; LOGGER.warn(errorMessage, e); throw new ParameterRuntimeException(errorMessage, e); } @@ -164,7 +170,8 @@ public class CarrierTechnologyParametersJSONAdapter // Check that the carrier technology label matches the label in the carrier technology // parameters object if (!carrierTechnologyParameters.getLabel().equals(carrierTechnologyLabel)) { - final String errorMessage = "carrier technology \"" + carrierTechnologyLabel + "\" does not match plugin \"" + final String errorMessage = CARRIER_TECHNOLOGY_PREAMBLE + carrierTechnologyLabel + + "\" does not match plugin \"" + carrierTechnologyParameters.getLabel() + "\" in \"" + carrierTechnologyParameterClassName + "\", specify correct carrier technology parameter plugin in parameter \"" + PARAMETER_CLASS_NAME + "\""; diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java index ba065d3ef..faa6d79b3 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.service.parameters.engineservice; import java.io.File; import java.net.URL; +import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.service.parameters.ApexParameterConstants; @@ -31,8 +32,6 @@ import org.onap.policy.common.parameters.ParameterGroup; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.apex.core.engine.EngineParameters; - /** * This class holds the parameters for an Apex Engine Service with multiple engine threads running multiple engines. * @@ -315,7 +314,7 @@ public class EngineServiceParameters implements ParameterGroup { } /** - * Validate the policy model file name parameter + * Validate the policy model file name parameter. * @param result the variable in which to store the result of the validation */ private void validatePolicyModelFileName(final GroupValidationResult result) { @@ -327,11 +326,11 @@ public class EngineServiceParameters implements ParameterGroup { // The file name can refer to a resource on the local file system or on the class // path - final URL fileURL = ResourceUtils.getUrl4Resource(policyModelFileName); - if (fileURL == null) { + final URL fileUrl = ResourceUtils.getUrl4Resource(policyModelFileName); + if (fileUrl == null) { result.setResult(POLICY_MODEL_FILE_NAME, ValidationStatus.INVALID, "not found or is not a plain file"); } else { - final File policyModelFile = new File(fileURL.getPath()); + final File policyModelFile = new File(fileUrl.getPath()); if (!policyModelFile.isFile()) { result.setResult(POLICY_MODEL_FILE_NAME, ValidationStatus.INVALID, "not found or is not a plain file"); } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java index 50f4925f3..06cbd416f 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJSONAdapter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java @@ -20,9 +20,6 @@ package org.onap.policy.apex.service.parameters.engineservice; -import java.lang.reflect.Type; -import java.util.Map.Entry; - import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -31,6 +28,9 @@ import com.google.gson.JsonParseException; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; +import java.lang.reflect.Type; +import java.util.Map.Entry; + import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameters; import org.onap.policy.apex.context.parameters.DistributorParameters; @@ -51,9 +51,9 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class EngineServiceParametersJSONAdapter +public class EngineServiceParametersJsonAdapter implements JsonSerializer<EngineParameters>, JsonDeserializer<EngineParameters> { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(EngineServiceParametersJSONAdapter.class); + private static final XLogger LOGGER = XLoggerFactory.getXLogger(EngineServiceParametersJsonAdapter.class); private static final String PARAMETER_CLASS_NAME = "parameterClassName"; diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java index 996899052..afd877fd2 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java @@ -33,26 +33,20 @@ import org.onap.policy.common.parameters.ValidationStatus; /** * The parameters for a single event producer, event consumer or synchronous event handler. * - * <p>Event producers, consumers, and synchronous event handlers all use a carrier technology and an event protocol so the - * actual parameters for each one are the same. Therefore, we use the same class for the parameters of each one. + * <p>Event producers, consumers, and synchronous event handlers all use a carrier technology and an event protocol so + * the actual parameters for each one are the same. Therefore, we use the same class for the parameters of each one. * - * <p>The following parameters are defined: - * <ol> - * <li>carrierTechnologyParameters: The carrier technology is the type of messaging infrastructure used to carry events. - * Examples are File, Kafka or REST. - * <li>eventProtocolParameters: The format that the events are in when being carried. Examples are JSON, XML, or Java - * Beans. carrier technology - * <li>synchronousMode: true if the event handler is working in synchronous mode, defaults to false - * <li>synchronousPeer: the peer event handler (consumer for producer or producer for consumer) of this event handler in - * synchronous mode + * <p>The following parameters are defined: <ol> <li>carrierTechnologyParameters: The carrier technology is the type of + * messaging infrastructure used to carry events. Examples are File, Kafka or REST. <li>eventProtocolParameters: The + * format that the events are in when being carried. Examples are JSON, XML, or Java Beans. carrier technology + * <li>synchronousMode: true if the event handler is working in synchronous mode, defaults to false <li>synchronousPeer: + * the peer event handler (consumer for producer or producer for consumer) of this event handler in synchronous mode * <li>synchronousTimeout: the amount of time to wait for the reply to synchronous events before they are timed out - * <li>requestorMode: true if the event handler is working in requestor mode, defaults to false - * <li>requestorPeer: the peer event handler (consumer for producer or producer for consumer) of this event handler in - * requestor mode + * <li>requestorMode: true if the event handler is working in requestor mode, defaults to false <li>requestorPeer: the + * peer event handler (consumer for producer or producer for consumer) of this event handler in requestor mode * <li>requestorTimeout: the amount of time to wait for the reply to synchronous events before they are timed out * <li>eventNameFilter: a regular expression to apply to events on this event handler. If specified, events not matching - * the given regular expression are ignored. If it is null, all events are handledDefaults to null. - * </ol> + * the given regular expression are ignored. If it is null, all events are handledDefaults to null. </ol> * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -340,7 +334,7 @@ public class EventHandlerParameters implements ParameterGroup { } /** - * Check if we're using synchronous mode + * Check if we're using synchronous mode. * * @return true if if we're using synchronous mode */ @@ -349,7 +343,8 @@ public class EventHandlerParameters implements ParameterGroup { } /** - * The synchronous peer for this event handler + * The synchronous peer for this event handler. + * * @return the synchronous peer for this event handler */ public String getSynchronousPeer() { @@ -357,7 +352,8 @@ public class EventHandlerParameters implements ParameterGroup { } /** - * Get the timeout for synchronous operations + * Get the timeout for synchronous operations. + * * @return the timeout for synchronous operations */ public long getSynchronousTimeout() { @@ -365,7 +361,8 @@ public class EventHandlerParameters implements ParameterGroup { } /** - * Check if this event handler will use requestor mode + * Check if this event handler will use requestor mode. + * * @return true if this event handler will use requestor mode */ public boolean isRequestorMode() { @@ -373,7 +370,8 @@ public class EventHandlerParameters implements ParameterGroup { } /** - * The requestor peer for this event handler + * The requestor peer for this event handler. + * * @return the requestor peer for this event handler */ public String getRequestorPeer() { @@ -381,7 +379,8 @@ public class EventHandlerParameters implements ParameterGroup { } /** - * @return the requestorTimeout + * Get the requestor timeout. + * @return the requestorTimeout. */ public long getRequestorTimeout() { return requestorTimeout; diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java index 645368509..ba37fe80c 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java @@ -20,10 +20,6 @@ package org.onap.policy.apex.service.parameters.eventprotocol; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -32,8 +28,12 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; + import org.onap.policy.apex.service.engine.event.impl.apexprotocolplugin.ApexEventProtocolParameters; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; import org.onap.policy.common.parameters.ParameterRuntimeException; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -44,9 +44,13 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class EventProtocolParametersJSONAdapter +public class EventProtocolParametersJsonAdapter implements JsonSerializer<EventProtocolParameters>, JsonDeserializer<EventProtocolParameters> { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(EventProtocolParametersJSONAdapter.class); + private static final XLogger LOGGER = XLoggerFactory.getXLogger(EventProtocolParametersJsonAdapter.class); + + // Recurring string constants + private static final String EVENT_PROTOCOL_PREFIX = "event protocol \""; + private static final String VALUE_TAG = "\" value \""; private static final String PARAMETER_CLASS_NAME = "parameterClassName"; @@ -57,7 +61,7 @@ public class EventProtocolParametersJSONAdapter private static final Map<String, String> BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP = new HashMap<>(); static { - BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP.put("JSON", JSONEventProtocolParameters.class.getCanonicalName()); + BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP.put("JSON", JsonEventProtocolParameters.class.getCanonicalName()); BUILT_IN_EVENT_PROTOCOL_PARMETER_CLASS_MAP.put("APEX", ApexEventProtocolParameters.class.getCanonicalName()); } @@ -98,7 +102,7 @@ public class EventProtocolParametersJSONAdapter // Get and check the event protocol label final String eventProtocolLabel = labelJsonPrimitive.getAsString().replaceAll("\\s+", ""); if (eventProtocolLabel == null || eventProtocolLabel.length() == 0) { - final String errorMessage = "event protocol parameter \"" + EVENT_PROTOCOL_TOKEN + "\" value \"" + final String errorMessage = "event protocol parameter \"" + EVENT_PROTOCOL_TOKEN + VALUE_TAG + labelJsonPrimitive.getAsString() + "\" invalid in JSON file"; LOGGER.warn(errorMessage); throw new ParameterRuntimeException(errorMessage); @@ -122,7 +126,7 @@ public class EventProtocolParametersJSONAdapter // Check the event protocol parameter class if (eventProtocolParameterClassName == null || eventProtocolParameterClassName.length() == 0) { final String errorMessage = - "event protocol \"" + eventProtocolLabel + "\" parameter \"" + PARAMETER_CLASS_NAME + "\" value \"" + EVENT_PROTOCOL_PREFIX + eventProtocolLabel + "\" parameter \"" + PARAMETER_CLASS_NAME + VALUE_TAG + (classNameJsonPrimitive != null ? classNameJsonPrimitive.getAsString() : "null") + "\" invalid in JSON file"; LOGGER.warn(errorMessage); @@ -135,7 +139,7 @@ public class EventProtocolParametersJSONAdapter eventProtocolParameterClass = Class.forName(eventProtocolParameterClassName); } catch (final ClassNotFoundException e) { final String errorMessage = - "event protocol \"" + eventProtocolLabel + "\" parameter \"" + PARAMETER_CLASS_NAME + "\" value \"" + EVENT_PROTOCOL_PREFIX + eventProtocolLabel + "\" parameter \"" + PARAMETER_CLASS_NAME + VALUE_TAG + eventProtocolParameterClassName + "\", could not find class"; LOGGER.warn(errorMessage, e); throw new ParameterRuntimeException(errorMessage, e); @@ -160,7 +164,7 @@ public class EventProtocolParametersJSONAdapter // Check that the event protocol label matches the label in the event protocol parameters // object if (!eventProtocolParameters.getLabel().equals(eventProtocolLabel)) { - final String errorMessage = "event protocol \"" + eventProtocolLabel + "\" does not match plugin \"" + final String errorMessage = EVENT_PROTOCOL_PREFIX + eventProtocolLabel + "\" does not match plugin \"" + eventProtocolParameters.getLabel() + "\" in \"" + eventProtocolParameterClassName + "\", specify correct event protocol parameter plugin in parameter \"" + PARAMETER_CLASS_NAME + "\""; diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JSONEventGenerator.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventGenerator.java index 94210e473..1ba901090 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JSONEventGenerator.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventGenerator.java @@ -27,9 +27,15 @@ import java.util.Random; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class JSONEventGenerator { +public class JsonEventGenerator { private static int nextEventNo = 0; + /** + * Json events. + * + * @param eventCount the event count + * @return the string + */ public static String jsonEvents(final int eventCount) { final StringBuilder builder = new StringBuilder(); @@ -43,6 +49,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event. + * + * @return the string + */ public static String jsonEvent() { final Random rand = new Random(); @@ -68,6 +79,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no name. + * + * @return the string + */ public static String jsonEventNoName() { final Random rand = new Random(); @@ -93,6 +109,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event bad name. + * + * @return the string + */ public static String jsonEventBadName() { final Random rand = new Random(); @@ -117,6 +138,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no ex name. + * + * @return the string + */ public static String jsonEventNoExName() { final Random rand = new Random(); @@ -140,6 +166,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no version. + * + * @return the string + */ public static String jsonEventNoVersion() { final Random rand = new Random(); @@ -165,6 +196,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event bad version. + * + * @return the string + */ public static String jsonEventBadVersion() { final Random rand = new Random(); @@ -190,6 +226,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no ex version. + * + * @return the string + */ public static String jsonEventNoExVersion() { final Random rand = new Random(); @@ -214,6 +255,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no namespace. + * + * @return the string + */ public static String jsonEventNoNamespace() { final Random rand = new Random(); @@ -239,6 +285,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event bad namespace. + * + * @return the string + */ public static String jsonEventBadNamespace() { final Random rand = new Random(); @@ -264,6 +315,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no ex namespace. + * + * @return the string + */ public static String jsonEventNoExNamespace() { final Random rand = new Random(); @@ -288,6 +344,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no source. + * + * @return the string + */ public static String jsonEventNoSource() { final Random rand = new Random(); @@ -313,6 +374,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event bad source. + * + * @return the string + */ public static String jsonEventBadSource() { final Random rand = new Random(); @@ -338,6 +404,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event no target. + * + * @return the string + */ public static String jsonEventNoTarget() { final Random rand = new Random(); @@ -363,6 +434,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event bad target. + * + * @return the string + */ public static String jsonEventBadTarget() { final Random rand = new Random(); @@ -388,6 +464,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event missing fields. + * + * @return the string + */ public static String jsonEventMissingFields() { final StringBuilder builder = new StringBuilder(); @@ -402,6 +483,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * Json event null fields. + * + * @return the string + */ public static String jsonEventNullFields() { final StringBuilder builder = new StringBuilder(); @@ -420,6 +506,11 @@ public class JSONEventGenerator { return builder.toString(); } + /** + * The main method. + * + * @param args the arguments + */ public static void main(final String[] args) { if (args.length != 1) { System.err.println("usage EventGenerator #events"); @@ -438,6 +529,11 @@ public class JSONEventGenerator { System.out.println(jsonEvents(eventCount)); } + /** + * Gets the next event no. + * + * @return the next event no + */ public static int getNextEventNo() { return nextEventNo; } diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java index 4f1089229..cfe2921b8 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONEventHandler.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java @@ -45,23 +45,30 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; import org.onap.policy.apex.model.eventmodel.concepts.AxEvents; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.model.utilities.TextFileUtils; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JSONEventConverter; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** * Test JSON Event Handler. + * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestJSONEventHandler { - private static final XLogger logger = XLoggerFactory.getXLogger(TestJSONEventHandler.class); - +public class TestJsonEventHandler { + private static final XLogger logger = XLoggerFactory.getXLogger(TestJsonEventHandler.class); + + /** + * Setup event model. + * + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexModelException the apex model exception + */ @BeforeClass public static void setupEventModel() throws IOException, ApexModelException { - final String policyModelString = - TextFileUtils.getTextFileAsString("src/test/resources/policymodels/SamplePolicyModelMVEL.json"); + final String policyModelString = TextFileUtils + .getTextFileAsString("src/test/resources/policymodels/SamplePolicyModelMVEL.json"); final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<AxPolicyModel>(AxPolicyModel.class); final AxPolicyModel apexPolicyModel = modelReader.read(new ByteArrayInputStream(policyModelString.getBytes())); @@ -69,6 +76,9 @@ public class TestJSONEventHandler { apexPolicyModel.register(); } + /** + * Initialize default schema parameters. + */ @BeforeClass public static void initializeDefaultSchemaParameters() { ParameterService.clear(); @@ -77,23 +87,31 @@ public class TestJSONEventHandler { ParameterService.register(schemaParameters); } + /** + * Teardown default schema parameters. + */ @AfterClass public static void teardownDefaultSchemaParameters() { ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); } + /** + * Test JSO nto apex event. + * + * @throws ApexException the apex exception + */ @Test - public void testJSONtoApexEvent() throws ApexException { + public void testJsontoApexEvent() throws ApexException { try { - final Apex2JSONEventConverter jsonEventConverter = new Apex2JSONEventConverter(); + final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter(); assertNotNull(jsonEventConverter); - jsonEventConverter.init(new JSONEventProtocolParameters()); + jsonEventConverter.init(new JsonEventProtocolParameters()); - final String apexEventJSONStringIn = JSONEventGenerator.jsonEvent(); + final String apexEventJsonStringIn = JsonEventGenerator.jsonEvent(); - logger.debug("input event\n" + apexEventJSONStringIn); + logger.debug("input event\n" + apexEventJsonStringIn); - final List<ApexEvent> apexEventList = jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + final List<ApexEvent> apexEventList = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); for (final ApexEvent apexEvent : apexEventList) { assertNotNull(apexEvent); @@ -115,129 +133,136 @@ public class TestJSONEventHandler { } } + /** + * Test JSO nto apex bad event. + * + * @throws ApexException the apex exception + */ @Test - public void testJSONtoApexBadEvent() throws ApexException { + public void testJsontoApexBadEvent() throws ApexException { try { - final Apex2JSONEventConverter jsonEventConverter = new Apex2JSONEventConverter(); + final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter(); assertNotNull(jsonEventConverter); - jsonEventConverter.init(new JSONEventProtocolParameters()); + jsonEventConverter.init(new JsonEventProtocolParameters()); - String apexEventJSONStringIn = null; + String apexEventJsonStringIn = null; try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoName(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoName(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { assertEquals("Failed to unmarshal JSON event: event received without mandatory parameter \"name\" ", - e.getMessage().substring(0, 82)); + e.getMessage().substring(0, 82)); } try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventBadName(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventBadName(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { - assertTrue(e.getMessage() - .startsWith("Failed to unmarshal JSON event: field \"name\" with value \"%%%%\" is invalid")); + assertTrue(e.getMessage().startsWith( + "Failed to unmarshal JSON event: field \"name\" with value \"%%%%\" is invalid")); } try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoExName(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoExName(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { assertEquals("Failed to unmarshal JSON event: an event definition for an event named \"I_DONT_EXI", - e.getMessage().substring(0, 82)); + e.getMessage().substring(0, 82)); } - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoVersion(); - ApexEvent event = jsonEventConverter.toApexEvent(null, apexEventJSONStringIn).get(0); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoVersion(); + ApexEvent event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn).get(0); assertEquals("0.0.1", event.getVersion()); try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventBadVersion(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventBadVersion(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { assertTrue(e.getMessage().startsWith( - "Failed to unmarshal JSON event: field \"version\" with value \"#####\" is invalid")); + "Failed to unmarshal JSON event: field \"version\" with value \"#####\" is invalid")); } try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoExVersion(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoExVersion(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { - assertTrue(e.getMessage().startsWith( - "Failed to unmarshal JSON event: an event definition for an event named " - + "\"Event0000\" with version \"1.2.3\" not found in Apex model")); + assertTrue(e.getMessage() + .startsWith("Failed to unmarshal JSON event: an event definition for an event named " + + "\"Event0000\" with version \"1.2.3\" not found in Apex model")); } - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoNamespace(); - event = jsonEventConverter.toApexEvent(null, apexEventJSONStringIn).get(0); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoNamespace(); + event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn).get(0); assertEquals("org.onap.policy.apex.sample.events", event.getNameSpace()); try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventBadNamespace(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventBadNamespace(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { - assertTrue(e.getMessage().startsWith( - "Failed to unmarshal JSON event: field \"nameSpace\" with value \"hello.&&&&\" is invalid")); + assertTrue(e.getMessage().startsWith("Failed to unmarshal JSON event: field \"nameSpace\" " + + "with value \"hello.&&&&\" is invalid")); } try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoExNamespace(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoExNamespace(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { - assertTrue(e.getMessage().startsWith( - "Failed to unmarshal JSON event: namespace \"pie.in.the.sky\" on event \"Event0000\" does not" - + " match namespace \"org.onap.policy.apex.sample.events\" for that event in the Apex model")); + assertTrue(e.getMessage() + .startsWith("Failed to unmarshal JSON event: namespace \"pie.in.the.sky\" " + + "on event \"Event0000\" does not" + + " match namespace \"org.onap.policy.apex.sample.events\" " + + "for that event in the Apex model")); } - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoSource(); - event = jsonEventConverter.toApexEvent(null, apexEventJSONStringIn).get(0); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoSource(); + event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn).get(0); assertEquals("Outside", event.getSource()); try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventBadSource(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventBadSource(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { assertTrue(e.getMessage().startsWith( - "Failed to unmarshal JSON event: field \"source\" with value \"%!@**@!\" is invalid")); + "Failed to unmarshal JSON event: field \"source\" with value \"%!@**@!\" is invalid")); } - apexEventJSONStringIn = JSONEventGenerator.jsonEventNoTarget(); - event = jsonEventConverter.toApexEvent(null, apexEventJSONStringIn).get(0); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNoTarget(); + event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn).get(0); assertEquals("Match", event.getTarget()); try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventBadTarget(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventBadTarget(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { - assertTrue(e.getMessage().startsWith( - "Failed to unmarshal JSON event: field \"target\" with value \"KNIO(*S)A(S)D\" is invalid")); + assertTrue(e.getMessage().startsWith("Failed to unmarshal JSON event: field \"target\" " + + "with value \"KNIO(*S)A(S)D\" is invalid")); } try { - apexEventJSONStringIn = JSONEventGenerator.jsonEventMissingFields(); - jsonEventConverter.toApexEvent(null, apexEventJSONStringIn); + apexEventJsonStringIn = JsonEventGenerator.jsonEventMissingFields(); + jsonEventConverter.toApexEvent(null, apexEventJsonStringIn); fail("Test should throw an exception here"); } catch (final ApexEventException e) { assertTrue(e.getMessage().startsWith("Failed to unmarshal JSON event: error parsing Event0000:0.0.1 " - + "event from Json. Field \"TestMatchCase\" is missing, but is mandatory.")); + + "event from Json. Field \"TestMatchCase\" is missing, but is mandatory.")); } - apexEventJSONStringIn = JSONEventGenerator.jsonEventNullFields(); - event = jsonEventConverter.toApexEvent(null, apexEventJSONStringIn).get(0); - assertEquals(event.get("TestSlogan"), null); - assertEquals(event.get("TestMatchCase"), (byte) -1); - assertEquals(event.get("TestTimestamp"), (long) -1); - assertEquals(event.get("TestTemperature"), -1.0); + apexEventJsonStringIn = JsonEventGenerator.jsonEventNullFields(); + event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn).get(0); + assertEquals(null, event.get("TestSlogan")); + assertEquals((byte) -1, event.get("TestMatchCase")); + assertEquals((long) -1, event.get("TestTimestamp")); + assertEquals(-1.0, event.get("TestTemperature")); // Set the missing fields as optional in the model final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get("Event0000"); @@ -246,8 +271,8 @@ public class TestJSONEventHandler { eventDefinition.getParameterMap().get("TestTimestamp").setOptional(true); eventDefinition.getParameterMap().get("TestTemperature").setOptional(true); - apexEventJSONStringIn = JSONEventGenerator.jsonEventMissingFields(); - event = jsonEventConverter.toApexEvent(null, apexEventJSONStringIn).get(0); + apexEventJsonStringIn = JsonEventGenerator.jsonEventMissingFields(); + event = jsonEventConverter.toApexEvent(null, apexEventJsonStringIn).get(0); assertEquals(null, event.get("TestSlogan")); assertEquals(null, event.get("TestMatchCase")); assertEquals(null, event.get("TestTimestamp")); @@ -258,10 +283,15 @@ public class TestJSONEventHandler { } } + /** + * Test apex event to JSON. + * + * @throws ApexException the apex exception + */ @Test - public void testApexEventToJSON() throws ApexException { + public void testApexEventToJson() throws ApexException { try { - final Apex2JSONEventConverter jsonEventConverter = new Apex2JSONEventConverter(); + final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter(); assertNotNull(jsonEventConverter); final Date event0000StartTime = new Date(); @@ -271,23 +301,23 @@ public class TestJSONEventHandler { event0000DataMap.put("TestTimestamp", event0000StartTime.getTime()); event0000DataMap.put("TestTemperature", 34.5445667); - final ApexEvent apexEvent0000 = - new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.sample.events", "test", "apex"); + final ApexEvent apexEvent0000 = new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.sample.events", + "test", "apex"); apexEvent0000.putAll(event0000DataMap); - final String apexEvent0000JSONString = (String) jsonEventConverter.fromApexEvent(apexEvent0000); + final String apexEvent0000JsonString = (String) jsonEventConverter.fromApexEvent(apexEvent0000); - logger.debug(apexEvent0000JSONString); + logger.debug(apexEvent0000JsonString); - assertTrue(apexEvent0000JSONString.contains("\"name\": \"Event0000\"")); - assertTrue(apexEvent0000JSONString.contains("\"version\": \"0.0.1\"")); - assertTrue(apexEvent0000JSONString.contains("\"nameSpace\": \"org.onap.policy.apex.sample.events\"")); - assertTrue(apexEvent0000JSONString.contains("\"source\": \"test\"")); - assertTrue(apexEvent0000JSONString.contains("\"target\": \"apex\"")); - assertTrue(apexEvent0000JSONString.contains("\"TestSlogan\": \"This is a test slogan\"")); - assertTrue(apexEvent0000JSONString.contains("\"TestMatchCase\": 12345")); - assertTrue(apexEvent0000JSONString.contains("\"TestTimestamp\": " + event0000StartTime.getTime())); - assertTrue(apexEvent0000JSONString.contains("\"TestTemperature\": 34.5445667")); + assertTrue(apexEvent0000JsonString.contains("\"name\": \"Event0000\"")); + assertTrue(apexEvent0000JsonString.contains("\"version\": \"0.0.1\"")); + assertTrue(apexEvent0000JsonString.contains("\"nameSpace\": \"org.onap.policy.apex.sample.events\"")); + assertTrue(apexEvent0000JsonString.contains("\"source\": \"test\"")); + assertTrue(apexEvent0000JsonString.contains("\"target\": \"apex\"")); + assertTrue(apexEvent0000JsonString.contains("\"TestSlogan\": \"This is a test slogan\"")); + assertTrue(apexEvent0000JsonString.contains("\"TestMatchCase\": 12345")); + assertTrue(apexEvent0000JsonString.contains("\"TestTimestamp\": " + event0000StartTime.getTime())); + assertTrue(apexEvent0000JsonString.contains("\"TestTemperature\": 34.5445667")); final Date event0004StartTime = new Date(1434363272000L); final Map<String, Object> event0004DataMap = new HashMap<String, Object>(); @@ -304,22 +334,22 @@ public class TestJSONEventHandler { event0004DataMap.put("TestActCaseSelected", new Integer(2)); event0004DataMap.put("TestActStateTime", new Long(1434370506095L)); - final ApexEvent apexEvent0004 = - new ApexEvent("Event0004", "0.0.1", "org.onap.policy.apex.sample.events", "test", "apex"); + final ApexEvent apexEvent0004 = new ApexEvent("Event0004", "0.0.1", "org.onap.policy.apex.sample.events", + "test", "apex"); apexEvent0004.putAll(event0004DataMap); - final String apexEvent0004JSONString = (String) jsonEventConverter.fromApexEvent(apexEvent0004); + final String apexEvent0004JsonString = (String) jsonEventConverter.fromApexEvent(apexEvent0004); - logger.debug(apexEvent0004JSONString); + logger.debug(apexEvent0004JsonString); - assertTrue(apexEvent0004JSONString.contains("\"name\": \"Event0004\"")); - assertTrue(apexEvent0004JSONString.contains("\"version\": \"0.0.1\"")); - assertTrue(apexEvent0004JSONString.contains("\"nameSpace\": \"org.onap.policy.apex.sample.events\"")); - assertTrue(apexEvent0004JSONString.contains("\"source\": \"test\"")); - assertTrue(apexEvent0004JSONString.contains("\"target\": \"apex\"")); - assertTrue(apexEvent0004JSONString.contains("\"TestSlogan\": \"Test slogan for External Event\"")); - assertTrue(apexEvent0004JSONString.contains("1434370506078")); - assertTrue(apexEvent0004JSONString.contains("1064.43")); + assertTrue(apexEvent0004JsonString.contains("\"name\": \"Event0004\"")); + assertTrue(apexEvent0004JsonString.contains("\"version\": \"0.0.1\"")); + assertTrue(apexEvent0004JsonString.contains("\"nameSpace\": \"org.onap.policy.apex.sample.events\"")); + assertTrue(apexEvent0004JsonString.contains("\"source\": \"test\"")); + assertTrue(apexEvent0004JsonString.contains("\"target\": \"apex\"")); + assertTrue(apexEvent0004JsonString.contains("\"TestSlogan\": \"Test slogan for External Event\"")); + assertTrue(apexEvent0004JsonString.contains("1434370506078")); + assertTrue(apexEvent0004JsonString.contains("1064.43")); } catch (final Exception e) { e.printStackTrace(); throw new ApexException("Exception reading Apex event JSON file", e); diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONTaggedEventConsumer.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonTaggedEventConsumer.java index 49e6f3bdf..e948ba67a 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJSONTaggedEventConsumer.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonTaggedEventConsumer.java @@ -37,7 +37,7 @@ import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer * Test JSON Tagged Event Consumer. * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestJSONTaggedEventConsumer { +public class TestJsonTaggedEventConsumer { @Test public void testGarbageText() throws IOException { @@ -71,7 +71,7 @@ public class TestJSONTaggedEventConsumer { taggedReader.init(jsonInputStream); TextBlock textBlock = taggedReader.readTextBlock(); - assertEquals(textBlock.getText(), "{TestTimestamp\": 1469781869268}"); + assertEquals("{TestTimestamp\": 1469781869268}", textBlock.getText()); textBlock = taggedReader.readTextBlock(); assertNull(textBlock.getText()); @@ -87,7 +87,7 @@ public class TestJSONTaggedEventConsumer { taggedReader.init(jsonInputStream); TextBlock textBlock = taggedReader.readTextBlock(); - assertEquals(textBlock.getText(), "{TestTimestamp\": 1469781869268}"); + assertEquals("{TestTimestamp\": 1469781869268}", textBlock.getText()); assertFalse(textBlock.isEndOfText()); textBlock = taggedReader.readTextBlock(); @@ -104,7 +104,7 @@ public class TestJSONTaggedEventConsumer { taggedReader.init(jsonInputStream); TextBlock textBlock = taggedReader.readTextBlock(); - assertEquals(textBlock.getText(), "{TestTimestamp\": 1469781869268}"); + assertEquals("{TestTimestamp\": 1469781869268}", textBlock.getText()); assertFalse(textBlock.isEndOfText()); textBlock = taggedReader.readTextBlock(); @@ -121,7 +121,7 @@ public class TestJSONTaggedEventConsumer { taggedReader.init(jsonInputStream); TextBlock textBlock = taggedReader.readTextBlock(); - assertEquals(textBlock.getText(), "{TestTimestamp\": 1469781869268}"); + assertEquals("{TestTimestamp\": 1469781869268}", textBlock.getText()); assertFalse(textBlock.isEndOfText()); textBlock = taggedReader.readTextBlock(); diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java index bfda220a5..56e716dd6 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ContextParameterTests.java @@ -65,8 +65,8 @@ public class ContextParameterTests { } catch (final ParameterException e) { assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextBadParams.json\"" + "\n(ParameterRuntimeException):failed to deserialize the parameters for " - + "\"contextParameters\" to parameter class \"hello\"\njava.lang.ClassNotFoundException: hello", - e.getMessage()); + + "\"contextParameters\" to parameter class " + + "\"hello\"\njava.lang.ClassNotFoundException: hello", e.getMessage()); } } @@ -97,8 +97,10 @@ public class ContextParameterTests { new ApexParameterHandler().getParameters(arguments); fail("This test should throw an exception"); } catch (final ParameterException e) { - assertEquals("error reading parameters from \"src/test/resources/parameters/serviceContextBadClassParams.json\"" - + "\n(ParameterRuntimeException):failed to deserialize the parameters for \"contextParameters\"" + assertEquals("error reading parameters from " + + "\"src/test/resources/parameters/serviceContextBadClassParams.json\"" + + "\n(ParameterRuntimeException):failed to deserialize " + + "the parameters for \"contextParameters\"" + " to parameter class \"java.lang.Integer\"\ncom.google.gson.JsonSyntaxException: " + "java.lang.IllegalStateException: Expected NUMBER but was BEGIN_OBJECT at path $", e.getMessage()); @@ -253,7 +255,8 @@ public class ContextParameterTests { } catch (final ParameterException e) { assertEquals("error reading parameters from " + "\"src/test/resources/parameters/serviceContextBadClassDistParams.json\"\n" - + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + + "(ClassCastException):" + + "org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + " org.onap.policy.apex.context.parameters.DistributorParameters", e.getMessage()); } } @@ -270,7 +273,8 @@ public class ContextParameterTests { } catch (final ParameterException e) { assertEquals("error reading parameters from " + "\"src/test/resources/parameters/serviceContextBadClassLockParams.json\"\n" - + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + + "(ClassCastException):" + + "org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + " org.onap.policy.apex.context.parameters.LockManagerParameters", e.getMessage()); } } @@ -287,7 +291,8 @@ public class ContextParameterTests { } catch (final ParameterException e) { assertEquals("error reading parameters from " + "\"src/test/resources/parameters/serviceContextBadClassPersistParams.json\"\n" - + "(ClassCastException):org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + + "(ClassCastException):" + + "org.onap.policy.apex.context.parameters.ContextParameters cannot be cast to" + " org.onap.policy.apex.context.parameters.PersistorParameters", e.getMessage()); } } diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java index 97724becc..7b71253b0 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ParameterTests.java @@ -156,7 +156,7 @@ public class ParameterTests { + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type " + "\"org.onap.policy.apex.service.engine.event.impl." - + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, " + + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, " + "parameter group has status INVALID\n" + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, " + "fileName not specified or is blank or null, " @@ -166,7 +166,7 @@ public class ParameterTests { + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type " + "\"org.onap.policy.apex.service.engine.event.impl." - + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, " + + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, " + "parameter group has status INVALID\n" + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, " + "fileName not specified or is blank or null, " @@ -241,23 +241,24 @@ public class ParameterTests { assertEquals(345, parameters.getEngineServiceParameters().getInstanceCount()); assertEquals(65522, parameters.getEngineServiceParameters().getDeploymentPort()); - final CarrierTechnologyParameters prodCT = parameters.getEventOutputParameters().get("FirstProducer") - .getCarrierTechnologyParameters(); - final EventProtocolParameters prodEP = parameters.getEventOutputParameters().get("FirstProducer") + final CarrierTechnologyParameters prodCarrierTech = parameters.getEventOutputParameters() + .get("FirstProducer").getCarrierTechnologyParameters(); + final EventProtocolParameters prodEventProt = parameters.getEventOutputParameters().get("FirstProducer") .getEventProtocolParameters(); - final CarrierTechnologyParameters consCT = parameters.getEventInputParameters() + final CarrierTechnologyParameters consCarrierTech = parameters.getEventInputParameters() .get("MySuperDooperConsumer1").getCarrierTechnologyParameters(); - final EventProtocolParameters consEP = parameters.getEventInputParameters().get("MySuperDooperConsumer1") - .getEventProtocolParameters(); + final EventProtocolParameters consEventProt = parameters.getEventInputParameters() + .get("MySuperDooperConsumer1").getEventProtocolParameters(); - assertEquals("SUPER_DOOPER", prodCT.getLabel()); - assertEquals("SUPER_TOK_DEL", prodEP.getLabel()); - assertEquals("SUPER_DOOPER", consCT.getLabel()); - assertEquals("JSON", consEP.getLabel()); + assertEquals("SUPER_DOOPER", prodCarrierTech.getLabel()); + assertEquals("SUPER_TOK_DEL", prodEventProt.getLabel()); + assertEquals("SUPER_DOOPER", consCarrierTech.getLabel()); + assertEquals("JSON", consEventProt.getLabel()); - assertTrue(prodCT instanceof SuperDooperCarrierTechnologyParameters); + assertTrue(prodCarrierTech instanceof SuperDooperCarrierTechnologyParameters); - final SuperDooperCarrierTechnologyParameters superDooperParameters = (SuperDooperCarrierTechnologyParameters) prodCT; + final SuperDooperCarrierTechnologyParameters superDooperParameters = + (SuperDooperCarrierTechnologyParameters) prodCarrierTech; assertEquals("somehost:12345", superDooperParameters.getBootstrapServers()); assertEquals("0", superDooperParameters.getAcks()); assertEquals(25, superDooperParameters.getRetries()); diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java index 26cf09c38..374a2df14 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/ProducerConsumerTests.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.junit.Test; -import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters; +import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters; import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments; import org.onap.policy.apex.service.parameters.ApexParameterHandler; import org.onap.policy.apex.service.parameters.ApexParameters; @@ -117,7 +117,7 @@ public class ProducerConsumerTests { + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" + ", parameter group has status INVALID\n" + " parameter group \"FILE\" type " + "\"org.onap.policy.apex.service.engine.event.impl." - + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, " + + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, " + "parameter group has status INVALID\n" + " field \"fileName\" type \"java.lang.String\" value \"null\" INVALID, " + "fileName not specified or is blank or null, " @@ -156,8 +156,8 @@ public class ProducerConsumerTests { + "(ParameterRuntimeException):carrier technology \"SUPER_LOOPER\" " + "does not match plugin \"SUPER_DOOPER\" in \"" + "org.onap.policy.apex.service.engine." + "parameters.dummyclasses.SuperDooperCarrierTechnologyParameters" - + "\", specify correct carrier technology parameter plugin in parameter \"parameterClassName\"", - e.getMessage()); + + "\", specify correct carrier technology parameter plugin " + + "in parameter \"parameterClassName\"", e.getMessage()); } } @@ -189,11 +189,11 @@ public class ProducerConsumerTests { try { final ApexParameters parameters = new ApexParameterHandler().getParameters(arguments); - final FILECarrierTechnologyParameters fileParams = (FILECarrierTechnologyParameters) parameters + final FileCarrierTechnologyParameters fileParams = (FileCarrierTechnologyParameters) parameters .getEventOutputParameters().get("aProducer").getCarrierTechnologyParameters(); assertEquals("/tmp/aaa.json", fileParams.getFileName()); assertEquals(false, fileParams.isStandardError()); - assertEquals(false, fileParams.isStandardIO()); + assertEquals(false, fileParams.isStandardIo()); assertEquals(false, fileParams.isStreamingMode()); } catch (final ParameterException e) { fail("This test should not throw an exception"); @@ -210,18 +210,20 @@ public class ProducerConsumerTests { new ApexParameterHandler().getParameters(arguments); fail("This test should throw an exception"); } catch (final ParameterException e) { - assertEquals("validation error(s) on parameters from \"src/test/resources/parameters/prodConsBadFileName.json\"\n" + assertEquals("validation error(s) on parameters from " + + "\"src/test/resources/parameters/prodConsBadFileName.json\"\n" + "parameter group \"APEX_PARAMETERS\" type " + "\"org.onap.policy.apex.service.parameters.ApexParameters\" INVALID, " + "parameter group has status INVALID\n" - + " parameter group map \"eventOutputParameters\" INVALID, parameter group has status INVALID\n" - + " parameter group \"aProducer\" type " - + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID, " - + "parameter group has status INVALID\n" + " parameter group \"FILE\" type " + + " parameter group map \"eventOutputParameters\" INVALID, " + + "parameter group has status INVALID\n" + " parameter group \"aProducer\" type " + + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" " + + "INVALID, parameter group has status INVALID\n" + " parameter group \"FILE\" type " + "\"org.onap.policy.apex.service.engine.event.impl." - + "filecarrierplugin.FILECarrierTechnologyParameters\" INVALID, " + + "filecarrierplugin.FileCarrierTechnologyParameters\" INVALID, " + "parameter group has status INVALID\n" + " field \"fileName\" type " - + "\"java.lang.String\" value \"null\" INVALID, fileName not specified or is blank or null, " + + "\"java.lang.String\" value \"null\" INVALID, " + + "fileName not specified or is blank or null, " + "it must be specified as a valid file location\n", e.getMessage()); } } @@ -237,8 +239,9 @@ public class ProducerConsumerTests { fail("This test should throw an exception"); } catch (final ParameterException e) { assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsBadEPParClass.json\"\n" - + "(ParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" does not match plugin \"JSON\" in " - + "\"org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters" + + "(ParameterRuntimeException):event protocol \"SUPER_TOK_DEL\" " + + "does not match plugin \"JSON\" in \"org.onap.policy.apex.service.engine.event.impl" + + ".jsonprotocolplugin.JsonEventProtocolParameters" + "\", specify correct event protocol parameter plugin in parameter \"parameterClassName\"", e.getMessage()); } @@ -270,7 +273,8 @@ public class ProducerConsumerTests { new ApexParameterHandler().getParameters(arguments); fail("This test should throw an exception"); } catch (final ParameterException e) { - assertEquals("error reading parameters from \"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n" + assertEquals("error reading parameters from " + + "\"src/test/resources/parameters/prodConsMismatchEPParClass.json\"\n" + "(ParameterRuntimeException):event protocol \"SUPER_TOK_BEL\" " + "does not match plugin \"SUPER_TOK_DEL\" in " + "\"org.onap.policy.apex.service.engine.parameters.dummyclasses." diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java index 7913af84c..8ad0654b1 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/SyncParameterTests.java @@ -151,8 +151,8 @@ public class SyncParameterTests { + "specify a non-negative timeout value in milliseconds\n" + " parameter group map \"eventInputParameters\" INVALID, " + "parameter group has status INVALID\n" + " parameter group \"SyncConsumer0\" type " - + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID, " - + "specified peered mode \"SYNCHRONOUS\" timeout value \"-1\" is illegal, " + + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" " + + "INVALID, specified peered mode \"SYNCHRONOUS\" timeout value \"-1\" is illegal, " + "specify a non-negative timeout value in milliseconds\n" + " parameter group \"SyncConsumer1\" type " + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID," @@ -371,8 +371,8 @@ public class SyncParameterTests { + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" + ", peer \"SyncConsumer0 for peered mode SYNCHRONOUS, value \"SyncProducer1\" on peer " + "\"SyncConsumer0\" does not equal event handler \"SyncProducer0\"\n" - + " parameter group map \"eventInputParameters\" INVALID, parameter group has status INVALID\n" - + " parameter group \"SyncConsumer0\" type " + + " parameter group map \"eventInputParameters\" INVALID, parameter group has status " + + "INVALID\n parameter group \"SyncConsumer0\" type " + "\"org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters\" INVALID" + ", peer \"SyncProducer1 for peered mode SYNCHRONOUS, value \"SyncConsumer1\" on peer " + "\"SyncProducer1\" does not equal event handler \"SyncConsumer0\"\n", e.getMessage()); @@ -454,7 +454,8 @@ public class SyncParameterTests { assertTrue(consCT1 instanceof SuperDooperCarrierTechnologyParameters); assertTrue(consEP1 instanceof SuperTokenDelimitedEventProtocolParameters); - final SuperDooperCarrierTechnologyParameters superDooperParameters = (SuperDooperCarrierTechnologyParameters) consCT1; + final SuperDooperCarrierTechnologyParameters superDooperParameters = + (SuperDooperCarrierTechnologyParameters) consCT1; assertEquals("localhost:9092", superDooperParameters.getBootstrapServers()); assertEquals("all", superDooperParameters.getAcks()); assertEquals(0, superDooperParameters.getRetries()); diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java index 7eaf4c8e1..ccde5199a 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperCarrierTechnologyParameters.java @@ -47,11 +47,12 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar private static final int DEFAULT_SESSION_TIMEOUT = 30000; private static final String DEFAULT_PRODUCER_TOPIC = "apex-out"; private static final int DEFAULT_CONSUMER_POLL_TIME = 100; - private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = { "apex-in" }; - private static final String DEFAULT_KEY_SERIALIZER = "org.apache.superDooper.common.serialization.StringSerializer"; - private static final String DEFAULT_VALUE_SERIALIZER = "org.apache.superDooper.common.serialization.StringSerializer"; - private static final String DEFAULT_KEY_DESERIALIZER = "org.apache.superDooper.common.serialization.StringDeserializer"; - private static final String DEFAULT_VALUE_DESERIALIZER = "org.apache.superDooper.common.serialization.StringDeserializer"; + private static final String[] DEFAULT_CONSUMER_TOPIC_LIST = + { "apex-in" }; + private static final String DEFAULT_KEYSERZER = "org.apache.superDooper.common.serialization.StringSerializer"; + private static final String DEFAULT_VALSERZER = "org.apache.superDooper.common.serialization.StringSerializer"; + private static final String DEFAULT_KEYDESZER = "org.apache.superDooper.common.serialization.StringDeserializer"; + private static final String DEFAULT_VALDESZER = "org.apache.superDooper.common.serialization.StringDeserializer"; // Parameter property map tokens private static final String PROPERTY_BOOTSTRAP_SERVERS = "bootstrap.servers"; @@ -83,10 +84,10 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar private String producerTopic = DEFAULT_PRODUCER_TOPIC; private int consumerPollTime = DEFAULT_CONSUMER_POLL_TIME; private String[] consumerTopicList = DEFAULT_CONSUMER_TOPIC_LIST; - private String keySerializer = DEFAULT_KEY_SERIALIZER; - private String valueSerializer = DEFAULT_VALUE_SERIALIZER; - private String keyDeserializer = DEFAULT_KEY_DESERIALIZER; - private String valueDeserializer = DEFAULT_VALUE_DESERIALIZER; + private String keySerializer = DEFAULT_KEYSERZER; + private String valueSerializer = DEFAULT_VALSERZER; + private String keyDeserializer = DEFAULT_KEYDESZER; + private String valueDeserializer = DEFAULT_VALDESZER; /** * Constructor to create a file carrier technology parameters instance and register the instance with the parameter @@ -478,19 +479,23 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar } if (retries < 0) { - result.setResult("retries", ValidationStatus.INVALID, "[" + retries + "] invalid, must be specified as retries >= 0"); + result.setResult("retries", ValidationStatus.INVALID, + "[" + retries + "] invalid, must be specified as retries >= 0"); } if (batchSize < 0) { - result.setResult("batchSize", ValidationStatus.INVALID, "[" + batchSize + "] invalid, must be specified as batchSize >= 0"); + result.setResult("batchSize", ValidationStatus.INVALID, + "[" + batchSize + "] invalid, must be specified as batchSize >= 0"); } if (lingerTime < 0) { - result.setResult("lingerTime", ValidationStatus.INVALID, "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0"); + result.setResult("lingerTime", ValidationStatus.INVALID, + "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0"); } if (bufferMemory < 0) { - result.setResult("bufferMemory", ValidationStatus.INVALID, "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0"); + result.setResult("bufferMemory", ValidationStatus.INVALID, + "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0"); } if (groupId == null || groupId.trim().length() == 0) { @@ -498,8 +503,8 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar } if (autoCommitTime < 0) { - result.setResult("autoCommitTime", ValidationStatus.INVALID, "[" + autoCommitTime - + "] invalid, must be specified as autoCommitTime >= 0"); + result.setResult("autoCommitTime", ValidationStatus.INVALID, + "[" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0"); } if (sessionTimeout < 0) { @@ -508,16 +513,18 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar } if (producerTopic == null || producerTopic.trim().length() == 0) { - result.setResult("producerTopic", ValidationStatus.INVALID, "producerTopic not specified, must be specified as a string"); + result.setResult("producerTopic", ValidationStatus.INVALID, + "producerTopic not specified, must be specified as a string"); } if (consumerPollTime < 0) { - result.setResult("consumerPollTime", ValidationStatus.INVALID, "[" + consumerPollTime - + "] invalid, must be specified as consumerPollTime >= 0"); + result.setResult("consumerPollTime", ValidationStatus.INVALID, + "[" + consumerPollTime + "] invalid, must be specified as consumerPollTime >= 0"); } if (consumerTopicList == null || consumerTopicList.length == 0) { - result.setResult("consumerTopicList", ValidationStatus.INVALID, "not specified, must be specified as a list of strings"); + result.setResult("consumerTopicList", ValidationStatus.INVALID, + "not specified, must be specified as a list of strings"); } StringBuilder consumerTopicMessageBuilder = new StringBuilder(); @@ -527,7 +534,7 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar + "\" specified on consumerTopicList, consumer topics must be specified as strings"); } } - + if (consumerTopicMessageBuilder.length() > 0) { result.setResult("consumerTopicList", ValidationStatus.INVALID, consumerTopicMessageBuilder.toString()); } @@ -537,11 +544,13 @@ public class SuperDooperCarrierTechnologyParameters extends CarrierTechnologyPar } if (valueSerializer == null || valueSerializer.trim().length() == 0) { - result.setResult("valueSerializer", ValidationStatus.INVALID, "not specified, must be specified as a string"); + result.setResult("valueSerializer", ValidationStatus.INVALID, + "not specified, must be specified as a string"); } if (keyDeserializer == null || keyDeserializer.trim().length() == 0) { - result.setResult("keyDeserializer", ValidationStatus.INVALID, "not specified, must be specified as a string"); + result.setResult("keyDeserializer", ValidationStatus.INVALID, + "not specified, must be specified as a string"); } if (valueDeserializer == null || valueDeserializer.trim().length() == 0) { diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java index a8d099654..0d021c919 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperDooperDistributorParameters.java @@ -74,8 +74,8 @@ public class SuperDooperDistributorParameters extends DistributorParameters { return jgroupsBindAddress; } - public void setjGroupsBindAddress(final String jGroupsBindAddress) { - this.jgroupsBindAddress = jGroupsBindAddress; + public void setjGroupsBindAddress(final String jgroupsBindAddress) { + this.jgroupsBindAddress = jgroupsBindAddress; } @Override diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java index ec4f97d78..7ae403726 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java @@ -20,7 +20,7 @@ package org.onap.policy.apex.service.engine.parameters.dummyclasses; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTokenDelimitedParameters; /** @@ -38,7 +38,7 @@ public class SuperTokenDelimitedEventProtocolParameters extends EventProtocolTex * the parameter service. */ public SuperTokenDelimitedEventProtocolParameters() { - super(JSONEventProtocolParameters.class.getCanonicalName()); + super(JsonEventProtocolParameters.class.getCanonicalName()); // Set the event protocol properties for the JSON carrier technology this.setLabel(SUPER_TOKEN_EVENT_PROTOCOL_LABEL); diff --git a/services/services-engine/src/test/resources/parameters/prodConsBadCTParClass.json b/services/services-engine/src/test/resources/parameters/prodConsBadCTParClass.json index 217946956..bb431279e 100644 --- a/services/services-engine/src/test/resources/parameters/prodConsBadCTParClass.json +++ b/services/services-engine/src/test/resources/parameters/prodConsBadCTParClass.json @@ -31,7 +31,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "SUPER_DOOPER", - "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "SUPER_TOK_DEL", diff --git a/services/services-engine/src/test/resources/parameters/prodConsBadEPParClass.json b/services/services-engine/src/test/resources/parameters/prodConsBadEPParClass.json index 0900d5bee..7b1f1c099 100644 --- a/services/services-engine/src/test/resources/parameters/prodConsBadEPParClass.json +++ b/services/services-engine/src/test/resources/parameters/prodConsBadEPParClass.json @@ -35,7 +35,7 @@ }, "eventProtocolParameters": { "eventProtocol": "SUPER_TOK_DEL", - "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JSONEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters" } } } diff --git a/services/services-engine/src/test/resources/parameters/prodConsNoCT.json b/services/services-engine/src/test/resources/parameters/prodConsNoCT.json index 7bf3024ba..cbd9957c8 100644 --- a/services/services-engine/src/test/resources/parameters/prodConsNoCT.json +++ b/services/services-engine/src/test/resources/parameters/prodConsNoCT.json @@ -31,7 +31,7 @@ "aConsumer": { "carrierParameters": { "carrierTechnology": "SUPER_DOOPER", - "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "SUPER_TOK_DEL", diff --git a/services/services-engine/src/test/resources/parameters/prodConsNoEP.json b/services/services-engine/src/test/resources/parameters/prodConsNoEP.json index 122680dbe..92c089225 100644 --- a/services/services-engine/src/test/resources/parameters/prodConsNoEP.json +++ b/services/services-engine/src/test/resources/parameters/prodConsNoEP.json @@ -31,7 +31,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "FILE", - "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FILECarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "SUPER_TOK_DEL", diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMvel.java index e500c9d3b..4aab859ca 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMvel.java @@ -31,10 +31,10 @@ import org.onap.policy.apex.context.parameters.ContextParameters; import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.common.parameters.ParameterService; -public class TestApexEngineMVEL { +public class TestApexEngineMvel { private SchemaParameters schemaParameters; private ContextParameters contextParameters; private EngineParameters engineParameters; @@ -61,7 +61,7 @@ public class TestApexEngineMVEL { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); ParameterService.register(engineParameters); } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java index 07a374926..b1542def0 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java @@ -45,7 +45,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.test.common.model.SampleDomainModelFactory; import org.onap.policy.common.parameters.ParameterService; import org.slf4j.ext.XLogger; @@ -86,7 +86,7 @@ public class TestEventInstantiation { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); ParameterService.register(engineParameters); } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java index 83e69c98f..20159a3bf 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java @@ -41,7 +41,7 @@ import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener; import org.onap.policy.apex.test.common.model.SampleDomainModelFactory; import org.onap.policy.common.parameters.ParameterService; @@ -83,7 +83,7 @@ public class TestContextUpdateDifferentModels { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); ParameterService.register(engineParameters); } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java index 7aaa1e585..d5605ea4c 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java @@ -44,7 +44,7 @@ import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener; import org.onap.policy.apex.test.common.model.SampleDomainModelFactory; import org.onap.policy.common.parameters.ParameterService; @@ -86,7 +86,7 @@ public class TestContextUpdateModel { ParameterService.register(contextParameters.getPersistorParameters()); engineParameters = new EngineParameters(); - engineParameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); ParameterService.register(engineParameters); } diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java index b17457516..c95498a05 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java @@ -28,7 +28,6 @@ import java.util.Properties; import kafka.admin.AdminUtils; import kafka.admin.RackAwareMode; -import kafka.server.BrokerState; import kafka.server.KafkaConfig; import kafka.server.KafkaServer; import kafka.utils.TestUtils; @@ -48,6 +47,9 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.service.engine.main.ApexMain; +/** + * The Class TestKafka2Kafka. + */ public class TestKafka2Kafka { // The method of starting an embedded Kafka server used in this example is based on the method // on stack overflow at @@ -66,6 +68,11 @@ public class TestKafka2Kafka { private static ZkClient zkClient; private static KafkaServer kafkaServer; + /** + * Setup dummy kafka server. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @BeforeClass public static void setupDummyKafkaServer() throws IOException { // setup Zookeeper @@ -95,6 +102,11 @@ public class TestKafka2Kafka { } + /** + * Shutdown dummy kafka server. + * + * @throws IOException Signals that an I/O exception has occurred. + */ @AfterClass public static void shutdownDummyKafkaServer() throws IOException { if (kafkaServer != null) { @@ -108,18 +120,39 @@ public class TestKafka2Kafka { } } + /** + * Test json kafka events. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + */ @Test public void testJsonKafkaEvents() throws MessagingException, ApexException { final String[] args = {"src/test/resources/prodcons/Kafka2KafkaJsonEvent.json"}; testKafkaEvents(args, false, "json"); } + /** + * Test XML kafka events. + * + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + */ @Test - public void testXMLKafkaEvents() throws MessagingException, ApexException { + public void testXmlKafkaEvents() throws MessagingException, ApexException { final String[] args = {"src/test/resources/prodcons/Kafka2KafkaXmlEvent.json"}; testKafkaEvents(args, true, "xml"); } + /** + * Test kafka events. + * + * @param args the args + * @param xmlEvents the xml events + * @param topicSuffix the topic suffix + * @throws MessagingException the messaging exception + * @throws ApexException the apex exception + */ private void testKafkaEvents(final String[] args, final Boolean xmlEvents, final String topicSuffix) throws MessagingException, ApexException { final KafkaEventSubscriber subscriber = diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerClient.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerClient.java index bda312c42..fd78ba5c0 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerClient.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerClient.java @@ -26,6 +26,9 @@ import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStri import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; +/** + * The Class WebSocketEventProducerClient. + */ public class WebSocketEventProducerClient implements WsStringMessageListener { private final String host; private final int port; @@ -36,6 +39,16 @@ public class WebSocketEventProducerClient implements WsStringMessageListener { WsStringMessageClient client; + /** + * Instantiates a new web socket event producer client. + * + * @param host the host + * @param port the port + * @param eventCount the event count + * @param xmlEvents the xml events + * @param eventInterval the event interval + * @throws MessagingException the messaging exception + */ public WebSocketEventProducerClient(final String host, final int port, final int eventCount, final boolean xmlEvents, final long eventInterval) throws MessagingException { this.host = host; @@ -51,6 +64,9 @@ public class WebSocketEventProducerClient implements WsStringMessageListener { + ", event count " + eventCount + ", xmlEvents " + xmlEvents); } + /** + * Send events. + */ public void sendEvents() { System.out.println(WebSocketEventProducerClient.class.getCanonicalName() + ": sending events on host " + host + ", port " + port + ", event count " + eventCount + ", xmlEvents " + xmlEvents); @@ -74,10 +90,18 @@ public class WebSocketEventProducerClient implements WsStringMessageListener { System.out.println(WebSocketEventProducerClient.class.getCanonicalName() + ": completed"); } + /** + * Gets the events sent count. + * + * @return the events sent count + */ public long getEventsSentCount() { return eventsSentCount; } + /** + * Shutdown. + */ public void shutdown() { client.stop(); System.out.println(WebSocketEventProducerClient.class.getCanonicalName() + ": stopped"); @@ -96,6 +120,12 @@ public class WebSocketEventProducerClient implements WsStringMessageListener { + ", received event " + eventString); } + /** + * The main method. + * + * @param args the arguments + * @throws MessagingException the messaging exception + */ public static void main(final String[] args) throws MessagingException { if (args.length != 5) { System.err.println("usage WebSocketEventProducerClient host port #events XML|JSON eventInterval"); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerServer.java index a36c4d61e..53aa0cab4 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerServer.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventProducerServer.java @@ -26,6 +26,9 @@ import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStri import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; +/** + * The Class WebSocketEventProducerServer. + */ public class WebSocketEventProducerServer implements WsStringMessageListener { private final int port; private final int eventCount; @@ -35,6 +38,15 @@ public class WebSocketEventProducerServer implements WsStringMessageListener { WsStringMessageServer server; + /** + * Instantiates a new web socket event producer server. + * + * @param port the port + * @param eventCount the event count + * @param xmlEvents the xml events + * @param eventInterval the event interval + * @throws MessagingException the messaging exception + */ public WebSocketEventProducerServer(final int port, final int eventCount, final boolean xmlEvents, final long eventInterval) throws MessagingException { this.port = port; @@ -49,6 +61,9 @@ public class WebSocketEventProducerServer implements WsStringMessageListener { + eventCount + ", xmlEvents " + xmlEvents); } + /** + * Send events. + */ public void sendEvents() { System.out.println(WebSocketEventProducerServer.class.getCanonicalName() + ": sending events on port " + port + ", event count " + eventCount + ", xmlEvents " + xmlEvents); @@ -73,10 +88,18 @@ public class WebSocketEventProducerServer implements WsStringMessageListener { System.out.println(WebSocketEventProducerServer.class.getCanonicalName() + ": event sending completed"); } + /** + * Gets the events sent count. + * + * @return the events sent count + */ public long getEventsSentCount() { return eventsSentCount; } + /** + * Shutdown. + */ public void shutdown() { server.stop(); System.out.println(WebSocketEventProducerServer.class.getCanonicalName() + ": stopped"); @@ -95,6 +118,12 @@ public class WebSocketEventProducerServer implements WsStringMessageListener { + ", received event " + eventString); } + /** + * The main method. + * + * @param args the arguments + * @throws MessagingException the messaging exception + */ public static void main(final String[] args) throws MessagingException { if (args.length != 4) { System.err.println("usage WebSocketEventProducerServer port #events XML|JSON eventInterval"); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberClient.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberClient.java index 48ca9c884..27a34a92e 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberClient.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberClient.java @@ -24,12 +24,22 @@ import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient; import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; +/** + * The Class WebSocketEventSubscriberClient. + */ public class WebSocketEventSubscriberClient implements WsStringMessageListener { private final int port; private long eventsReceivedCount = 0; private final WsStringMessageClient client; + /** + * Instantiates a new web socket event subscriber client. + * + * @param host the host + * @param port the port + * @throws MessagingException the messaging exception + */ public WebSocketEventSubscriberClient(final String host, final int port) throws MessagingException { this.port = port; @@ -51,15 +61,29 @@ public class WebSocketEventSubscriberClient implements WsStringMessageListener { eventsReceivedCount++; } + /** + * Gets the events received count. + * + * @return the events received count + */ public long getEventsReceivedCount() { return eventsReceivedCount; } + /** + * Shutdown. + */ public void shutdown() { client.stop(); System.out.println(WebSocketEventSubscriberServer.class.getCanonicalName() + ": stopped"); } + /** + * The main method. + * + * @param args the arguments + * @throws MessagingException the messaging exception + */ public static void main(final String[] args) throws MessagingException { if (args.length != 2) { System.err.println("usage WebSocketEventSubscriberClient host port"); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberServer.java index 83e324b9c..854a0e410 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberServer.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/websocket/WebSocketEventSubscriberServer.java @@ -24,12 +24,21 @@ import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; +/** + * The Class WebSocketEventSubscriberServer. + */ public class WebSocketEventSubscriberServer implements WsStringMessageListener { private final int port; private long eventsReceivedCount = 0; private final WsStringMessageServer server; + /** + * Instantiates a new web socket event subscriber server. + * + * @param port the port + * @throws MessagingException the messaging exception + */ public WebSocketEventSubscriberServer(final int port) throws MessagingException { this.port = port; @@ -54,15 +63,29 @@ public class WebSocketEventSubscriberServer implements WsStringMessageListener { eventsReceivedCount++; } + /** + * Gets the events received count. + * + * @return the events received count + */ public long getEventsReceivedCount() { return eventsReceivedCount; } + /** + * Shutdown. + */ public void shutdown() { server.stop(); System.out.println(WebSocketEventSubscriberServer.class.getCanonicalName() + ": stopped"); } + /** + * The main method. + * + * @param args the arguments + * @throws MessagingException the messaging exception + */ public static void main(final String[] args) throws MessagingException { if (args.length != 1) { System.err.println("usage WebSocketEventSubscriberClient port"); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java index aa7b56189..8f9aa6cee 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/context/EventAlbumContextTest.java @@ -29,13 +29,11 @@ import java.io.IOException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain; +import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.service.ModelService; import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.apex.service.engine.main.ApexMain; -import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.resources.ResourceUtils; public class EventAlbumContextTest { @@ -86,7 +84,7 @@ public class EventAlbumContextTest { final String[] cliArgs = new String[] { "-c", tempCommandFile.getCanonicalPath(), "-l", tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath() }; - new ApexCLIEditorMain(cliArgs); + new ApexCommandLineEditorMain(cliArgs); final String[] args = new String[] { "-m", tempModelFile.getAbsolutePath(), "-c", configFile }; final ApexMain apexMain = new ApexMain(args); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java index 451b4c76a..187a2a316 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/engdep/EngDepMessagingTest.java @@ -42,7 +42,7 @@ import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.service.ModelService; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.service.engine.event.ApexEvent; import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters; import org.onap.policy.apex.test.common.model.SampleDomainModelFactory; @@ -94,7 +94,7 @@ public class EngDepMessagingTest { engineServiceParameters.setDeploymentPort(58820); engineServiceParameters.setInstanceCount(3); engineServiceParameters.setId(100); - engineServiceParameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + engineServiceParameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); ParameterService.register(engineServiceParameters); ParameterService.register(engineServiceParameters.getEngineParameters()); diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInJsonEvent.json index 507ae7d6f..209e94fea 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInOutJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInOutJsonEvent.json index 43e187a87..10544c45e 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInOutJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredInOutJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredOutJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredOutJsonEvent.json index e5cd23b03..99b7c6684 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredOutJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileFilteredOutJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileJsonEvent.json index a7a321039..fb42942d7 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileXmlEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileXmlEvent.json index 5cca6d604..4b3adfaae 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileXmlEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2FileXmlEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -24,7 +24,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } }, @@ -38,7 +38,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json index b7540f943..9ce0bb348 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestFile2Rest/apex/event/PutEvent", "httpMethod": "DELETE" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadURL.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadURL.json index 99856932e..639b7c677 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadURL.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventBadURL.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestFile2Rest/apex/event/Bad" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventNoURL.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventNoURL.json index 8c00885e5..2dcedf7fd 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventNoURL.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventNoURL.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPost.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPost.json index 1a1a189a4..1fa52d055 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPost.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPost.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestFile2Rest/apex/event/PostEvent" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json index fda83d7a6..e196d8999 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestFile2Rest/apex/event/PostEventBadResponse" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPut.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPut.json index 990e08f17..641c0c97e 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPut.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/File2RESTJsonEventPut.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestFile2Rest/apex/event/PutEvent", "httpMethod": "PUT" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSJsonEvent.json index 6e9405576..0d55d8a7d 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "JMS", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JmsCarrierTechnologyParameters", "parameters": { "initialContextFactory": "org.onap.policy.apex.apps.uservice.test.adapt.jms.TestInitialContextFactory", "connectionFactory": "ConnectionFactory", @@ -31,7 +31,7 @@ }, "eventProtocolParameters": { "eventProtocol": "JMSTEXT", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JmsTextEventProtocolParameters" } } }, @@ -39,7 +39,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "JMS", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JmsCarrierTechnologyParameters", "parameters": { "initialContextFactory": "org.onap.policy.apex.apps.uservice.test.adapt.jms.TestInitialContextFactory", "connectionFactory": "ConnectionFactory", @@ -51,7 +51,7 @@ }, "eventProtocolParameters": { "eventProtocol": "JMSTEXT", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JMSTextEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JmsTextEventProtocolParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSObjectEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSObjectEvent.json index 9a8aed39b..228f8ec60 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSObjectEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/JMS2JMSObjectEvent.json @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "JMS", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JmsCarrierTechnologyParameters", "parameters": { "initialContextFactory": "org.onap.policy.apex.apps.uservice.test.adapt.jms.TestInitialContextFactory", "connectionFactory": "ConnectionFactory", @@ -30,7 +30,7 @@ }, "eventProtocolParameters": { "eventProtocol": "JMSOBJECT", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JmsObjectEventProtocolParameters" } } }, @@ -38,7 +38,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "JMS", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JMSCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.jms.JmsCarrierTechnologyParameters", "parameters": { "initialContextFactory": "org.onap.policy.apex.apps.uservice.test.adapt.jms.TestInitialContextFactory", "connectionFactory": "ConnectionFactory", @@ -50,7 +50,7 @@ }, "eventProtocolParameters": { "eventProtocol": "JMSOBJECT", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JMSObjectEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.jms.JmsObjectEventProtocolParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaJsonEvent.json index 974e22b51..cd758b18d 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "KAFKA", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters", "parameters": { "bootstrapServers": "localhost:39902", "acks": "all", @@ -40,7 +40,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "KAFKA", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters", "parameters": { "bootstrapServers": "localhost:39902", "groupId": "apex-group-id", diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaXmlEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaXmlEvent.json index 916b7caf7..d4468a57e 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaXmlEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Kafka2KafkaXmlEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "KAFKA", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters", "parameters": { "bootstrapServers": "localhost:39902", "acks": "all", @@ -33,7 +33,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } }, @@ -41,7 +41,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "KAFKA", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters", "parameters": { "bootstrapServers": "localhost:39902", "groupId": "apex-group-id", @@ -58,7 +58,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/LBPolicy_ExecModel_file2kafka.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/LBPolicy_ExecModel_file2kafka.json index f98a853f6..7b4127d53 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/LBPolicy_ExecModel_file2kafka.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/LBPolicy_ExecModel_file2kafka.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "KAFKA", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KAFKACarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters", "parameters": { "bootstrapServers": "localhost:9092", "acks": "all", diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEmptyEvents.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEmptyEvents.json index 8e77e7d25..804b91e9f 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEmptyEvents.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEmptyEvents.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRest2File/apex/event/GetEmptyEvent" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEvent.json index 849a83eca..6424e52e1 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRest2File/apex/event/GetEvent" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json index 86f14b024..227c20a0e 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRest2File/apex/event/GetEvent", "httpMethod": "POST" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadResponse.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadResponse.json index 95c3fd5c3..f365a9631 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadResponse.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadResponse.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRest2File/apex/event/GetEventBadResponse" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadURL.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadURL.json index f58e55bc4..852e69194 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadURL.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventBadURL.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { "url": "http://localhost:32801/TestRest2File/apex/event/Bad" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventNoURL.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventNoURL.json index ff35e17be..877ca47ba 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventNoURL.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/REST2FileJsonEventNoURL.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEvent.json index 180530ac7..f482bc9b2 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -37,7 +37,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerNotSync.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerNotSync.json index 7cd558a51..0b325a08d 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerNotSync.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerNotSync.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -34,7 +34,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoHost.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoHost.json index 72c94fd58..40943e794 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoHost.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoHost.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true } @@ -35,7 +35,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoPort.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoPort.json index 0ee99e2c9..85e33ef54 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoPort.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoPort.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost" @@ -36,7 +36,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextAvro.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextAvro.json index 7aabe00e7..2cd373810 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextAvro.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextAvro.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } }, "contextParameters": { @@ -26,7 +26,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -45,7 +45,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextJava.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextJava.json index 30b32da82..193c259b5 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextJava.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventContextJava.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } }, "contextParameters": { @@ -26,7 +26,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -45,7 +45,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventDivideByZero.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventDivideByZero.json index 1a5db11e8..d4b6d19b5 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventDivideByZero.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventDivideByZero.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -37,7 +37,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventMultiIn.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventMultiIn.json index 9975a443f..b34a85d32 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventMultiIn.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventMultiIn.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -35,7 +35,7 @@ "SecondConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -54,7 +54,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" @@ -66,7 +66,7 @@ "SecondProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerHost.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerHost.json index c33570808..2c73fc3de 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerHost.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerHost.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -37,7 +37,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "host": "localhost" } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerNotSync.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerNotSync.json index 1c0d005f6..8c55d158d 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerNotSync.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerNotSync.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -34,7 +34,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters" }, "eventProtocolParameters": { "eventProtocol": "JSON" diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerPort.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerPort.json index 4366c651a..da08cf569 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerPort.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerPort.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -37,7 +37,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "port": 12345 } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerStandalone.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerStandalone.json index d0cf4eb11..a2626dcf1 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerStandalone.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/RESTServerJsonEventProducerStandalone.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "FirstConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true, "host": "localhost", @@ -37,7 +37,7 @@ "FirstProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTSERVER", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RESTServerCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters", "parameters": { "standalone": true } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientJsonEvent.json index 651a63b59..7caa8b264 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "host": "localhost", "port": 42453 @@ -33,7 +33,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "host": "localhost", "port": 42451 diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientXMLEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientXMLEvent.json index c14bc0645..8883d2fa7 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientXMLEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsClientXMLEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "host": "localhost", "port": 42453 @@ -26,7 +26,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } }, @@ -34,7 +34,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "host": "localhost", "port": 42451 @@ -42,7 +42,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } } diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerJsonEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerJsonEvent.json index c1fa11c30..e7b1943c1 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerJsonEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerJsonEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 42452 @@ -33,7 +33,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 42450 diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerXMLEvent.json b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerXMLEvent.json index 878d7108a..5cd7945c2 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerXMLEvent.json +++ b/testsuites/integration/integration-uservice-test/src/test/resources/prodcons/Ws2WsServerXMLEvent.json @@ -9,7 +9,7 @@ "engineParameters": { "executorParameters": { "MVEL": { - "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters" + "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters" } } } @@ -18,7 +18,7 @@ "aProducer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 42452 @@ -26,7 +26,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } }, @@ -34,7 +34,7 @@ "aConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "WEBSOCKET", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.websocket.WebSocketCarrierTechnologyParameters", "parameters": { "wsClient": false, "port": 42450 @@ -42,7 +42,7 @@ }, "eventProtocolParameters": { "eventProtocol": "XML", - "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XMLEventProtocolParameters" + "parameterClassName": "org.onap.policy.apex.plugins.event.protocol.xml.XmlEventProtocolParameters" } } } diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/benchmark/ApexBaseBenchMarkTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/benchmark/ApexBaseBenchMarkTest.java index 363811978..43211bc73 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/benchmark/ApexBaseBenchMarkTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/benchmark/ApexBaseBenchMarkTest.java @@ -36,7 +36,7 @@ import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters; import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters; import org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters; import org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.service.engine.event.ApexEvent; import org.onap.policy.apex.service.engine.runtime.ApexEventListener; import org.onap.policy.apex.service.engine.runtime.ApexServiceModelUpdateTest; @@ -74,7 +74,7 @@ public class ApexBaseBenchMarkTest { final EngineParameters engineParameters = parameters.getEngineParameters(); final Map<String, ExecutorParameters> executorParameterMap = engineParameters.getExecutorParameterMap(); - executorParameterMap.put("MVEL", new MVELExecutorParameters()); + executorParameterMap.put("MVEL", new MvelExecutorParameters()); executorParameterMap.put("JAVASCRIPT", new JavascriptExecutorParameters()); executorParameterMap.put("JYTHON", new JythonExecutorParameters()); executorParameterMap.put("JAVA", new JavaExecutorParameters()); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceModelUpdateTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceModelUpdateTest.java index d26580611..aa95e73b3 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceModelUpdateTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceModelUpdateTest.java @@ -38,7 +38,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.service.ModelService; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.service.engine.event.ApexEvent; import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.runtime.impl.EngineServiceImpl; @@ -80,7 +80,7 @@ public class ApexServiceModelUpdateTest { parameters.setName(engineServiceKey.getName()); parameters.setVersion(engineServiceKey.getVersion()); parameters.setId(100); - parameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + parameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); service = EngineServiceImpl.create(parameters); LOGGER.debug("Running TestApexEngine. . ."); diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceTest.java index c5617e1e4..c178cd9aa 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/service/engine/runtime/ApexServiceTest.java @@ -36,7 +36,7 @@ import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters; +import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.service.engine.event.ApexEvent; import org.onap.policy.apex.service.engine.runtime.impl.EngineServiceImpl; import org.onap.policy.apex.service.engine.utils.Utils; @@ -58,8 +58,8 @@ public class ApexServiceTest { private static final long MAX_START_WAIT = 5000; // 5 sec private static final long MAX_RECV_WAIT = 5000; // 5 sec - private final static AxArtifactKey engineServiceKey = new AxArtifactKey("Machine-1_process-1_engine-1", "0.0.0"); - private final static EngineServiceParameters parameters = new EngineServiceParameters(); + private static final AxArtifactKey engineServiceKey = new AxArtifactKey("Machine-1_process-1_engine-1", "0.0.0"); + private static final EngineServiceParameters parameters = new EngineServiceParameters(); private static EngineService service = null; private static TestListener listener = null; private static AxPolicyModel apexPolicyModel = null; @@ -81,7 +81,7 @@ public class ApexServiceTest { parameters.setName(engineServiceKey.getName()); parameters.setVersion(engineServiceKey.getVersion()); parameters.setId(100); - parameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MVELExecutorParameters()); + parameters.getEngineParameters().getExecutorParameterMap().put("MVEL", new MvelExecutorParameters()); service = EngineServiceImpl.create(parameters); @@ -130,13 +130,13 @@ public class ApexServiceTest { final ApexEvent event = new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex"); - event.setExecutionID(System.nanoTime()); + event.setExecutionId(System.nanoTime()); event.putAll(eventDataMap); engineServiceEventInterface.sendEvent(event); final ApexEvent event2 = new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex"); - event2.setExecutionID(System.nanoTime()); + event2.setExecutionId(System.nanoTime()); event2.putAll(eventDataMap); engineServiceEventInterface.sendEvent(event2); @@ -193,13 +193,13 @@ public class ApexServiceTest { final ApexEvent event1 = new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex"); event1.putAll(eventDataMap); - event1.setExecutionID(System.nanoTime()); + event1.setExecutionId(System.nanoTime()); final ApexEventListener myEventListener1 = new ApexEventListener() { @Override public void onApexEvent(final ApexEvent responseEvent) { assertNotNull("Synchronous sendEventWait failed", responseEvent); - assertEquals(event1.getExecutionID(), responseEvent.getExecutionID()); + assertEquals(event1.getExecutionId(), responseEvent.getExecutionId()); waitFlag = false; } }; @@ -214,14 +214,14 @@ public class ApexServiceTest { final ApexEvent event2 = new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex"); - event2.setExecutionID(System.nanoTime()); + event2.setExecutionId(System.nanoTime()); event2.putAll(eventDataMap); final ApexEventListener myEventListener2 = new ApexEventListener() { @Override public void onApexEvent(final ApexEvent responseEvent) { assertNotNull("Synchronous sendEventWait failed", responseEvent); - assertEquals(event2.getExecutionID(), responseEvent.getExecutionID()); + assertEquals(event2.getExecutionId(), responseEvent.getExecutionId()); assertEquals(2, actionEventsReceived); waitFlag = false; } @@ -283,13 +283,13 @@ public class ApexServiceTest { final ApexEvent event = new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex"); - event.setExecutionID(System.nanoTime()); + event.setExecutionId(System.nanoTime()); event.putAll(eventDataMap); engineServiceEventInterface.sendEvent(event); final ApexEvent event2 = new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex"); - event2.setExecutionID(System.nanoTime()); + event2.setExecutionId(System.nanoTime()); event2.putAll(eventDataMap); engineServiceEventInterface.sendEvent(event2); @@ -350,7 +350,7 @@ public class ApexServiceTest { @Override public void onApexEvent(final ApexEvent responseEvent) { assertNotNull("Synchronous sendEventWait failed", responseEvent); - assertEquals(event1.getExecutionID(), responseEvent.getExecutionID()); + assertEquals(event1.getExecutionId(), responseEvent.getExecutionId()); waitFlag = false; } }; @@ -371,7 +371,7 @@ public class ApexServiceTest { @Override public void onApexEvent(final ApexEvent responseEvent) { assertNotNull("Synchronous sendEventWait failed", responseEvent); - assertEquals(event2.getExecutionID(), responseEvent.getExecutionID()); + assertEquals(event2.getExecutionId(), responseEvent.getExecutionId()); waitFlag = false; } }; @@ -429,7 +429,7 @@ public class ApexServiceTest { * * @see TestEvent */ - private final static class TestListener implements ApexEventListener { + private static final class TestListener implements ApexEventListener { /* * (non-Javadoc) diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java index cc9ed5cae..88ada24f6 100644 --- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java +++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java @@ -31,7 +31,7 @@ import java.util.Map.Entry; import java.util.Properties; import org.apache.commons.lang3.Validate; -import org.onap.policy.apex.auth.clicodegen.CGCliEditor; +import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; @@ -104,7 +104,7 @@ public class Model2Cli { * @throws ApexException if any problem occurred in the model */ public int runApp() throws ApexException { - final CGCliEditor codeGen = new CGCliEditor(); + final CodeGeneratorCliEditor codeGen = new CodeGeneratorCliEditor(); final ApexModelFactory factory = new ApexModelFactory(); final ApexModel model = factory.createApexModel(new Properties(), true); @@ -208,7 +208,7 @@ public class Model2Cli { * @param event the event * @return the parameters for event */ - private List<ST> getParametersForEvent(final CGCliEditor cg, final AxEvent event) { + private List<ST> getParametersForEvent(final CodeGeneratorCliEditor cg, final AxEvent event) { final Collection<AxField> fields = event.getFields(); final List<ST> ret = new ArrayList<>(fields.size()); for (final AxField f : fields) { @@ -229,7 +229,7 @@ public class Model2Cli { * @param task the task * @return the context references for task */ - private List<ST> getCtxtRefsForTask(final CGCliEditor cg, final AxTask task) { + private List<ST> getCtxtRefsForTask(final CodeGeneratorCliEditor cg, final AxTask task) { final Collection<AxArtifactKey> ctxs = task.getContextAlbumReferences(); final List<ST> ret = new ArrayList<>(ctxs.size()); final AxArtifactKey tkey = task.getKey(); @@ -250,7 +250,7 @@ public class Model2Cli { * @param task the task * @return the parameters for task */ - private List<ST> getParametersForTask(final CGCliEditor cg, final AxTask task) { + private List<ST> getParametersForTask(final CodeGeneratorCliEditor cg, final AxTask task) { final Collection<AxTaskParameter> pars = task.getTaskParameters().values(); final List<ST> ret = new ArrayList<>(pars.size()); for (final AxTaskParameter p : pars) { @@ -271,7 +271,7 @@ public class Model2Cli { * @param task the task * @return the logic for task */ - private ST getLogicForTask(final CGCliEditor cg, final AxTask task) { + private ST getLogicForTask(final CodeGeneratorCliEditor cg, final AxTask task) { final AxArtifactKey tkey = task.getKey(); final AxTaskLogic tl = task.getTaskLogic(); @@ -288,7 +288,7 @@ public class Model2Cli { * @param task the task * @return the output fields for task */ - private List<ST> getOutfieldsForTask(final CGCliEditor cg, final AxTask task) { + private List<ST> getOutfieldsForTask(final CodeGeneratorCliEditor cg, final AxTask task) { final Collection<? extends AxField> fields = task.getOutputFields().values(); final List<ST> ret = new ArrayList<>(fields.size()); for (final AxField f : fields) { @@ -309,7 +309,7 @@ public class Model2Cli { * @param task the task * @return the input fields for task */ - private List<ST> getInfieldsForTask(final CGCliEditor cg, final AxTask task) { + private List<ST> getInfieldsForTask(final CodeGeneratorCliEditor cg, final AxTask task) { final Collection<? extends AxField> fields = task.getInputFields().values(); final List<ST> ret = new ArrayList<>(fields.size()); for (final AxField f : fields) { @@ -330,7 +330,7 @@ public class Model2Cli { * @param pol the policy * @return the states for policy */ - private List<ST> getStatesForPolicy(final CGCliEditor cg, final AxPolicy pol) { + private List<ST> getStatesForPolicy(final CodeGeneratorCliEditor cg, final AxPolicy pol) { final Collection<AxState> states = pol.getStateMap().values(); final List<ST> ret = new ArrayList<>(states.size()); for (final AxState st : states) { @@ -357,7 +357,7 @@ public class Model2Cli { * @param st the state * @return the finalizers for state */ - private List<ST> getFinalizersForState(final CGCliEditor cg, final AxState st) { + private List<ST> getFinalizersForState(final CodeGeneratorCliEditor cg, final AxState st) { final Collection<AxStateFinalizerLogic> fins = st.getStateFinalizerLogicMap().values(); final List<ST> ret = new ArrayList<>(fins.size()); final AxReferenceKey skey = st.getKey(); @@ -379,7 +379,7 @@ public class Model2Cli { * @param st the state * @return the context references for state */ - private List<ST> getCtxtRefsForState(final CGCliEditor cg, final AxState st) { + private List<ST> getCtxtRefsForState(final CodeGeneratorCliEditor cg, final AxState st) { final Collection<AxArtifactKey> ctxs = st.getContextAlbumReferences(); final List<ST> ret = new ArrayList<>(ctxs.size()); final AxReferenceKey skey = st.getKey(); @@ -400,7 +400,7 @@ public class Model2Cli { * @param st the state * @return the TSL for state (if any) in a list */ - private List<ST> getTSLForState(final CGCliEditor cg, final AxState st) { + private List<ST> getTSLForState(final CodeGeneratorCliEditor cg, final AxState st) { final AxReferenceKey skey = st.getKey(); if (st.checkSetTaskSelectionLogic()) { final AxTaskSelectionLogic tsl = st.getTaskSelectionLogic(); @@ -419,7 +419,7 @@ public class Model2Cli { * @param st the state * @return the task references for state */ - private List<ST> getTaskRefsForState(final CGCliEditor cg, final AxState st) { + private List<ST> getTaskRefsForState(final CodeGeneratorCliEditor cg, final AxState st) { final Map<AxArtifactKey, AxStateTaskReference> taskrefs = st.getTaskReferences(); final List<ST> ret = new ArrayList<>(taskrefs.size()); final AxReferenceKey skey = st.getKey(); @@ -444,7 +444,7 @@ public class Model2Cli { * @param st the state * @return the state outputs for state */ - private List<ST> getStateOutputsForState(final CGCliEditor cg, final AxState st) { + private List<ST> getStateOutputsForState(final CodeGeneratorCliEditor cg, final AxState st) { final Collection<AxStateOutput> outs = st.getStateOutputs().values(); final List<ST> ret = new ArrayList<>(outs.size()); final AxReferenceKey skey = st.getKey(); |