Browse Source

Fixing exceptions

Sam Jaffe 5 năm trước cách đây
mục cha
commit
61cde512ca

+ 7 - 6
src/main/lombok/org/leumasjaffe/recipe/model/Card.java

@@ -1,5 +1,6 @@
 package org.leumasjaffe.recipe.model;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -13,12 +14,12 @@ import lombok.Data;
 
 @Data
 public class Card {
-	int id; // TODO Fix this
-	int[] dependsOn; // decltype(id)[]
-	String vessel;
-	Optional<Step> preparation;
-	List<Step> cooking;
-	Optional<Rest> rest;
+	int id = 0; // TODO Fix this
+	int[] dependsOn = {}; // decltype(id)[]
+	String vessel = "";
+	Optional<Step> preparation = Optional.empty();
+	List<Step> cooking = new ArrayList<>();
+	Optional<Rest> rest = Optional.empty();
 	
 	@JsonIgnore
 	Collection<Ingredient> getIngredients() {

+ 25 - 27
src/test/resources/example.json

@@ -4,34 +4,32 @@
   "products": [
     {
       "name": "Curry",
-      "prep": {
-        "phase": {
-          "steps": [
-            {
-              "ingredients": [
-                {
-                  "name": "onion",
-                  "value": 100,
-                  "unit": [ null, "g" ]
-                }
-              ],
-              "duration": {
-                "displayAs": "MINUTES",
-                "isApproximate": true,
-                "minSeconds": 300,
-                "maxSeconds": 600
-              },
-              "instruction": "Expode"
-            }
-          ]
+      "cards": [
+        {
+          "id": 0,
+          "dependsOn": [],
+          "vessel": "",
+          "preparation": {
+            "ingredients": [
+              {
+                "name": "onion",
+                "value": 100,
+                "unit": [
+                  null,
+                  "g"
+                ]
+              }
+            ],
+            "duration": {
+              "displayAs": "MINUTES",
+              "isApproximate": true,
+              "minSeconds": 300,
+              "maxSeconds": 600
+            },
+            "instruction": "Expode"
+          }
         }
-      },
-      "cooking": {
-        "phase": {
-          "steps": [
-          ]
-        }
-      }
+      ]
     }
   ]
 }