1
- package travelator.marketing ;
1
+ package travelator.marketing
2
2
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
11
7
12
8
class HighValueCustomersReportTests {
13
9
14
10
@Test
15
- public void test() throws IOException {
16
- List <String > input = List .of(
17
- " ID\t FirstName\t LastName\t Score\t Spend" ,
18
- " 1\t Fred\t Flintstone\t 11\t 1000.00" ,
19
- " 4\t Betty\t Rubble\t 10\t 2000.00" ,
20
- " 2\t Barney\t Rubble\t 0\t 20.00" ,
21
- " 3\t Wilma\t Flintstone\t 9\t 0.00"
22
- );
23
- List <String > expected = List .of(
24
- " ID\t Name\t Spend" ,
25
- " 4\t RUBBLE, Betty\t 2000.00" ,
26
- " 1\t FLINTSTONE, Fred\t 1000.00" ,
27
- " \t TOTAL\t 3000.00"
28
- );
29
- check(input, expected);
11
+ fun test () {
12
+ check(
13
+ inputLines = listOf (
14
+ " ID\t FirstName\t LastName\t Score\t Spend" ,
15
+ " 1\t Fred\t Flintstone\t 11\t 1000.00" ,
16
+ " 4\t Betty\t Rubble\t 10\t 2000.00" ,
17
+ " 2\t Barney\t Rubble\t 0\t 20.00" ,
18
+ " 3\t Wilma\t Flintstone\t 9\t 0.00"
19
+ ),
20
+ expectedLines = listOf (
21
+ " ID\t Name\t Spend" ,
22
+ " 4\t RUBBLE, Betty\t 2000.00" ,
23
+ " 1\t FLINTSTONE, Fred\t 1000.00" ,
24
+ " \t TOTAL\t 3000.00"
25
+ )
26
+ )
30
27
}
31
28
29
+
32
30
@Test
33
- public void emptyTest() throws IOException {
34
- List <String > input = List .of(
35
- " ID\t FirstName\t LastName\t Score\t Spend"
36
- );
37
- List <String > expected = List .of(
38
- " ID\t Name\t Spend" ,
39
- " \t TOTAL\t 0.00"
40
- );
41
- check(input, expected);
31
+ fun emptyTest () {
32
+ check(
33
+ inputLines = listOf (
34
+ " ID\t FirstName\t LastName\t Score\t Spend"
35
+ ),
36
+ expectedLines = listOf (
37
+ " ID\t Name\t Spend" ,
38
+ " \t TOTAL\t 0.00"
39
+ )
40
+ )
42
41
}
43
42
44
43
@Test
45
- public void emptySpendIs0() {
44
+ fun emptySpendIs0 () {
46
45
assertEquals(
47
- new CustomerData (" 1" , " Fred" , " Flintstone" , 0 , 0D ),
48
- HighValueCustomersReportKt .toCustomerData( " 1\t Fred\t Flintstone\t 0" )
49
- );
46
+ CustomerData (" 1" , " Fred" , " Flintstone" , 0 , 0.0 ),
47
+ " 1\t Fred\t Flintstone\t 0" .toCustomerData( )
48
+ )
50
49
}
51
50
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 " )),
59
58
output
60
- );
61
- assertEquals(String .join (" \n " , expectedLines ), output.toString());
59
+ )
60
+ assertEquals(expectedLines.joinToString (" \n " ), output.toString())
62
61
}
63
62
}
0 commit comments