8000 io-to-data.1 : convert tests to Kotlin · java-to-kotlin/code@b93055f · GitHub
[go: up one dir, main page]

Skip to content

Commit b93055f

Browse files
Duncan McGregordmcg
authored andcommitted
io-to-data.1 : convert tests to Kotlin
1 parent 8db8094 commit b93055f

File tree

1 file changed

+45
-46
lines changed

1 file changed

+45
-46
lines changed
Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,62 @@
1-
package travelator.marketing;
1+
package travelator.marketing
22

3-
import org.junit.jupiter.api.Test;
4-
5-
import java.io.IOException;
6-
import java.io.StringReader;
7-
import java.io.StringWriter;
8-
import java.util.List;
9-
10-
import static org.junit.jupiter.api.Assertions.assertEquals;
3+
import org.junit.jupiter.api.Assertions.assertEquals
4+
import org.junit.jupiter.api.Test
5+
import java.io.StringReader
6+
import java.io.StringWriter
117

128
class HighValueCustomersReportTests {
139

1410
@Test
15-
public void test() throws IOException {
16-
List<String> input = List.of(
17-
"ID\tFirstName\tLastName\tScore\tSpend",
18-
"1\tFred\tFlintstone\t11\t1000.00",
19-
"4\tBetty\tRubble\t10\t2000.00",
20-
"2\tBarney\tRubble\t0\t20.00",
21-
"3\tWilma\tFlintstone\t9\t0.00"
22-
);
23-
List<String> expected = List.of(
24-
"ID\tName\tSpend",
25-
"4\tRUBBLE, Betty\t2000.00",
26-
"1\tFLINTSTONE, Fred\t1000.00",
27-
"\tTOTAL\t3000.00"
28-
);
29-
check(input, expected);
11+
fun test() {
12+
check(
13+
inputLines = listOf(
14+
"ID\tFirstName\tLastName\tScore\tSpend",
15+
"1\tFred\tFlintstone\t11\t1000.00",
16+
"4\tBetty\tRubble\t10\t2000.00",
17+
"2\tBarney\tRubble\t0\t20.00",
18+
"3\tWilma\tFlintstone\t9\t0.00"
19+
),
20+
expectedLines = listOf(
21+
"ID\tName\tSpend",
22+
"4\tRUBBLE, Betty\t2000.00",
23+
"1\tFLINTSTONE, Fred\t1000.00",
24+
"\tTOTAL\t3000.00"
25+
)
26+
)
3027
}
3128

29+
3230
@Test
33-
public void emptyTest() throws IOException {
34-
List<String> input = List.of(
35-
"ID\tFirstName\tLastName\tScore\tSpend"
36-
);
37-
List<String> expected = List.of(
38-
"ID\tName\tSpend",
39-
"\tTOTAL\t0.00"
40-
);
41-
check(input, expected);
31+
fun emptyTest() {
32+
check(
33+
inputLines = listOf(
34+
"ID\tFirstName\tLastName\tScore\tSpend"
35+
),
36+
expectedLines = listOf(
37+
"ID\tName\tSpend",
38+
"\tTOTAL\t0.00"
39+
)
40+
)
4241
}
4342

4443
@Test
45-
public void emptySpendIs0() {
44+
fun emptySpendIs0() {
4645
assertEquals(
47-
new CustomerData("1", "Fred", "Flintstone", 0, 0D),
48-
HighValueCustomersReportKt.toCustomerData("1\tFred\tFlintstone\t0")
49-
);
46+
CustomerData("1", "Fred", "Flintstone", 0, 0.0),
47+
"1\tFred\tFlintstone\t0".toCustomerData()
48+
)
5049
}
5150

52-
private void check(
53-
List<String> inputLines,
54-
List<String> expectedLines
55-
) throws IOException {
56-
var output = new StringWriter();
57-
HighValueCustomersReportKt.generate(
58-
new StringReader(String.join("\n", inputLines)),
51+
private fun check(
52+
inputLines: List<String>,
53+
expectedLines: List<String>
54+
) {
55+
val output = StringWriter()
56+
generate(
57+
StringReader(inputLines.joinToString("\n")),
5958
output
60-
);
61-
assertEquals(String.join("\n", expectedLines), output.toString());
59+
)
60+
assertEquals(expectedLines.joinToString("\n"), output.toString())
6261
}
6362
}

0 commit comments

Comments
 (0)
0