Added testParserError to CliTest

parent 33f75a79
...@@ -61,8 +61,7 @@ public final class DistributedTargetGeneratorCli { ...@@ -61,8 +61,7 @@ public final class DistributedTargetGeneratorCli {
public static final String GENERATOR_CPP = "cpp"; public static final String GENERATOR_CPP = "cpp";
public static final String GENERATOR_ROSCPP = "roscpp"; public static final String GENERATOR_ROSCPP = "roscpp";
public DistributedTargetGeneratorCli() { private DistributedTargetGeneratorCli() {}
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(Arrays.toString(args)); System.out.println(Arrays.toString(args));
...@@ -96,7 +95,7 @@ public final class DistributedTargetGeneratorCli { ...@@ -96,7 +95,7 @@ public final class DistributedTargetGeneratorCli {
try { try {
cliArgs = parser.parse(options, args); cliArgs = parser.parse(options, args);
} catch (ParseException e) { } catch (ParseException e) {
Log.error("Argument parsing exception", e); Log.error("0x9A1AC: Argument parsing exception", e);
return null; return null;
} }
return cliArgs; return cliArgs;
......
...@@ -41,6 +41,18 @@ public class CliTest{ ...@@ -41,6 +41,18 @@ public class CliTest{
LogConfig.enableFailQuick(true); LogConfig.enableFailQuick(true);
} }
@Test
public void testParserError(){
String[] args = {
"invalidParsingArg"};
DistributedTargetGeneratorCli.main(args);
assertTrue(LogConfig.getErrorCount() == 1);
assertTrue(LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains("0x9A1AC")));
}
@Test @Test
public void testNoGenerators(){ public void testNoGenerators(){
String[] args = { String[] args = {
...@@ -62,7 +74,7 @@ public class CliTest{ ...@@ -62,7 +74,7 @@ public class CliTest{
"--output-dir=target/cliTest/InvalidGenerators/"}; "--output-dir=target/cliTest/InvalidGenerators/"};
DistributedTargetGeneratorCli.main(args); DistributedTargetGeneratorCli.main(args);
assertTrue(LogConfig.getErrorCount() == 1); assertTrue(LogConfig.getErrorCount() == 1);
assertTrue(LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains("0xE28B6"))); assertTrue(logContains("0xE28B6"));
} }
@Test @Test
...@@ -124,7 +136,7 @@ public class CliTest{ ...@@ -124,7 +136,7 @@ public class CliTest{
"--output-dir=target/cliTest/InvalidRootModel/"}; "--output-dir=target/cliTest/InvalidRootModel/"};
DistributedTargetGeneratorCli.main(args); DistributedTargetGeneratorCli.main(args);
assertTrue(LogConfig.getErrorCount() == 1); assertTrue(LogConfig.getErrorCount() == 1);
assertTrue(LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains("0x5FFAE"))); assertTrue(logContains("0x5FFAE"));
} }
@Test @Test
...@@ -136,7 +148,11 @@ public class CliTest{ ...@@ -136,7 +148,11 @@ public class CliTest{
"--output-dir=target/cliTest/InvalidModelsDir/"}; "--output-dir=target/cliTest/InvalidModelsDir/"};
DistributedTargetGeneratorCli.main(args); DistributedTargetGeneratorCli.main(args);
assertTrue(LogConfig.getErrorCount() == 1); assertTrue(LogConfig.getErrorCount() == 1);
assertTrue(LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains("0x6444B"))); assertTrue(logContains("0x6444B"));
} }
private boolean logContains(String errorCode){
return LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains(errorCode));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment