Repository navigation
Expand file tree
/
Copy pathVersionInfoCommandIT.java
More file actions
68 lines (51 loc) · 1.86 KB
/
Copy pathVersionInfoCommandIT.java
File metadata and controls
68 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package org.utplsql.cli;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.utplsql.cli.util.SystemCapturer;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertEquals;
class VersionInfoCommandIT {
private SystemCapturer capturer;
@BeforeEach
void setupCaptureSystemOut() {
capturer = new SystemCapturer.SystemOutCapturer();
}
private String[] getNonEmptyLineArray(String content) {
return Arrays.stream(content.split("[\r\n]+"))
.filter(line -> !line.isEmpty())
.toArray(String[]::new);
}
private void assertNumberOfLines( int expected, String content ) {
String[] lines = getNonEmptyLineArray(content);
assertEquals(expected, lines.length, () -> {
StringBuilder sb = new StringBuilder();
sb.append(String.format("Expected output to have %d lines, but got %d.%n", expected, lines.length));
sb.append("Actual lines were:").append(System.lineSeparator());
for (int i = 0; i < lines.length; i++) {
sb.append(String.format(" [%d] %s%n", i, lines[i]));
}
return sb.toString();
});
}
@Test
void infoCommandRunsWithoutConnection() {
capturer.start();
int result = TestHelper.runApp("info");
String output = capturer.stop();
assertEquals(0, result);
assertNumberOfLines(2, output);
}
@Test
void infoCommandRunsWithConnection() {
capturer.start();
int result = TestHelper.runApp("info", TestHelper.getConnectionString());
String output = capturer.stop();
assertEquals(0, result);
assertNumberOfLines(3, output);
}
@AfterEach
void cleanupCaptureSystemOut() {
capturer.stop();
}
}