SM2Tool { public static void main(String[] args) { Log.ensureInitalization(); if (args.length != 1) { Log.error("0xEE744 Please specify only one single path to the input model."); return; } Log.info("SM2 DSL Tool", "SM2Tool"); Log.info("------------------", "SM2Tool"); String model = args[0]; final ASTAutomaton ast = parse(model); Log.info(model + " parsed successfully!", "SM2Tool"); ISM2ArtifactScope modelTopScope = createSymbolTable(ast); Optional<StateSymbol> aSymbol = modelTopScope.resolveState("Ping"); if (aSymbol.isPresent()) { Log.info("Resolved state symbol \"Ping\"; FQN = " + aSymbol.get().toString(), "SM2Tool"); } runDefaultCoCos(ast); SM2CoCoChecker customCoCos = new SM2CoCoChecker(); customCoCos.addCoCo(new StateNameStartsWithCapitalLetter()); customCoCos.checkAll(ast); CountStates cs = new CountStates(); cs.handle(ast); Log.info("The model contains " + cs.getCount() + " states.", "SM2Tool"); PrettyPrinter pp = new PrettyPrinter(); pp.handle(ast); Log.info("Pretty printing the parsed sm2 into console:", "SM2Tool"); Log.println(pp.getResult()); }  static void main(String[] args); static ASTAutomaton parse(String model); static ISM2ArtifactScope createSymbolTable(ASTAutomaton ast); static void runDefaultCoCos(ASTAutomaton ast);  }
@Test public void test() { String[] args = {"src/test/resources/example/PingPong.aut"}; SM2Tool.main(args); assertTrue(Log.getFindings().isEmpty()); List<String> p = LogStub.getPrints(); assertEquals(9, p.size()); Assert.assertTrue(p.get(0), p.get(0).matches(".*.INFO. SM2Tool SM2 DSL Tool.*\n")); Assert.assertTrue(p.get(3), p.get(3).matches(".*.INFO. .* StateSymbol defined for NoGame.*\n")); Assert.assertTrue(p.get(6), p.get(6).matches(".*.INFO. .* The model contains 3 states.*\n")); String res = p.get(p.size()-1).replaceAll("[\r\n]", " "); assertEquals(231, res.length()); Assert.assertTrue(res, res.matches(".*state NoGame <<initial>>.*")); Assert.assertTrue(res, res.matches(".*Pong - returnBall > Ping;.*")); }