aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiederick de Vries <diederick@diederickdevries.net>2020-06-29 21:32:08 +0200
committerDiederick de Vries <diederick@diederickdevries.net>2020-06-29 21:32:08 +0200
commitaf1d403a60c9cf9966761957ce645a3fa0aa7223 (patch)
tree1391fc122618492a65ea1ce1bc72af8950b83b7d
parent42c7a7f127d7fa9a7f42045333e71f2c6fb1382e (diff)
downloadboodschapi-af1d403a60c9cf9966761957ce645a3fa0aa7223.tar.gz
boodschapi-af1d403a60c9cf9966761957ce645a3fa0aa7223.tar.bz2
boodschapi-af1d403a60c9cf9966761957ce645a3fa0aa7223.zip
fix:allow for null amounts
-rw-r--r--src/main/java/net/diederickdevries/boodschapi/model/Item.java2
-rw-r--r--src/test/java/net/diederickdevries/boodschapi/controller/ItemControllerIT.java14
-rw-r--r--src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/net/diederickdevries/boodschapi/model/Item.java b/src/main/java/net/diederickdevries/boodschapi/model/Item.java
index 14abe77..0976c72 100644
--- a/src/main/java/net/diederickdevries/boodschapi/model/Item.java
+++ b/src/main/java/net/diederickdevries/boodschapi/model/Item.java
@@ -75,7 +75,7 @@ public class Item implements Serializable
75 this.id = id; 75 this.id = id;
76 } 76 }
77 77
78 public Item(final Grocery grocery, final Shop shop, float amount, final Week week) 78 public Item(final Grocery grocery, final Shop shop, Float amount, final Week week)
79 { 79 {
80 this.grocery = grocery; 80 this.grocery = grocery;
81 this.shop = shop; 81 this.shop = shop;
diff --git a/src/test/java/net/diederickdevries/boodschapi/controller/ItemControllerIT.java b/src/test/java/net/diederickdevries/boodschapi/controller/ItemControllerIT.java
index 30dd1a6..4800eea 100644
--- a/src/test/java/net/diederickdevries/boodschapi/controller/ItemControllerIT.java
+++ b/src/test/java/net/diederickdevries/boodschapi/controller/ItemControllerIT.java
@@ -135,9 +135,9 @@ public class ItemControllerIT
135 final Week twoWeeksAgo = lastWeek.getLastWeek(); 135 final Week twoWeeksAgo = lastWeek.getLastWeek();
136 final Week threeWeeksAgo = twoWeeksAgo.getLastWeek(); 136 final Week threeWeeksAgo = twoWeeksAgo.getLastWeek();
137 137
138 itemRepository.saveAndFlush(new Item(grocery, shop, 1, lastWeek)); 138 itemRepository.saveAndFlush(new Item(grocery, shop, 1F, lastWeek));
139 itemRepository.saveAndFlush(new Item(grocery, shop, 2, twoWeeksAgo)); 139 itemRepository.saveAndFlush(new Item(grocery, shop, 2F, twoWeeksAgo));
140 itemRepository.saveAndFlush(new Item(grocery, shop, 2, threeWeeksAgo)); 140 itemRepository.saveAndFlush(new Item(grocery, shop, 2F, threeWeeksAgo));
141 141
142 controller.copyWeeklyBoughtItemsTo(week.toString()); 142 controller.copyWeeklyBoughtItemsTo(week.toString());
143 143
@@ -167,10 +167,10 @@ public class ItemControllerIT
167 167
168 // The one from last week (with amount 2) would be the one copied, so 168 // The one from last week (with amount 2) would be the one copied, so
169 // We'll give the already existing one amount 1. 169 // We'll give the already existing one amount 1.
170 itemRepository.saveAndFlush(new Item(grocery, shop, 1, week)); 170 itemRepository.saveAndFlush(new Item(grocery, shop, 1F, week));
171 itemRepository.saveAndFlush(new Item(grocery, shop, 2, lastWeek)); 171 itemRepository.saveAndFlush(new Item(grocery, shop, 2F, lastWeek));
172 itemRepository.saveAndFlush(new Item(grocery, shop, 2, twoWeeksAgo)); 172 itemRepository.saveAndFlush(new Item(grocery, shop, 2F, twoWeeksAgo));
173 itemRepository.saveAndFlush(new Item(grocery, shop, 2, threeWeeksAgo)); 173 itemRepository.saveAndFlush(new Item(grocery, shop, 2F, threeWeeksAgo));
174 174
175 controller.copyWeeklyBoughtItemsTo(week.toString()); 175 controller.copyWeeklyBoughtItemsTo(week.toString());
176 176
diff --git a/src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java b/src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java
index a1458e5..13d482f 100644
--- a/src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java
+++ b/src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java
@@ -108,7 +108,7 @@ public class ItemRepositoryIT
108 final int n = 3; 108 final int n = 3;
109 for (int i = 1; i <= n; ++i) 109 for (int i = 1; i <= n; ++i)
110 { 110 {
111 itemRepository.saveAndFlush(new Item(grocery, shop, i, new Week("20200" + i))); 111 itemRepository.saveAndFlush(new Item(grocery, shop, (float)i, new Week("20200" + i)));
112 } 112 }
113 assertEquals(grocery, itemRepository.findByWeekAndGrocery("202001", grocery).getGrocery()); 113 assertEquals(grocery, itemRepository.findByWeekAndGrocery("202001", grocery).getGrocery());
114 assertEquals(grocery, itemRepository.findByWeekAndGrocery("202002", grocery).getGrocery()); 114 assertEquals(grocery, itemRepository.findByWeekAndGrocery("202002", grocery).getGrocery());