Added testParserError to CliTest

parent 33f75a79
......@@ -61,8 +61,7 @@ public final class DistributedTargetGeneratorCli {
public static final String GENERATOR_CPP = "cpp";
public static final String GENERATOR_ROSCPP = "roscpp";
public DistributedTargetGeneratorCli() {
}
private DistributedTargetGeneratorCli() {}
public static void main(String[] args) {
System.out.println(Arrays.toString(args));
......@@ -96,7 +95,7 @@ public final class DistributedTargetGeneratorCli {
try {
cliArgs = parser.parse(options, args);
} catch (ParseException e) {
Log.error("Argument parsing exception", e);
Log.error("0x9A1AC: Argument parsing exception", e);
return null;
}
return cliArgs;
......
......@@ -41,6 +41,18 @@ public class CliTest{
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
public void testNoGenerators(){
String[] args = {
......@@ -62,7 +74,7 @@ public class CliTest{
"--output-dir=target/cliTest/InvalidGenerators/"};
DistributedTargetGeneratorCli.main(args);
assertTrue(LogConfig.getErrorCount() == 1);
assertTrue(LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains("0xE28B6")));
assertTrue(logContains("0xE28B6"));
}
@Test
......@@ -124,7 +136,7 @@ public class CliTest{
"--output-dir=target/cliTest/InvalidRootModel/"};
DistributedTargetGeneratorCli.main(args);
assertTrue(LogConfig.getErrorCount() == 1);
assertTrue(LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains("0x5FFAE")));
assertTrue(logContains("0x5FFAE"));
}
@Test
......@@ -136,7 +148,11 @@ public class CliTest{
"--output-dir=target/cliTest/InvalidModelsDir/"};
DistributedTargetGeneratorCli.main(args);
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