From 1065a4d52a5ffbcc9bc28bc854d0b37350cd611b Mon Sep 17 00:00:00 2001 From: Pablissimo Date: Sat, 4 Feb 2017 16:24:27 +0000 Subject: [PATCH] Adding missing test, renaming config parameter --- .../pablissimo/sonar/TsLintExecutorConfig.java | 2 +- .../com/pablissimo/sonar/TsLintExecutorImpl.java | 2 +- .../sonar/TsLintExecutorConfigTest.java | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/pablissimo/sonar/TsLintExecutorConfig.java b/src/main/java/com/pablissimo/sonar/TsLintExecutorConfig.java index 0126b63..e5cde94 100644 --- a/src/main/java/com/pablissimo/sonar/TsLintExecutorConfig.java +++ b/src/main/java/com/pablissimo/sonar/TsLintExecutorConfig.java @@ -31,7 +31,7 @@ public static TsLintExecutorConfig fromSettings(Settings settings, SensorContext return toReturn; } - public Boolean useAlreadyExistsTsLintOutput() { + public Boolean useExistingTsLintOutput() { return this.pathToTsLintOutput != null && !this.pathToTsLintOutput.isEmpty(); } diff --git a/src/main/java/com/pablissimo/sonar/TsLintExecutorImpl.java b/src/main/java/com/pablissimo/sonar/TsLintExecutorImpl.java index 0dd48c9..8834505 100644 --- a/src/main/java/com/pablissimo/sonar/TsLintExecutorImpl.java +++ b/src/main/java/com/pablissimo/sonar/TsLintExecutorImpl.java @@ -90,7 +90,7 @@ else if (files == null) { throw new IllegalArgumentException("files"); } - if (config.useAlreadyExistsTsLintOutput()) { + if (config.useExistingTsLintOutput()) { LOG.debug("Running with existing JSON file '" + config.getPathToTsLintOutput() + "' instead of calling tslint"); List toReturn = new ArrayList(); toReturn.add(this.getFileContent(new File(config.getPathToTsLintOutput()))); diff --git a/src/test/java/com/pablissimo/sonar/TsLintExecutorConfigTest.java b/src/test/java/com/pablissimo/sonar/TsLintExecutorConfigTest.java index c03155d..1b7e240 100644 --- a/src/test/java/com/pablissimo/sonar/TsLintExecutorConfigTest.java +++ b/src/test/java/com/pablissimo/sonar/TsLintExecutorConfigTest.java @@ -79,6 +79,22 @@ public void useTsConfigInsteadOfFileList_returnsFalse_ifPathToTsConfigNotSet() { assertFalse(config.useTsConfigInsteadOfFileList()); } + + @Test + public void useExistingTsLintOutput_returnsTrueIfPathSet() { + TsLintExecutorConfig config = getNewConfig(); + config.setPathToTsLintOutput("/path/to/tslint/json/output"); + + assertTrue(config.useExistingTsLintOutput()); + } + + @Test + public void useExistingTsLintOutput_returnsFalseIfPathNotSet() { + TsLintExecutorConfig config = getNewConfig(); + config.setPathToTsLintOutput(""); + + assertFalse(config.useExistingTsLintOutput()); + } @Test public void fromSettings_initialisesFromSettingsAndResolver() {