Browse Source

Merge 5a2fc8abe75eacee79af155b68620632afa4888f into 23c2c01bf07b924ac9b860fa2771bf6ceb246ad5

PeterMcCormick 6 years ago
parent
commit
9bc57b2363
No account linked to committer's email

+ 6
- 0
pom.xml View File

@@ -8,6 +8,11 @@
8 8
     <artifactId>PainfullAfternoon</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10 10
 
11
+    <properties>
12
+        <maven.compiler.source>1.8</maven.compiler.source>
13
+        <maven.compiler.target>1.8</maven.compiler.target>
14
+    </properties>
15
+
11 16
     <dependencies>
12 17
         <dependency>
13 18
             <groupId>junit</groupId>
@@ -19,5 +24,6 @@
19 24
             <artifactId>org.apache.commons.io</artifactId>
20 25
             <version>2.4</version>
21 26
         </dependency>
27
+
22 28
     </dependencies>
23 29
 </project>

+ 1
- 1
src/main/java/io/zipcoder/Item.java View File

@@ -43,6 +43,6 @@ public class Item {
43 43
 
44 44
     @Override
45 45
     public String toString(){
46
-        return "name:" + name + " price:" + price + " type:" + type + " expiration:" + expiration;
46
+        return "name:" + name + " Price:" + price + " type:" + type + " expiration:" + expiration;
47 47
     }
48 48
 }

+ 1
- 0
src/main/java/io/zipcoder/ItemParseException.java View File

@@ -1,4 +1,5 @@
1 1
 package io.zipcoder;
2 2
 
3 3
 public class ItemParseException extends Exception {
4
+
4 5
 }

+ 142
- 12
src/main/java/io/zipcoder/ItemParser.java View File

@@ -1,31 +1,161 @@
1 1
 package io.zipcoder;
2 2
 
3
-import java.util.ArrayList;
4
-import java.util.Arrays;
3
+import java.util.*;
4
+import java.util.regex.Matcher;
5
+import java.util.regex.Pattern;
5 6
 
