@Test public void test_lazy_start() throws Exception { String alreadyStarted = "eslint-bridge server is up, no need to start."; String starting = "Starting Node.js process to start eslint-bridge server at port"; eslintBridgeServer = createEslintBridgeServer("startServer.js"); eslintBridgeServer.startServerLazily(context); assertThat(logTester.logs(DEBUG).stream().anyMatch(s -> s.startsWith(starting))).isTrue(); assertThat(logTester.logs(DEBUG)).doesNotContain(alreadyStarted); logTester.clear(); eslintBridgeServer.startServerLazily(context); assertThat(logTester.logs(DEBUG).stream().noneMatch(s -> s.startsWith(starting))).isTrue(); assertThat(logTester.logs(DEBUG)).contains(alreadyStarted); }
@Override public void startServerLazily(SensorContext context) throws IOException { if (failedToStart) { throw new ServerAlreadyFailedException(); } try { if (isAlive()) { LOG.debug("eslint-bridge server is up, no need to start."); return; } deploy(); List<Path> deployedBundles = rulesBundles.deploy(); startServer(context, deployedBundles); } catch (NodeCommandException e) { failedToStart = true; throw e; } }
EslintBridgeServerImpl implements EslintBridgeServer { @Override public void startServerLazily(SensorContext context) throws IOException { if (failedToStart) { throw new ServerAlreadyFailedException(); } try { if (isAlive()) { LOG.debug("eslint-bridge server is up, no need to start."); return; } deploy(); List<Path> deployedBundles = rulesBundles.deploy(); startServer(context, deployedBundles); } catch (NodeCommandException e) { failedToStart = true; throw e; } } }
EslintBridgeServerImpl implements EslintBridgeServer { @Override public void startServerLazily(SensorContext context) throws IOException { if (failedToStart) { throw new ServerAlreadyFailedException(); } try { if (isAlive()) { LOG.debug("eslint-bridge server is up, no need to start."); return; } deploy(); List<Path> deployedBundles = rulesBundles.deploy(); startServer(context, deployedBundles); } catch (NodeCommandException e) { failedToStart = true; throw e; } } EslintBridgeServerImpl(NodeCommandBuilder nodeCommandBuilder, Bundle bundle, RulesBundles rulesBundles,
    NodeDeprecationWarning deprecationWarning);   EslintBridgeServerImpl(NodeCommandBuilder nodeCommandBuilder,
    int timeoutSeconds,
    Bundle bundle,
    RulesBundles rulesBundles,
    NodeDeprecationWarning deprecationWarning); }
EslintBridgeServerImpl implements EslintBridgeServer { @Override public void startServerLazily(SensorContext context) throws IOException { if (failedToStart) { throw new ServerAlreadyFailedException(); } try { if (isAlive()) { LOG.debug("eslint-bridge server is up, no need to start."); return; } deploy(); List<Path> deployedBundles = rulesBundles.deploy(); startServer(context, deployedBundles); } catch (NodeCommandException e) { failedToStart = true; throw e; } } EslintBridgeServerImpl(NodeCommandBuilder nodeCommandBuilder, Bundle bundle, RulesBundles rulesBundles,
    NodeDeprecationWarning deprecationWarning);   EslintBridgeServerImpl(NodeCommandBuilder nodeCommandBuilder,
    int timeoutSeconds,
    Bundle bundle,
    RulesBundles rulesBundles,
    NodeDeprecationWarning deprecationWarning); @Override void startServerLazily(SensorContext context); @Override void initLinter(Rule[] rules); @Override AnalysisResponse analyzeJavaScript(AnalysisRequest request); @Override AnalysisResponse analyzeTypeScript(AnalysisRequest request); boolean isAlive(); @Override boolean newTsConfig(); @Override TsConfigFile loadTsConfig(String filename); @Override void clean(); @Override String getCommandInfo(); @Override void start(); @Override void stop(); }
EslintBridgeServerImpl implements EslintBridgeServer { @Override public void startServerLazily(SensorContext context) throws IOException { if (failedToStart) { throw new ServerAlreadyFailedException(); } try { if (isAlive()) { LOG.debug("eslint-bridge server is up, no need to start."); return; } deploy(); List<Path> deployedBundles = rulesBundles.deploy(); startServer(context, deployedBundles); } catch (NodeCommandException e) { failedToStart = true; throw e; } } EslintBridgeServerImpl(NodeCommandBuilder nodeCommandBuilder, Bundle bundle, RulesBundles rulesBundles,
    NodeDeprecationWarning deprecationWarning);   EslintBridgeServerImpl(NodeCommandBuilder nodeCommandBuilder,
    int timeoutSeconds,
    Bundle bundle,
    RulesBundles rulesBundles,
    NodeDeprecationWarning deprecationWarning); @Override void startServerLazily(SensorContext context); @Override void initLinter(Rule[] rules); @Override AnalysisResponse analyzeJavaScript(AnalysisRequest request); @Override AnalysisResponse analyzeTypeScript(AnalysisRequest request); boolean isAlive(); @Override boolean newTsConfig(); @Override TsConfigFile loadTsConfig(String filename); @Override void clean(); @Override String getCommandInfo(); @Override void start(); @Override void stop();  }