Improve version cli test
@@ -32,6 +32,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import java.util.regex.Pattern;
import static com.quorum.tessera.test.util.ElUtil.createAndPopulatePaths;
import static org.assertj.core.api.Assertions.*;
@@ -45,8 +46,7 @@ public class PicoCliDelegateTest {
private PicoCliDelegate cliDelegate;
- @Rule
- public SystemErrRule systemErrOutput = new SystemErrRule().enableLog();
+ @Rule public SystemErrRule systemErrOutput = new SystemErrRule().enableLog();
@Rule public SystemOutRule systemOutOutput = new SystemOutRule().enableLog();
@@ -61,18 +61,20 @@ public class PicoCliDelegateTest {
public void version() throws Exception {
final CliResult result = cliDelegate.execute("version");
- final String sysout = systemOutOutput.getLog();
- final String syserr = systemErrOutput.getLog();
-
assertThat(result).isNotNull();
assertThat(result.getConfig()).isNotPresent();
assertThat(result.getStatus()).isEqualTo(0);
assertThat(result.isSuppressStartup()).isTrue();
+ final String syserr = systemErrOutput.getLog();
assertThat(syserr).isEmpty();
+
+ final String sysout = systemOutOutput.getLogWithNormalizedLineSeparator();
assertThat(sysout).isNotEmpty();
- assertThat(sysout).contains("20.10.2");
+ final String sysoutNoNewLine = sysout.replace("\n", "");
+
+ assertThat(sysoutNoNewLine).matches(Pattern.compile("^.*[0-9]{2}\\.[0-9]{2}(\\.[0-9]{1,2})?(-SNAPSHOT)?$"));
}
@Test
@@ -123,7 +125,8 @@ public class PicoCliDelegateTest {
assertThat(syserr).isEmpty();
assertThat(sysout).isNotEmpty();
- assertThat(sysout).contains("Usage: tessera keygen [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
+ assertThat(sysout)
+ .contains("Usage: tessera keygen [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
}
@Test
@@ -140,7 +143,8 @@ public class PicoCliDelegateTest {
assertThat(syserr).isEmpty();
assertThat(sysout).isNotEmpty();
- assertThat(sysout).contains("Usage: tessera keygen [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
+ assertThat(sysout)
+ .contains("Usage: tessera keygen [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
}
@Test
@@ -157,7 +161,8 @@ public class PicoCliDelegateTest {
assertThat(syserr).isEmpty();
assertThat(sysout).isNotEmpty();
- assertThat(sysout).contains("Usage: tessera keyupdate [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
+ assertThat(sysout)
+ .contains("Usage: tessera keyupdate [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
}
@Test
@@ -170,12 +175,8 @@ public class PicoCliDelegateTest {
assertThat(ex).hasMessage("Missing required option: '--keys.keyData.privateKeyPath <privateKeyPath>'");
assertThat(syserr).isNotEmpty();
- assertThat(syserr).contains(
- "Usage: tessera keyupdate [OPTIONS] [COMMAND]",
- "Description:",
- "Options:",
- "Commands:"
- );
+ assertThat(syserr)
+ .contains("Usage: tessera keyupdate [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
}
@Test
