|
@@ -26,6 +26,11 @@ public class ItemParserTest {
|
26
|
26
|
+"naME:BreaD;price:3.23;type:Food;expiration:1/02/2016##"
|
27
|
27
|
+"NAMe:BrEAD;price:1.23;type:Food;expiration:2/25/2016##";
|
28
|
28
|
|
|
29
|
+ private String rawMultipleItems3 = "naMe:Milk;price:3.23;type:Food;expiration:1/25/2016##"
|
|
30
|
+ +"naME:BreaD;price:3.23;type:Food;expiration:1/02/2016##"
|
|
31
|
+ +"naME:BreaD;price:3.23;type:Food;expiration:1/02/2016##"
|
|
32
|
+ +"NAMe:BrEAD;price:1.23;type:Food;expiration:2/25/2016##";
|
|
33
|
+
|
29
|
34
|
private ItemParser itemParser;
|
30
|
35
|
|
31
|
36
|
@Before
|
|
@@ -98,6 +103,19 @@ public class ItemParserTest {
|
98
|
103
|
}
|
99
|
104
|
|
100
|
105
|
@Test
|
|
106
|
+ public void itemNameAndCountAsString() throws ItemParseException {
|
|
107
|
+ // Given
|
|
108
|
+ String nameForBread = "bread";
|
|
109
|
+ String expectedNameAndCount = "name: Bread\t\tseen: 3 times";
|
|
110
|
+ itemParser.parseRawDataIntoItemStringArray(rawMultipleItems3);
|
|
111
|
+ itemParser.createItems();
|
|
112
|
+ // When
|
|
113
|
+ itemParser.addNameAndItemsOfSameNameToItemOrganizer();
|
|
114
|
+ String actualNameAndCount = "";
|
|
115
|
+ // Then
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ @Test
|
101
|
119
|
public void getPricesAndTheirCountTest() throws ItemParseException {
|
102
|
120
|
// Given
|
103
|
121
|
String nameForBread = "bread";
|
|
@@ -120,20 +138,18 @@ public class ItemParserTest {
|
120
|
138
|
public void pricesAndTheirCountAsStringTest() throws ItemParseException {
|
121
|
139
|
// Given
|
122
|
140
|
String nameForBread = "bread";
|
123
|
|
- itemParser.parseRawDataIntoItemStringArray(rawMultipleItems2);
|
|
141
|
+ itemParser.parseRawDataIntoItemStringArray(rawMultipleItems3);
|
124
|
142
|
itemParser.createItems();
|
125
|
143
|
itemParser.addNameAndItemsOfSameNameToItemOrganizer();
|
126
|
144
|
String expectedPricesAndTheirCount = "=============\t\t=============\n" +
|
127
|
|
- "Price: " + 3.23 + "\t\tseen: " + 5 + " " + "times" + "\n" +
|
|
145
|
+ "Price: " + "3.23" + "\t\tseen: " + "2" + " " + "times" + "\n" +
|
128
|
146
|
"-------------\t\t-------------\n" +
|
129
|
|
- "Price: " + 1.23 + "\t\tseen: " + 1 + " " + "time" + "\n" +
|
|
147
|
+ "Price: " + "1.23" + "\t\tseen: " + "1" + " " + "time" + "\n" +
|
130
|
148
|
"-------------\t\t-------------";
|
131
|
149
|
// When
|
132
|
|
- int actual323Count = itemParser.getPricesAndTheirCount(nameForBread).get(expected323Price);
|
133
|
|
- int actual123Count = itemParser.getPricesAndTheirCount(nameForBread).get(expected123Price);
|
|
150
|
+ String actualPATC = itemParser.pricesAndTheirCountAsString(itemParser.getPricesAndTheirCount(nameForBread));
|
134
|
151
|
// Then
|
135
|
|
- Assert.assertEquals(expected323Count, actual323Count);
|
136
|
|
- Assert.assertEquals(expected123Count, actual123Count);
|
|
152
|
+ Assert.assertEquals(expectedPricesAndTheirCount, actualPATC);
|
137
|
153
|
}
|
138
|
154
|
|
139
|
155
|
@Test
|