aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiederick de Vries <diederick@diederickdevries.net>2020-06-29 08:58:40 +0200
committerDiederick de Vries <diederick@diederickdevries.net>2020-06-29 08:58:40 +0200
commit97f7d5fdae7ba8d6f7f178bdc82ac388a277f037 (patch)
tree07173e0d60b99048a56699165434a459982f3989
parentab3fc3fb5793aaca421046b3f6332dc15bb57bc6 (diff)
downloadboodschapi-97f7d5fdae7ba8d6f7f178bdc82ac388a277f037.tar.gz
boodschapi-97f7d5fdae7ba8d6f7f178bdc82ac388a277f037.tar.bz2
boodschapi-97f7d5fdae7ba8d6f7f178bdc82ac388a277f037.zip
refactor:add amount field to constructor
-rw-r--r--src/main/java/net/diederickdevries/boodschapi/model/Item.java3
-rw-r--r--src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/net/diederickdevries/boodschapi/model/Item.java b/src/main/java/net/diederickdevries/boodschapi/model/Item.java
index dde3555..14abe77 100644
--- a/src/main/java/net/diederickdevries/boodschapi/model/Item.java
+++ b/src/main/java/net/diederickdevries/boodschapi/model/Item.java
@@ -75,10 +75,11 @@ 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, 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;
82 this.amount = amount;
82 this.week = week.toString(); 83 this.week = week.toString();
83 } 84 }
84 85
diff --git a/src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java b/src/test/java/net/diederickdevries/boodschapi/repository/ItemRepositoryIT.java
index 1ae7df1..a1458e5 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, new Week("20200" + i))); 111 itemRepository.saveAndFlush(new Item(grocery, shop, 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());
@@ -117,5 +117,6 @@ public class ItemRepositoryIT
117 List<Item> found = itemRepository.findByWeeks("202001", "202002", "202003"); 117 List<Item> found = itemRepository.findByWeeks("202001", "202002", "202003");
118 assertEquals(1, found.size()); 118 assertEquals(1, found.size());
119 assertEquals(grocery, found.get(0).getGrocery()); 119 assertEquals(grocery, found.get(0).getGrocery());
120 assertTrue(1 == found.get(0).getAmount());
120 } 121 }
121} 122}