Print message instead of null on console when specified play volume is invalid (#670)

The fix helps users and also ensures the unit test works on both Java 8 and 11.

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2019-03-17 13:00:35 +01:00
committed by Christoph Weitkamp
parent 71b241ae21
commit 7e94df1656
2 changed files with 3 additions and 2 deletions
@@ -144,7 +144,7 @@ public class AudioConsoleCommandExtension extends AbstractConsoleCommandExtensio
try {
volume = PercentType.valueOf(args[2]);
} catch (Exception e) {
console.println(e.getMessage());
console.println("Specify volume as percentage between 0 and 100");
break;
}
playOnSinks(args[0], args[1], volume, console);
@@ -140,7 +140,8 @@ public class AudioConsoleTest extends AbstractAudioServeltTest {
fileHandler.wavFileName(), "invalid" };
audioConsoleCommandExtension.execute(args, consoleMock);
waitForAssert(() -> assertThat("The given volume was invalid", consoleOutput, nullValue()));
waitForAssert(() -> assertThat("The given volume was invalid", consoleOutput,
is("Specify volume as percentage between 0 and 100")));
}
@Test