|
@@ -5,13 +5,11 @@ import org.junit.Test;
|
5
|
5
|
import static org.junit.Assert.*;
|
6
|
6
|
|
7
|
7
|
public class HamletParserTest {
|
8
|
|
- private String hamletText;
|
9
|
8
|
private HamletParser hamletParser;
|
10
|
9
|
|
11
|
10
|
@Before
|
12
|
11
|
public void setUp() {
|
13
|
12
|
this.hamletParser = new HamletParser();
|
14
|
|
- this.hamletText = hamletParser.getHamletData();
|
15
|
13
|
}
|
16
|
14
|
|
17
|
15
|
@Test
|
|
@@ -19,88 +17,54 @@ public class HamletParserTest {
|
19
|
17
|
//GIVEN
|
20
|
18
|
|
21
|
19
|
//WHEN
|
22
|
|
- String expected = "The Tragedy of Leon, Prince of Denmark\nTARIK\n";
|
|
20
|
+ String expected = "The Tragedy of Leon, Prince of Denmark\nTarik\n";
|
23
|
21
|
//THEN
|
24
|
22
|
String actual = hamletParser.loadFile("hamletTest.txt");
|
25
|
23
|
Assert.assertEquals(expected, actual);
|
26
|
24
|
|
27
|
|
- // the file to output, then test output for 'has hamlet or horatio
|
28
|
25
|
}
|
29
|
26
|
|
30
|
|
-// @Test
|
31
|
|
-// public void testChangeHamletToLeon() {
|
32
|
|
-// //GIVEN
|
33
|
|
-//
|
34
|
|
-// //WHEN
|
35
|
|
-// String expected = "Leon";
|
36
|
|
-// //THEN
|
37
|
|
-// String actual = hamletParser.changeHamletToLeon();
|
38
|
|
-// Assert.assertEquals(expected, actual);
|
39
|
|
-// }
|
40
|
|
-//
|
41
|
|
-// @Test
|
42
|
|
-// public void testChangeHoratioToTariq() {
|
43
|
|
-// //GIVEN
|
44
|
|
-//
|
45
|
|
-// //WHEN
|
46
|
|
-// String expected = "Tariq";
|
47
|
|
-// //THEN
|
48
|
|
-// String actual = hamletParser.changeChangeHoratioToTariq();
|
49
|
|
-// Assert.assertEquals(expected, actual);
|
50
|
|
-// }
|
51
|
|
-//
|
52
|
|
-// @Test
|
53
|
|
-// public void testFindHoratio() {
|
54
|
|
-// //GIVEN
|
55
|
|
-// String input = "horatio";
|
56
|
|
-// //WHEN
|
57
|
|
-// boolean expected = true;
|
58
|
|
-// //THEN
|
59
|
|
-// boolean actual = hamletParser.findHoratio(input);
|
60
|
|
-// Assert.assertEquals(expected, actual);
|
61
|
|
-// }
|
62
|
|
-//
|
63
|
|
-// @Test
|
64
|
|
-// public void testFindHamlet() {
|
65
|
|
-// //GIVEN
|
66
|
|
-// String input = "HAMLET";
|
67
|
|
-// //WHEN
|
68
|
|
-// boolean expected = true;
|
69
|
|
-// //THEN
|
70
|
|
-// boolean actual = hamletParser.findHamlet(input);
|
71
|
|
-// Assert.assertEquals(expected, actual);
|
72
|
|
-// }
|
73
|
|
-//
|
74
|
|
-// @Test
|
75
|
|
-// public void testFindHoratio2() {
|
76
|
|
-// //GIVEN
|
77
|
|
-// String input = "nope";
|
78
|
|
-// //WHEN
|
79
|
|
-// boolean expected = false;
|
80
|
|
-// //THEN
|
81
|
|
-// boolean actual = hamletParser.findHoratio(input);
|
82
|
|
-// Assert.assertEquals(expected, actual);
|
83
|
|
-// }
|
84
|
|
-//
|
85
|
|
-// @Test
|
86
|
|
-// public void testFindHamlet2() {
|
87
|
|
-// //GIVEN
|
88
|
|
-// String input = "hhamlet";
|
89
|
|
-// //WHEN
|
90
|
|
-// boolean expected = false;
|
91
|
|
-// //THEN
|
92
|
|
-// boolean actual = hamletParser.findHamlet(input);
|
93
|
|
-// Assert.assertEquals(expected, actual);
|
94
|
|
-// }
|
95
|
|
-
|
96
|
27
|
@Test
|
97
|
28
|
public void hamletReplaceTest() {
|
98
|
29
|
//GIVEN
|
99
|
30
|
String input = "Hamlet Horatio hamlet horatio HAMLET HORATIO";
|
100
|
31
|
//WHEN
|
101
|
|
- String expected = "Leon Tarik leon tarik LEON TARIK";
|
|
32
|
+ String expected = "Leon Tarik Leon Tarik Leon Tarik";
|
102
|
33
|
//THEN
|
103
|
34
|
String actual = hamletParser.replaceHamletAndHoratio(input);
|
104
|
35
|
Assert.assertEquals(expected, actual);
|
105
|
36
|
}
|
106
|
|
-}
|
|
37
|
+
|
|
38
|
+ @Test
|
|
39
|
+ public void getHamletFile() {
|
|
40
|
+ //GIVEN
|
|
41
|
+
|
|
42
|
+ //WHEN
|
|
43
|
+ String expected = "hamlet.txt";
|
|
44
|
+ //THEN
|
|
45
|
+ String actual = hamletParser.getHamletFile();
|
|
46
|
+ Assert.assertEquals(expected, actual);
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ @Test
|
|
50
|
+ public void openOutFileTest() {
|
|
51
|
+ //GIVEN
|
|
52
|
+
|
|
53
|
+ //WHEN
|
|
54
|
+ boolean expected = true;
|
|
55
|
+ //THEN
|
|
56
|
+ boolean actual = hamletParser.openOutFile("text.txt");
|
|
57
|
+ Assert.assertEquals(expected, actual);
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ @Test
|
|
61
|
+ public void openOutFileTest2() {
|
|
62
|
+ //GIVEN
|
|
63
|
+
|
|
64
|
+ //WHEN
|
|
65
|
+ boolean expected = false;
|
|
66
|
+ //THEN
|
|
67
|
+ boolean actual = hamletParser.openOutFile("");
|
|
68
|
+ Assert.assertEquals(expected, actual);
|
|
69
|
+ }
|
|
70
|
+}
|