summaryrefslogtreecommitdiffstats
path: root/auth/cli-editor/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'auth/cli-editor/src/test')
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java6
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java12
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java132
3 files changed, 68 insertions, 82 deletions
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/TestCLIEditorOptions.java
index 87618e18d..2056c9239 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/TestCLIEditorOptions.java
@@ -235,7 +235,7 @@ public class TestCLIEditorOptions {
// Generate input model
final String[] cliArgsIn = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex",
- "-l", tempLogFileIn.getAbsolutePath(), "-o", tempModelFileIn.getAbsolutePath()};
+ "-l", tempLogFileIn.getAbsolutePath(), "-o", tempModelFileIn.getAbsolutePath()};
final ApexCLIEditorMain cliEditorIn = new ApexCLIEditorMain(cliArgsIn);
assertEquals(0, cliEditorIn.getErrorCount());
@@ -252,8 +252,8 @@ public class TestCLIEditorOptions {
assertEquals(2924, tempModelFileInCharCount);
final String[] cliArgsOut = new String[] {"-i", tempModelFileIn.getAbsolutePath(), "-c",
- "src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex", "-l",
- tempLogFileOut.getAbsolutePath(), "-o", tempModelFileOut.getAbsolutePath()};
+ "src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex", "-l",
+ tempLogFileOut.getAbsolutePath(), "-o", tempModelFileOut.getAbsolutePath()};
final ApexCLIEditorMain cliEditorOut = new ApexCLIEditorMain(cliArgsOut);
assertEquals(0, cliEditorOut.getErrorCount());
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 3de41e8d4..1b99fce16 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
@@ -45,13 +45,8 @@ public class TestContextAlbums {
public void createTempFiles() throws IOException {
tempModelFile = File.createTempFile("TestPolicyModel", ".json");
- logicBlockArgs = new String[] {
- "-c",
- "src/test/resources/scripts/ContextAlbums.apex",
- "-o",
- tempModelFile.getAbsolutePath(),
- "-nl"
- };
+ logicBlockArgs = new String[] {"-c", "src/test/resources/scripts/ContextAlbums.apex", "-o",
+ tempModelFile.getAbsolutePath(), "-nl"};
}
/**
@@ -81,7 +76,8 @@ public class TestContextAlbums {
final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
assertNotNull(writtenModel);
- final URL compareModelURL = ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json");
+ final URL compareModelURL =
+ ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json");
final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
// Ignore key info UUIDs
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 6ff85e71c..eb2f2a46b 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
@@ -41,75 +41,65 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
* Test FileMacro in the CLI.
*/
public class TestFileMacro {
- private String[] fileMacroArgs;
-
- private File tempModelFile;
- private File tempLogFile;
-
- @Before
- public void createTempFiles() throws IOException {
- tempModelFile = File.createTempFile("TestPolicyModel", ".json");
- tempLogFile = File.createTempFile("TestPolicyModel", ".log");
-
- fileMacroArgs = new String[] {
- "-c",
- "src/test/resources/scripts/FileMacro.apex",
- "-l",
- tempLogFile.getCanonicalPath(),
- "-o",
- tempModelFile.getCanonicalPath(),
- "-if",
- "true"
- };
- }
-
- @After
- public void removeGeneratedModels() {
- tempModelFile.delete();
- }
-
- /**
- * Test logic block macro in CLI scripts.
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
- */
- @Test
- public void testLogicBlock() throws IOException, ApexModelException {
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(fileMacroArgs);
- // We expect eight errors
- assertEquals(8, 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 compareModelURL = ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json");
- final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
-
- // Ignore key info UUIDs
- writtenModel.getKeyInformation().getKeyInfoMap().clear();
- compareModel.getKeyInformation().getKeyInfoMap().clear();
-
- assertTrue(writtenModel.equals(compareModel));
-
- // The output event is in this file
- final File outputLogFile = new File(tempLogFile.getCanonicalPath());
-
- final String outputLogString = TextFileUtils
- .getTextFileAsString(outputLogFile.getCanonicalPath())
- .replace(Paths.get("").toAbsolutePath().toString() + File.separator, "")
- .replaceAll("\\s+", "");
-
- // We compare the log to what we expect to get
- final String outputLogCompareString = TextFileUtils
- .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log")
- .replaceAll("\\s+", "");
-
- // Check what we got is what we expected to get
- assertEquals(outputLogCompareString, outputLogString);
- }
+ private String[] fileMacroArgs;
+
+ private File tempModelFile;
+ private File tempLogFile;
+
+ @Before
+ public void createTempFiles() throws IOException {
+ tempModelFile = File.createTempFile("TestPolicyModel", ".json");
+ tempLogFile = File.createTempFile("TestPolicyModel", ".log");
+
+ fileMacroArgs = new String[] {"-c", "src/test/resources/scripts/FileMacro.apex", "-l",
+ tempLogFile.getCanonicalPath(), "-o", tempModelFile.getCanonicalPath(), "-if", "true"};
+ }
+
+ @After
+ public void removeGeneratedModels() {
+ tempModelFile.delete();
+ }
+
+ /**
+ * Test logic block macro in CLI scripts.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexModelException if there is an Apex error
+ */
+ @Test
+ public void testLogicBlock() throws IOException, ApexModelException {
+ final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(fileMacroArgs);
+ // We expect eight errors
+ assertEquals(8, 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 compareModelURL =
+ ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json");
+ final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
+
+ // Ignore key info UUIDs
+ writtenModel.getKeyInformation().getKeyInfoMap().clear();
+ compareModel.getKeyInformation().getKeyInfoMap().clear();
+
+ assertTrue(writtenModel.equals(compareModel));
+
+ // The output event is in this file
+ final File outputLogFile = new File(tempLogFile.getCanonicalPath());
+
+ final String outputLogString = TextFileUtils.getTextFileAsString(outputLogFile.getCanonicalPath())
+ .replace(Paths.get("").toAbsolutePath().toString() + File.separator, "").replaceAll("\\s+", "");
+
+ // We compare the log to what we expect to get
+ final String outputLogCompareString = TextFileUtils
+ .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log").replaceAll("\\s+", "");
+
+ // Check what we got is what we expected to get
+ assertEquals(outputLogCompareString, outputLogString);
+ }
}