forked from utPLSQL/utPLSQL-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersionInfoCommandIT.java
More file actions
60 lines (43 loc) · 1.5 KB
/
VersionInfoCommandIT.java
File metadata and controls
60 lines (43 loc) · 1.5 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
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 int getNonEmptyLines(String content) {
return (int) Arrays.stream(content.split("[\n|\r]"))
.filter(line -> !line.isEmpty())
.count();
}
private void assertNumberOfLines( int expected, String content ) {
int numOfLines = getNonEmptyLines(content);
assertEquals(expected, numOfLines, String.format("Expected output to have %n lines, but got %n", expected, numOfLines));
}
@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();
}
}