6 7
 public class ItemParser {
7 8
 
9
+    Pattern pattern;
10
+    Matcher matcher;
11
+    Integer countExceptionsThrown = 0;
8 12
 
9
-    public ArrayList<String> parseRawDataIntoStringArray(String rawData){
13
+    HashMap<Double, Integer> priceOccurrence;
14
+    HashMap<String, ArrayList<Double>> namePrice = new HashMap<>();
15
+
16
+    private ArrayList<String> splitStringWithRegexPattern(String stringPattern, String inputString) {
17
+        return new ArrayList<String>(Arrays.asList(inputString.split(stringPattern)));
18
+    }
19
+
20
+    public ArrayList<String> parseRawDataIntoStringArray(String rawData) {
10 21
         String stringPattern = "##";
11
-        ArrayList<String> response = splitStringWithRegexPattern(stringPattern , rawData);
22
+        ArrayList<String> response = splitStringWithRegexPattern(stringPattern, rawData);
12 23
         return response;
13 24
     }
14 25
 
15
-    public Item parseStringIntoItem(String rawItem) throws ItemParseException{
16
-        return null;
26
+    public Integer getExceptionsThrown() {
27
+
28
+        return this.countExceptionsThrown;
29
+    }
30
+
31
+    public Item parseStringIntoItem(String rawItem) throws ItemParseException {
32
+
33
+        String name = checkName(rawItem);
34
+        Double price = Double.valueOf(checkPrice(rawItem));
35
+        String type = checkType(rawItem);
36
+        String expiration = checkExpiration(rawItem);
37
+        getNamePrice(name, price);
38
+        return new Item(name, price, type, expiration);
39
+
17 40
     }
18 41
 
19
-    public ArrayList<String> findKeyValuePairsInRawItemData(String rawItem){
20
-        String stringPattern = "[;|^]";
21
-        ArrayList<String> response = splitStringWithRegexPattern(stringPattern , rawItem);
42
+    public ArrayList<String> findKeyValuePairsInRawItemData(String rawItem) {
43
+        String stringPattern = "[@|;|^|%|*]";
44
+        ArrayList<String> response = splitStringWithRegexPattern(stringPattern, rawItem);
22 45
         return response;
23 46
     }
24 47
 
25
-    private ArrayList<String> splitStringWithRegexPattern(String stringPattern, String inputString){
26
-        return new ArrayList<String>(Arrays.asList(inputString.split(stringPattern)));
48
+
49
+    public String checkName(String input) throws ItemParseException {
50
+
51
+        Pattern patternName = Pattern.compile("([Nn]..[Ee]:)([a-zA-Z\\s|\\d|\\-|_]+)");
52
+
53
+        Matcher matcherName = patternName.matcher(input);
54
+
55
+        if (matcherName.find()) {
56
+            String temp = matcherName.group(2).substring(0, 1).toUpperCase() +
57
+                    matcherName.group(2).substring(1).toLowerCase();
58
+            if (temp.contains("0"))
59
+                return temp.replace('0', 'o');
60
+            return temp;
61
+        }
62
+        else {
63
+            countExceptionsThrown++;
64
+            throw new ItemParseException();
65
+        }
66
+
27 67
     }
28 68
 
69
+    public String checkPrice(String input) throws ItemParseException {
70
+        Pattern patternPrice = Pattern.compile("([Pp]...[Ee]:)(\\d{1,6}\\.\\d{2})");
71
+        Matcher matcherPrice = patternPrice.matcher(input);
72
+
73
+        if (matcherPrice.find())
74
+            return matcherPrice.group(2);
75
+        else {
76
+            countExceptionsThrown++;
77
+            throw new ItemParseException();
78
+        }
79
+    }
80
+
81
+
82
+    public String checkType(String input) throws ItemParseException {
83
+        Pattern patternType = Pattern.compile("([Tt]..[Ee]:)(\\w+)");
84
+        Matcher matcherType = patternType.matcher(input);
85
+
86
+        if (matcherType.find())
87
+            return matcherType.group(2).toLowerCase();
88
+        else {
89
+            countExceptionsThrown++;
90
+            throw new ItemParseException();
91
+        }
92
+    }
93
+
94
+    public String checkExpiration(String input) throws ItemParseException {
95
+        Pattern patternExpiration = Pattern.compile("([Ee]........[Nn]:)(\\d{1,2}\\/\\d{2}\\/\\d{4})");
96
+        Matcher matcherExpiration = patternExpiration.matcher(input);
97
+
98
+        if (matcherExpiration.find())
99
+            return matcherExpiration.group(2);
100
+        else {
101
+            countExceptionsThrown++;
102
+            throw new ItemParseException();
103
+        }
104
+    }
105
+
106
+
107
+    public void getNamePrice(String name, Double price) {
108
+        if (!namePrice.containsKey(name)) {
109
+            namePrice.put(name, new ArrayList<>());
110
+            namePrice.get(name).add(price);
111
+        } else {
112
+            namePrice.get(name).add(price);
113
+        }
114
+    }
115
+
116
+    public HashMap<Double, Integer> getPriceOccurrence(String name) {
117
+        ArrayList<Double> prices = namePrice.get(name);
118
+        priceOccurrence = new HashMap<>();
119
+        for (int i = 0; i < prices.size(); i++) {
120
+            double price = prices.get(i);
121
+            if (!priceOccurrence.containsKey(prices.get(i))) {
122
+                priceOccurrence.put(price, 1);
123
+            } else {
124
+                priceOccurrence.put(price, priceOccurrence.get(price) + 1);
125
+            }
126
+        }
127
+        return priceOccurrence;
128
+    }
129
+
130
+    public HashMap<String, ArrayList<Double>> getNamePrice() {
131
+        return namePrice;
132
+    }
133
+
134
+
135
+   public static void main(String[] args) {
136
+       ItemParser itemParser = new ItemParser();
137
+       System.out.println(itemParser.getExceptionsThrown());
138
+   }
139
+//        HashMap<String, ArrayList<Double>> map = new HashMap<>();
140
+//        String item = "Milk";
141
+//        ArrayList<Double> prices = new ArrayList<>();
142
+//
143
+//        Double one = 2.15;
144
+//        Double two = 3.15;
145
+//        Double three = 3.21;
146
+//        Double four = 2.45;
147
+//
148
+//        prices.add(one);
149
+//        prices.add(two);
150
+//        prices.add(three);
151
+//        prices.add(four);
152
+//
153
+//        map.put(item, prices);
154
+//        ItemParser itemParser = new ItemParser();
155
+//
156
+//        System.out.println(itemParser.getPriceOccurrence(map, item));
157
+//
158
+//    }
29 159
 
30 160
 
31
-}
161
+}

+ 74
- 4
src/main/java/io/zipcoder/Main.java View File

@@ -2,18 +2,88 @@ package io.zipcoder;
2 2
 
3 3
 import org.apache.commons.io.IOUtils;
4 4
 
5
+import java.util.ArrayList;
6
+import java.util.HashMap;
7
+import java.util.Iterator;
8
+
5 9
 
6 10
 public class Main {
7 11
 
8
-    public String readRawDataToString() throws Exception{
12
+    ItemParser hurtLocker;
13
+    ArrayList<String> groceryAccountedFor;
14
+
15
+    public Main() {
16
+        hurtLocker = new ItemParser();
17
+        groceryAccountedFor = new ArrayList<>();
18
+    }
19
+
20
+    public String readRawDataToString(String file) throws Exception{
9 21
         ClassLoader classLoader = getClass().getClassLoader();
10
-        String result = IOUtils.toString(classLoader.getResourceAsStream("RawData.txt"));
11
-        return result;
22
+        String result = IOUtils.toString(classLoader.getResourceAsStream(file));
23
+
24
+        ArrayList<String> rawDataToString = hurtLocker.parseRawDataIntoStringArray(result);
25
+        ArrayList<ArrayList<String>> namePriceTypeExpiration = new ArrayList<>();
26
+
27
+        for (String itemInfo : rawDataToString) {
28
+            namePriceTypeExpiration.add(hurtLocker.findKeyValuePairsInRawItemData(itemInfo));
29
+        }
30
+
31
+        for (ArrayList<String> aLS: namePriceTypeExpiration)
32
+            try {
33
+                Item newItem = hurtLocker.parseStringIntoItem(aLS.toString());
34
+                if(!groceryAccountedFor.contains(newItem.getName())) {
35
+                    groceryAccountedFor.add(newItem.getName());
36
+                }
37
+
38
+            } catch (ItemParseException e) {
39
+
40
+            }
41
+        return groceryListFormat();
42
+    }
43
+
44
+    public String groceryListFormat() {
45
+        StringBuilder sb = new StringBuilder();
46
+        for (String item : groceryAccountedFor) {
47
+            int timesSeen = hurtLocker.namePrice.get(item).size();
48
+            sb.append(String.format("name:%8s        seen:%2d %s\n", item, timesSeen, timeOrTimes(timesSeen)));
49
+            sb.append(String.format("=============        =============\n"));
50
+            sb.append(countOccurrences(item));
51
+            sb.append("\n");
52
+        }
53
+        int errorCount = hurtLocker.getExceptionsThrown();
54
+        sb.append(String.format("Errors               seen:%2d %s\n", errorCount, timeOrTimes(errorCount)));
55
+        return sb.toString();
56
+    }
57
+    public String countOccurrences(String item) {
58
+        StringBuilder sb = new StringBuilder();
59
+        HashMap<Double, Integer> priceOccurrence = hurtLocker.getPriceOccurrence(item);
60
+        Iterator<Double> itemPriceIterator = priceOccurrence.keySet().iterator();
61
+        int count = 0;
62
+        while (itemPriceIterator.hasNext()) {
63
+            count++;
64
+            Double price = itemPriceIterator.next();
65
+            sb.append(String.format("Price:%7.2f        seen:%2d %s\n", price, priceOccurrence.get(price), timeOrTimes(priceOccurrence.get(price))));
66
+            if (itemPriceIterator.hasNext() && count > 1) sb.append(String.format("-------------        -------------\n"));
67
+            if (count == 1) sb.append(String.format("-------------        -------------\n"));
68
+        }
69
+        return sb.toString();
70
+    }
71
+
72
+    public String timeOrTimes(int timesSeen) {
73
+        String times;
74
+        if (timesSeen == 1) return "time";
75
+        else return "times";
12 76
     }
13 77
 
14 78
     public static void main(String[] args) throws Exception{
15
-        String output = (new Main()).readRawDataToString();
79
+
80
+        Main main = new Main();
81
+        String output = main.readRawDataToString("RawData.txt");
16 82
         System.out.println(output);
83
+
84
+
85
+
17 86
         // TODO: parse the data in output into items, and display to console.
87
+
18 88
     }
19 89
 }

+ 28
- 0
src/main/resources/TestData.txt View File

@@ -0,0 +1,28 @@
1
+naMe:MRShMll0;price:3.23;type:Food;expiration:10/25/2022
2
+                ##naME:c0cAC0la;price:1.23;type:Food;expiration:1/02/2016
3
+                ##NAMe:PREtzels;price:1.23;type:Food;expiration:2/25/2016
4
+                ##naMe:MiLK;price:3.23;type:Food^expiration:1/11/2016
5
+                ##naMe:TwINKies;price:4.25;type:Food%expiration:1/25/2016
6
+                ##naMe:3DozEggs;price:2.25;type:Food*expiration:1/25/2016
7
+                ##naMe:PANCKEMX;price:1.25;type:Food;expiration:3/22/2016
8
+                ##naMe:COOkieS;price:2.25;type:Food;expiration:1/25/2016
9
+                ##NAME:2lbShrmp;price:3.23;type:Food;expiration:1/17/2016
10
+                ##naMe:Snpple24;price:10.23;type:Food!expiration:4/25/2016
11
+                ##naMe:aplJaX;price:0.25;type:Food;expiration:1/23/2016
12
+                ##naMe:aplJAx;price:0.23;type:Food;expiration:5/02/2016
13
+                ##NAMe:;price:1.23;type:Food;expiration:1/25/2016
14
+                ##naMe:;price:3.23;type:Food;expiration:1/04/2016
15
+                ##naMe:Milk;price:3.23;type:Food;expiration:1/25/2016
16
+                ##naME:BreaD;price:1.23;type:Food@expiration:1/02/2016
17
+                ##NAMe:BrEAD;price:1.23;type:Food@expiration:2/25/2016
18
+                ##naMe:MiLK;priCe:;type:Food;expiration:1/11/2016
19
+                ##naMe:Cookies;price:2.15;type:Food;expiration:1/25/2016
20
+                ##naMe:Co0kieS;pRice:2.25;type:Food;expiration:1/25/2016
21
+                ##naMe:COokIes;price:2.45;type:Food;expiration:3/22/2016
22
+                ##naMe:COOkieS;Price:2.25;type:Food;expiration:1/25/2016
23
+                ##NAME:MilK;price:3.23;type:Food;expiration:1/17/2016
24
+                ##naMe:MilK;priCe:;type:Food;expiration:4/25/2016
25
+                ##naMe:apPles;prIce:0.25;type:Food;expiration:1/23/2016
26
+                ##naMe:apPles;pRice:0.23;type:Food;expiration:5/02/2016
27
+                ##NAMe:BrEAD;price:1.23;type:Food;expiration:1/25/2016
28
+                ##naMe:;price:3.23;type:Food^expiration:1/04/2016##

+ 34
- 12
src/test/java/io/zipcoder/ItemParserTest.java View File

@@ -1,33 +1,38 @@
1 1
 package io.zipcoder;
2 2
 
3
-import org.junit.Assert;
3
+
4 4
 import org.junit.Before;
5 5
 import org.junit.Test;
6 6
 
7
+
7 8
 import java.util.ArrayList;
8 9
 
9 10
 import static org.junit.Assert.*;
10 11
 
11 12
 public class ItemParserTest {
12 13
 
13
-    private String rawSingleItem =    "naMe:Milk;price:3.23;type:Food;expiration:1/25/2016##";
14
+    private String rawSingleItem = "naMe:Milk;price:3.23;type:Food;expiration:1/25/2016##";
14 15
 
15 16
     private String rawSingleItemIrregularSeperatorSample = "naMe:MiLK;price:3.23;type:Food^expiration:1/11/2016##";
16 17
 
17
-    private String rawBrokenSingleItem =    "naMe:Milk;price:3.23;type:Food;expiration:1/25/2016##";
18
+    private String rawBrokenSingleItem = "naMe:;price:3.23;type:Food;expiration:1/25/2016##";
18 19
 
19 20
     private String rawMultipleItems = "naMe:Milk;price:3.23;type:Food;expiration:1/25/2016##"
20
-                                      +"naME:BreaD;price:1.23;type:Food;expiration:1/02/2016##"
21
-                                      +"NAMe:BrEAD;price:1.23;type:Food;expiration:2/25/2016##";
21
+            + "naME:BreaD;price:1.23;type:Food;expiration:1/02/2016##"
22
+            + "NAMe:BrEAD;price:1.23;type:Food;expiration:2/25/2016##";
23
+
24
+    private String getRawMultipleBrokenItems = "naMe:;price:3.23;type:Food;expiration:1/25/2016##"
25
+            + "naME:BreaD;price:1.23;type:;expiration:1/02/2016##"
26
+            + "NAMe:BrEAD;price:;type:Food;expiration:2/25/2016##";
22 27
     private ItemParser itemParser;
23 28
 
24 29
     @Before
25
-    public void setUp(){
30
+    public void setUp() {
26 31
         itemParser = new ItemParser();
27 32
     }
28 33
 
29 34
     @Test
30
-    public void parseRawDataIntoStringArrayTest(){
35
+    public void parseRawDataIntoStringArrayTest() {
31 36
         Integer expectedArraySize = 3;
32 37
         ArrayList<String> items = itemParser.parseRawDataIntoStringArray(rawMultipleItems);
33 38
         Integer actualArraySize = items.size();
@@ -35,28 +40,45 @@ public class ItemParserTest {
35 40
     }
36 41
 
37 42
     @Test
38
-    public void parseStringIntoItemTest() throws ItemParseException{
39
-        Item expected = new Item("milk", 3.23, "food","1/25/2016");
43
+    public void parseStringIntoItemTest() throws ItemParseException {
44
+        Item expected = new Item("milk", 3.23, "food", "1/25/2016");
40 45
         Item actual = itemParser.parseStringIntoItem(rawSingleItem);
46
+        System.out.println(actual);
47
+        assertEquals(expected.toString(), actual.toString());
48
+    }
49
+
50
+    @Test
51
+    public void parseStringIntoItemTest1() throws ItemParseException {
52
+        Item expected = new Item("root-_beer", 232321.34, "drink", "12/23/2019");
53
+        Item actual = itemParser.parseStringIntoItem("NAME:ro0t-_beer;pRICE:232321.34;type:dRiNK;expiration:12/23/2019");
54
+        System.out.println(actual.toString());
41 55
         assertEquals(expected.toString(), actual.toString());
42 56
     }
43 57
 
44 58
     @Test(expected = ItemParseException.class)
45
-    public void parseBrokenStringIntoItemTest() throws ItemParseException{
59
+    public void parseBrokenStringIntoItemTest() throws ItemParseException {
46 60
         itemParser.parseStringIntoItem(rawBrokenSingleItem);
47 61
     }
48 62
 
49 63
     @Test
50
-    public void findKeyValuePairsInRawItemDataTest(){
64
+    public void findKeyValuePairsInRawItemDataTest() {
51 65
         Integer expected = 4;
52 66
         Integer actual = itemParser.findKeyValuePairsInRawItemData(rawSingleItem).size();
53 67
         assertEquals(expected, actual);
54 68
     }
55 69
 
56 70
     @Test
57
-    public void findKeyValuePairsInRawItemDataTestIrregular(){
71
+    public void findKeyValuePairsInRawItemDataTestIrregular() {
58 72
         Integer expected = 4;
59 73
         Integer actual = itemParser.findKeyValuePairsInRawItemData(rawSingleItemIrregularSeperatorSample).size();
60 74
         assertEquals(expected, actual);
61 75
     }
76
+
77
+//    @Test
78
+//    public void countExceptionTest() {
79
+//        Integer expected = 3;
80
+//        Integer actual = itemParser.getExceptionsThrown(getRawMultipleBrokenItems);
81
+//        assertEquals(expected, actual);
82
+//    }
83
+
62 84
 }

+ 188
- 0
src/test/java/io/zipcoder/MainTest.java View File

@@ -0,0 +1,188 @@
1
+package io.zipcoder;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+public class MainTest {
8
+
9
+    private Main mainTest = new Main();
10
+    @Before
11
+    public void Setup() {
12
+
13
+
14
+
15
+        String originalRawData = "naMe:Milk;price:3.23;type:Food;expiration:1/25/2016" +
16
+                "##naME:BreaD;price:1.23;type:Food;expiration:1/02/2016" +
17
+                "##NAMe:BrEAD;price:1.23;type:Food;expiration:2/25/2016" +
18
+                "##naMe:MiLK;price:3.23;type:Food^expiration:1/11/2016" +
19
+                "##naMe:Cookies;price:2.25;type:Food%expiration:1/25/2016" +
20
+                "##naMe:CoOkieS;price:2.25;type:Food*expiration:1/25/2016" +
21
+                "##naMe:COokIes;price:2.25;type:Food;expiration:3/22/2016" +
22
+                "##naMe:COOkieS;price:2.25;type:Food;expiration:1/25/2016" +
23
+                "##NAME:MilK;price:3.23;type:Food;expiration:1/17/2016" +
24
+                "##naMe:MilK;price:1.23;type:Food!expiration:4/25/2016" +
25
+                "##naMe:apPles;price:0.25;type:Food;expiration:1/23/2016" +
26
+                "##naMe:apPles;price:0.23;type:Food;expiration:5/02/2016" +
27
+                "##NAMe:BrEAD;price:1.23;type:Food;expiration:1/25/2016" +
28
+                "##naMe:;price:3.23;type:Food;expiration:1/04/2016" +
29
+                "##naMe:Milk;price:3.23;type:Food;expiration:1/25/2016" +
30
+                "##naME:BreaD;price:1.23;type:Food@expiration:1/02/2016" +
31
+                "##NAMe:BrEAD;price:1.23;type:Food@expiration:2/25/2016" +
32
+                "##naMe:MiLK;priCe:;type:Food;expiration:1/11/2016" +
33
+                "##naMe:Cookies;price:2.25;type:Food;expiration:1/25/2016" +
34
+                "##naMe:Co0kieS;pRice:2.25;type:Food;expiration:1/25/2016" +
35
+                "##naMe:COokIes;price:2.25;type:Food;expiration:3/22/2016" +
36
+                "##naMe:COOkieS;Price:2.25;type:Food;expiration:1/25/2016" +
37
+                "##NAME:MilK;price:3.23;type:Food;expiration:1/17/2016" +
38
+                "##naMe:MilK;priCe:;type:Food;expiration:4/25/2016" +
39
+                "##naMe:apPles;prIce:0.25;type:Food;expiration:1/23/2016" +
40
+                "##naMe:apPles;pRice:0.23;type:Food;expiration:5/02/2016" +
41
+                "##NAMe:BrEAD;price:1.23;type:Food;expiration:1/25/2016" +
42
+                "##naMe:;price:3.23;type:Food^expiration:1/04/2016##";
43
+
44
+        String practice = "naMe:MaRShMAll0w;price:3.23;type:Food;expiration:10/25/2022" +
45
+                "##naME:c0cAC0la;price:1.23;type:Food;expiration:1/02/2016" +
46
+                "##NAMe:PREtzels;price:1.23;type:Food;expiration:2/25/2016" +
47
+                "##naMe:MiLK;price:3.23;type:Food^expiration:1/11/2016" +
48
+                "##naMe:TwINKies;price:4.25;type:Food%expiration:1/25/2016" +
49
+                "##naMe:3DozEggs;price:2.25;type:Food*expiration:1/25/2016" +
50
+                "##naMe:PANCAKEMIX;price:1.25;type:Food;expiration:3/22/2016" +
51
+                "##naMe:COOkieS;price:2.25;type:Food;expiration:1/25/2016" +
52
+                "##NAME:2lbShrmp;price:3.23;type:Food;expiration:1/17/2016" +
53
+                "##naMe:Snpple24;price:10.23;type:Food!expiration:4/25/2016" +
54
+                "##naMe:aplJax;price:0.25;type:Food;expiration:1/23/2016" +
55
+                "##naMe:aplJax;price:0.23;type:Food;expiration:5/02/2016" +
56
+                "##NAMe:;price:1.23;type:Food;expiration:1/25/2016" +
57
+                "##naMe:;price:3.23;type:Food;expiration:1/04/2016" +
58
+                "##naMe:Milk;price:3.23;type:Food;expiration:1/25/2016" +
59
+                "##naME:BreaD;price:1.23;type:Food@expiration:1/02/2016" +
60
+                "##NAMe:BrEAD;price:1.23;type:Food@expiration:2/25/2016" +
61
+                "##naMe:MiLK;priCe:;type:Food;expiration:1/11/2016" +
62
+                "##naMe:Cookies;price:2.25;type:Food;expiration:1/25/2016" +
63
+                "##naMe:Co0kieS;pRice:2.25;type:Food;expiration:1/25/2016" +
64
+                "##naMe:COokIes;price:2.25;type:Food;expiration:3/22/2016" +
65
+                "##naMe:COOkieS;Price:2.25;type:Food;expiration:1/25/2016" +
66
+                "##NAME:MilK;price:3.23;type:Food;expiration:1/17/2016" +
67
+                "##naMe:MilK;priCe:;type:Food;expiration:4/25/2016" +
68
+                "##naMe:apPles;prIce:0.25;type:Food;expiration:1/23/2016" +
69
+                "##naMe:apPles;pRice:0.23;type:Food;expiration:5/02/2016" +
70
+                "##NAMe:BrEAD;price:1.23;type:Food;expiration:1/25/2016" +
71
+                "##naMe:;price:3.23;type:Food^expiration:1/04/2016##";
72
+
73
+
74
+
75
+    }
76
+    @Test
77
+    public void MainTest()throws Exception {
78
+        String expected = "name:    Milk \t\t seen: 6 times\n" +
79
+                "============= \t \t =============\n" +
80
+                "Price: \t 3.23\t\t seen: 5 times\n" +
81
+                "-------------\t\t -------------\n" +
82
+                "Price:   1.23\t\t seen: 1 time\n" +
83
+                "\n" +
84
+                "name:   Bread\t\t seen: 6 times\n" +
85
+                "=============\t\t =============\n" +
86
+                "Price:   1.23\t\t seen: 6 times\n" +
87
+                "-------------\t\t -------------\n" +
88
+                "\n" +
89
+                "name: Cookies     \t seen: 8 times\n" +
90
+                "=============     \t =============\n" +
91
+                "Price:   2.25        seen: 8 times\n" +
92
+                "-------------        -------------\n" +
93
+                "\n" +
94
+                "name:  Apples     \t seen: 4 times\n" +
95
+                "=============     \t =============\n" +
96
+                "Price:   0.25     \t seen: 2 times\n" +
97
+                "-------------     \t -------------\n" +
98
+                "Price:   0.23  \t \t seen: 2 times\n" +
99
+                "\n" +
100
+                "Errors         \t \t seen: 4 times\n";
101
+
102
+        String actual = mainTest.readRawDataToString("RawData.txt");
103
+
104
+
105
+        //This test is simply here to visually compare expected vs actual
106
+
107
+        Assert.assertEquals(expected, actual);
108
+    }
109
+
110
+    @Test
111
+    public void gettingCrazyTest() throws Exception {
112
+
113
+        String expected = "name:Mrshmllo        seen: 1 time\n" +
114
+                "=============        =============\n" +
115
+                "Price:   3.23        seen: 1 time\n" +
116
+                "-------------        -------------\n" +
117
+                "\n" +
118
+                "name:Cocacola        seen: 1 time\n" +
119
+                "=============        =============\n" +
120
+                "Price:   1.23        seen: 1 time\n" +
121
+                "-------------        -------------\n" +
122
+                "\n" +
123
+                "name:Pretzels        seen: 1 time\n" +
124
+                "=============        =============\n" +
125
+                "Price:   1.23        seen: 1 time\n" +
126
+                "-------------        -------------\n" +
127
+                "\n" +
128
+                "name:    Milk        seen: 3 times\n" +
129
+                "=============        =============\n" +
130
+                "Price:   3.23        seen: 3 times\n" +
131
+                "-------------        -------------\n" +
132
+                "\n" +
133
+                "name:Twinkies        seen: 1 time\n" +
134
+                "=============        =============\n" +
135
+                "Price:   4.25        seen: 1 time\n" +
136
+                "-------------        -------------\n" +
137
+                "\n" +
138
+                "name:3dozeggs        seen: 1 time\n" +
139
+                "=============        =============\n" +
140
+                "Price:   2.25        seen: 1 time\n" +
141
+                "-------------        -------------\n" +
142
+                "\n" +
143
+                "name:Panckemx        seen: 1 time\n" +
144
+                "=============        =============\n" +
145
+                "Price:   1.25        seen: 1 time\n" +
146
+                "-------------        -------------\n" +
147
+                "\n" +
148
+                "name: Cookies        seen: 5 times\n" +
149
+                "=============        =============\n" +
150
+                "Price:   2.25        seen: 3 times\n" +
151
+                "-------------        -------------\n" +
152
+                "Price:   2.15        seen: 1 time\n" +
153
+                "-------------        -------------\n" +
154
+                "Price:   2.45        seen: 1 time\n" +
155
+                "\n" +
156
+                "name:2lbshrmp        seen: 1 time\n" +
157
+                "=============        =============\n" +
158
+                "Price:   3.23        seen: 1 time\n" +
159
+                "-------------        -------------\n" +
160
+                "\n" +
161
+                "name:Snpple24        seen: 1 time\n" +
162
+                "=============        =============\n" +
163
+                "Price:  10.23        seen: 1 time\n" +
164
+                "-------------        -------------\n" +
165
+                "\n" +
166
+                "name:  Apljax        seen: 2 times\n" +
167
+                "=============        =============\n" +
168
+                "Price:   0.25        seen: 1 time\n" +
169
+                "-------------        -------------\n" +
170
+                "Price:   0.23        seen: 1 time\n" +
171
+                "\n" +
172
+                "name:   Bread        seen: 3 times\n" +
173
+                "=============        =============\n" +
174
+                "Price:   1.23        seen: 3 times\n" +
175
+                "-------------        -------------\n" +
176
+                "\n" +
177
+                "name:  Apples        seen: 2 times\n" +
178
+                "=============        =============\n" +
179
+                "Price:   0.25        seen: 1 time\n" +
180
+                "-------------        -------------\n" +
181
+                "Price:   0.23        seen: 1 time\n" +
182
+                "\n" +
183
+                "Errors               seen: 5 times\n";
184
+        String actual = mainTest.readRawDataToString("TestData.txt");
185
+        Assert.assertEquals(expected, actual);
186
+
187
+    }
188
+}