diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Expense.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Expense.java similarity index 98% rename from src/main/java/no/ntnu/idatt1002/demo/data/Expense.java rename to src/main/java/no/ntnu/idatt1002/demo/data/Economics/Expense.java index 15a59f7e76e795eab11785935ba4b4c47ea0627c..74fe9d893306bba98cb37d02d9e1d411f2a86cfc 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Expense.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Expense.java @@ -1,4 +1,4 @@ -package no.ntnu.idatt1002.demo.data; +package no.ntnu.idatt1002.demo.data.Economics; public class Expense extends Item{ private ExpenseCategory category; diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/ExpenseCategory.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseCategory.java similarity index 62% rename from src/main/java/no/ntnu/idatt1002/demo/data/ExpenseCategory.java rename to src/main/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseCategory.java index 0460a4004fa69e8e8b186714c508e7869968ad09..c1043a4da811ab182cca75ef49972e44a218a6f2 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/ExpenseCategory.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseCategory.java @@ -1,4 +1,4 @@ -package no.ntnu.idatt1002.demo.data; +package no.ntnu.idatt1002.demo.data.Economics; public enum ExpenseCategory { diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Income.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Income.java similarity index 98% rename from src/main/java/no/ntnu/idatt1002/demo/data/Income.java rename to src/main/java/no/ntnu/idatt1002/demo/data/Economics/Income.java index 10e2f7ae936cf79681999a5373f5e48f6b9ef147..646b1d82d10449eec9656abfcfab03e5ad7b9ff2 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Income.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Income.java @@ -1,4 +1,4 @@ -package no.ntnu.idatt1002.demo.data; +package no.ntnu.idatt1002.demo.data.Economics; /** * The Income class inherits from the Item class. The Item class additionally has a private field for an diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/IncomeCategory.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/IncomeCategory.java similarity index 60% rename from src/main/java/no/ntnu/idatt1002/demo/data/IncomeCategory.java rename to src/main/java/no/ntnu/idatt1002/demo/data/Economics/IncomeCategory.java index 1ead533938575fd5483f2b4b32c3d00f8d7dafd0..021d993c35000429f906ecbb8ae2d85f2c681eea 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/IncomeCategory.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/IncomeCategory.java @@ -1,4 +1,4 @@ -package no.ntnu.idatt1002.demo.data; +package no.ntnu.idatt1002.demo.data.Economics; public enum IncomeCategory { SALARY, diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Item.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Item.java similarity index 88% rename from src/main/java/no/ntnu/idatt1002/demo/data/Item.java rename to src/main/java/no/ntnu/idatt1002/demo/data/Economics/Item.java index 562b2999c66603bdbeb78b5b3ad1f36e061c1615..818d21f388da4945ada87728d4883605464bf7e3 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Item.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Item.java @@ -1,4 +1,6 @@ -package no.ntnu.idatt1002.demo.data; +package no.ntnu.idatt1002.demo.data.Economics; + +import java.util.Objects; /** * The Item class represents a good or service purchased in real life. The item belongs to a category and @@ -7,7 +9,7 @@ package no.ntnu.idatt1002.demo.data; * @author HanneSofie * */ -public class Item { +public abstract class Item { private String description = ""; private double amount; private boolean recurring; @@ -70,7 +72,7 @@ public class Item { */ public void setAmount(double amount) { if(amount <= 1.0f ) { - throw new IllegalArgumentException("A positive amount must be provided."); + throw new IllegalArgumentException("A positive amount must be provided"); } this.amount = amount; } @@ -110,6 +112,18 @@ public class Item { this.date = newDate; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Item item)) return false; + return Double.compare(item.amount, amount) == 0 && recurring == item.recurring && Objects.equals(description, item.description) && Objects.equals(date, item.date); + } + + @Override + public int hashCode() { + return Objects.hash(description, amount, recurring, date); + } + /* @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegister.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegister.java new file mode 100644 index 0000000000000000000000000000000000000000..8a8b35fcee5af8677efa29009360159880c77f18 --- /dev/null +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegister.java @@ -0,0 +1,69 @@ +package no.ntnu.idatt1002.demo.data.Economics; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * ItemRegister is a generic class used by ExpenseRegister and + * IncomeRegister. + * @param <T> Income or Expense + */ +public class ItemRegister<T>{ + ArrayList<T> items; + + /** + * An "empty" class constructor. + */ + public ItemRegister() { + this.items = new ArrayList<>(); //ArrayList for storing T麓s + } + + /** + * Class constructor that takes in an ArrayList of T as argument. + * @param items An ArrayList of Income or Expense you want to overview. + */ + public ItemRegister(ArrayList<T> items) { + this.items = items; + } + + /** + * Get an ArrayList of every T. + * @return T ArrayList. + */ + public ArrayList<T> getItems() { + return items; + } + + /** + * Add a new T to the register. Throws IllegalArgumentException + * if the new T is already registered. + * @param newItem The T you want to add. + */ + public void addItem(T newItem){ + if(items.contains(newItem)){ + throw new IllegalArgumentException("This item is already registered"); + } + items.add(newItem); + } + + /** + * Get the sum of all T麓s in items. + * @return Sum of all T麓s. + */ + public double getTotalSum(){ + ArrayList<Item> castedItems = (ArrayList<Item>) items; //Casts items as an ArrayList of Item麓s + return castedItems.stream().map(Item::getAmount).mapToDouble(Double::doubleValue).sum(); + } + + public <S> ArrayList<T> getItemsBasedOnCategory(S Category){ + if(Category instanceof IncomeCategory){ //Checks if it麓s an instance of IncomeCategory + ArrayList<Income> castedIncome = (ArrayList<Income>) items; + return (ArrayList<T>) castedIncome.stream().filter(anIncome -> anIncome.getCategory().compareTo((IncomeCategory) Category) == 0).collect(Collectors.toList()); + } else if(Category instanceof ExpenseCategory){ //Checks if it麓s an instance of ExpenseCategory + ArrayList<Expense> castedExpenses = (ArrayList<Expense>) items; + return (ArrayList<T>) castedExpenses.stream().filter(anExpense -> anExpense.getCategory().compareTo((ExpenseCategory) Category) == 0).collect(Collectors.toList()); + } else{return null;} + } +} diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/ItemOverview.java b/src/main/java/no/ntnu/idatt1002/demo/data/ItemOverview.java deleted file mode 100644 index 2c4f15510a079a96c0128cf8724ce0ac89eacf6d..0000000000000000000000000000000000000000 --- a/src/main/java/no/ntnu/idatt1002/demo/data/ItemOverview.java +++ /dev/null @@ -1,74 +0,0 @@ -package no.ntnu.idatt1002.demo.data; - -import java.util.ArrayList; - -/** - * RevenueOverview is a class for storing and getting - * information on your total income and expense. - */ -public class ItemOverview { - ArrayList<Income> income; - ArrayList<Expense> expense; - - /** - * The class constructor. - */ - public ItemOverview(){ - this.income = new ArrayList<>(); //ArrayList for storing income - this.expense = new ArrayList<>(); //ArrayList for storing expense - } - - /** - * Get an ArrayList of every income. - * @return Income ArrayList. - */ - public ArrayList<Income> getIncome() { - return income; - } - - /** - * Get an ArrayList of every expense. - * @return Expense ArrayList. - */ - public ArrayList<Expense> getExpense() { - return expense; - } - - /** - * Add an Income object to income. - * @param newIncome The Income you want to add. - */ - public void addIncome(Income newIncome){ - if(income.contains(newIncome)){ - throw new IllegalArgumentException("This income is already registered"); - } - income.add(newIncome); - } - - /** - * Add an Expense object to income. - * @param newExpense The Expense you want to add. - */ - public void addExpense(Expense newExpense){ - if(expense.contains(newExpense)){ - throw new IllegalArgumentException("This expense is already registered"); - } - expense.add(newExpense); - } - - /** - * Get the sum of all Income in income. - * @return Sum of all Income. - */ - public double getTotalIncome(){ - return income.stream().map(Item::getAmount).mapToDouble(Double::doubleValue).sum(); - } - - /** - * Get the sum of all Expense in expense. - * @return Sum of all Expense. - */ - public double getTotalExpense(){ - return expense.stream().map(Item::getAmount).mapToDouble(Double::doubleValue).sum(); - } -} diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/ExpenseTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseTest.java similarity index 82% rename from src/test/java/no/ntnu/idatt1002/demo/data/ExpenseTest.java rename to src/test/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseTest.java index e72597e935fe46c9778707d2bd5914beb80d5e82..338f63fb563e843c1871674e6043528cc89b9894 100644 --- a/src/test/java/no/ntnu/idatt1002/demo/data/ExpenseTest.java +++ b/src/test/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseTest.java @@ -1,5 +1,7 @@ -package no.ntnu.idatt1002.demo.data; +package no.ntnu.idatt1002.demo.data.Economics; +import no.ntnu.idatt1002.demo.data.Economics.Expense; +import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/Economics/IncomeTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/Economics/IncomeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..69302606c5bebbf279efd8c395e1d4e887ec8fcd --- /dev/null +++ b/src/test/java/no/ntnu/idatt1002/demo/data/Economics/IncomeTest.java @@ -0,0 +1,52 @@ +package no.ntnu.idatt1002.demo.data.Economics; + +import no.ntnu.idatt1002.demo.data.Economics.Income; +import no.ntnu.idatt1002.demo.data.Economics.IncomeCategory; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class IncomeTest { + + @Test + @DisplayName("The Income constructor throws exceptions when it should.") + void constructorThrows(){ + assertThrows(IllegalArgumentException.class, () -> new Income("description", 8.5f, false, null, "03.03.23")); + assertThrows(IllegalArgumentException.class, () -> new Income("description", -10.0f, false, IncomeCategory.SALARY, "03.03.23")); + }; + + @Test + @DisplayName("The Income constructor does not throw exceptions when it should not.") + void constructorDoesThrow() { + assertDoesNotThrow(() -> new Income("description", 59.9f, false, IncomeCategory.SALARY, "03.03.23")); + } +} + +/** + * package no.ntnu.idatt1002.demo.data.Economics; + * + * import no.ntnu.idatt1002.demo.data.Economics.Item; + * import org.junit.jupiter.api.DisplayName; + * import org.junit.jupiter.api.Test; + * + * import static org.junit.jupiter.api.Assertions.*; + * + * class ItemTest { + * + * @Test + * @DisplayName("The Item constructor throws exceptions when it should.") + * void constructorThrows(){ + * assertThrows(IllegalArgumentException.class, () -> new Item("description", 0f, false, "03.03.23")); + * assertThrows(IllegalArgumentException.class, () -> new Item("description", -10.0f, false, "03.03.23")); + * assertThrows(IllegalArgumentException.class, () -> new Item("description", -10.0f, false, "")); + * }; + * + * @Test + * @DisplayName("The Item constructor does not throw exceptions when it should not.") + * void constructorDoesThrow() { + * assertDoesNotThrow(() -> new Item("description", 59.9f, false, "03.03.23")); + * } + * + * } + */ \ No newline at end of file diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegisterTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegisterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5894f13141a103625e4c083e1f5b174b824fbbbd --- /dev/null +++ b/src/test/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegisterTest.java @@ -0,0 +1,130 @@ +package no.ntnu.idatt1002.demo.data.Economics; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; + +public class ItemRegisterTest { + ItemRegister<Income> incomeRegister; + ItemRegister<Expense> expenseRegister; + + @Nested + @DisplayName("Test ItemRegister when using Income") + class incomeRegisterTests { + @BeforeEach + public void createItemOverView() { + incomeRegister = new ItemRegister(); + } + + @Test + @DisplayName("addItem method throws exception when it should") + void addItemThrows() { + Income income = new Income("description", 59.9f, false, IncomeCategory.SALARY, "03.03.23"); + assertThrows(IllegalArgumentException.class, () -> { + incomeRegister.addItem(income); + incomeRegister.addItem(income); + }); + } + + @Test + @DisplayName("addItem method does not throw exception when it should not") + void addItemDoesNotThrow() { + Income income1 = new Income("description", 59.9f, false, IncomeCategory.GIFT, "03.03.23"); + Income income2 = new Income("anotherDescription", 6.5f, true, IncomeCategory.SALARY, "02.03.23"); + assertDoesNotThrow(() -> { + incomeRegister.addItem(income1); + incomeRegister.addItem(income2); + }); + } + + @Test + @DisplayName("getTotalSum method gives correct amount") + void getTotalSumCorrectAmount() { + Income income1 = new Income("description1", 59.9f, false, IncomeCategory.SALARY, "03.03.23"); + Income income2 = new Income("description2", 62.4f, true, IncomeCategory.GIFT, "01.02.21"); + Income income3 = new Income("description3", 9.81f, false, IncomeCategory.SALARY, "05.07.23"); + incomeRegister.addItem(income1); + incomeRegister.addItem(income2); + incomeRegister.addItem(income3); + + double totalIncome = 59.9f + 62.4f + 9.81f; + assertEquals(Math.round(incomeRegister.getTotalSum()), Math.round(totalIncome)); + } + + @Test + void getIncomeBasedOnCategoryGivesCorrectIncome() { + Income income1 = new Income("description1", 59.9f, false, IncomeCategory.SALARY, "03.03.23"); + Income income2 = new Income("description2", 62.4f, true, IncomeCategory.GIFT, "01.02.21"); + Income income3 = new Income("description3", 9.81f, false, IncomeCategory.SALARY, "05.07.23"); + + incomeRegister.addItem(income1); + incomeRegister.addItem(income2); + incomeRegister.addItem(income3); + ArrayList<Income> incomeSalary = incomeRegister.getItemsBasedOnCategory(IncomeCategory.SALARY); + assertTrue(incomeSalary.contains(income1) && incomeSalary.contains(income3)); + } + } + + @Nested + @DisplayName("Test ItemRegister when using Expense") + class expenseRegisterTests { + @BeforeEach + public void createItemOverView() { + expenseRegister = new ItemRegister(); + } + + @Test + @DisplayName("addItem method throws exception when it should") + void addItemThrows() { + Expense expense = new Expense("description", 59.9f, false, ExpenseCategory.CLOTHES, "03.03.23"); + assertThrows(IllegalArgumentException.class, () -> { + expenseRegister.addItem(expense); + expenseRegister.addItem(expense); + }); + } + + @Test + @DisplayName("addItem method does not throw exception when it should not") + void addItemDoesNotThrow() { + Expense expense1 = new Expense("description", 59.9f, false, ExpenseCategory.CLOTHES, "03.03.23"); + Expense expense2 = new Expense("anotherDescription", 6.5f, true, ExpenseCategory.BOOKS, "02.03.23"); + assertDoesNotThrow(() -> { + expenseRegister.addItem(expense1); + expenseRegister.addItem(expense2); + }); + } + + @Test + @DisplayName("getTotalSum method gives correct amount") + void getTotalSumCorrectAmount(){ + Expense expense1 = new Expense("description1", 59.9f, false, ExpenseCategory.CLOTHES, "03.03.23"); + Expense expense2 = new Expense("description2", 62.4f, true, ExpenseCategory.FOOD, "01.02.21"); + Expense expense3 = new Expense("description3", 9.81f, false, ExpenseCategory.CLOTHES, "05.07.23"); + + expenseRegister.addItem(expense1); + expenseRegister.addItem(expense2); + expenseRegister.addItem(expense3); + double totalIncome = 59.9f + 62.4f + 9.81f; + assertEquals(Math.round(expenseRegister.getTotalSum()), Math.round(totalIncome)); + } + + @Test + void getIncomeBasedOnCategoryGivesCorrectIncome() { + Expense expense1 = new Expense("description1", 59.9f, false, ExpenseCategory.CLOTHES, "03.03.23"); + Expense expense2 = new Expense("description2", 62.4f, true, ExpenseCategory.FOOD, "01.02.21"); + Expense expense3 = new Expense("description3", 9.81f, false, ExpenseCategory.CLOTHES, "05.07.23"); + + expenseRegister.addItem(expense1); + expenseRegister.addItem(expense2); + expenseRegister.addItem(expense3); + ArrayList<Expense> expenseSalary = expenseRegister.getItemsBasedOnCategory(ExpenseCategory.CLOTHES); + assertTrue(expenseSalary.contains(expense1) && expenseSalary.contains(expense3)); + } + } +} + \ No newline at end of file diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/IncomeTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/IncomeTest.java deleted file mode 100644 index 6e71180496623fbc78971c3ea22be4ab061f2f1f..0000000000000000000000000000000000000000 --- a/src/test/java/no/ntnu/idatt1002/demo/data/IncomeTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package no.ntnu.idatt1002.demo.data; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class IncomeTest { - - @Test - @DisplayName("The Income constructor throws exceptions when it should.") - void constructorThrows(){ - assertThrows(IllegalArgumentException.class, () -> new Income("description", 8.5f, false, null, "03.03.23")); - assertThrows(IllegalArgumentException.class, () -> new Income("description", -10.0f, false, IncomeCategory.SALARY, "03.03.23")); - }; - - @Test - @DisplayName("The Income constructor does not throw exceptions when it should not.") - void constructorDoesThrow() { - assertDoesNotThrow(() -> new Income("description", 59.9f, false, IncomeCategory.SALARY, "03.03.23")); - } - - -} \ No newline at end of file diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/ItemOverviewTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/ItemOverviewTest.java deleted file mode 100644 index 61861aaf837ad25de1f0e55b07c3594082b6ea2e..0000000000000000000000000000000000000000 --- a/src/test/java/no/ntnu/idatt1002/demo/data/ItemOverviewTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package no.ntnu.idatt1002.demo.data; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ItemOverviewTest { - ItemOverview itemOverview; - @BeforeEach - public void makeItemOverview(){ - itemOverview = new ItemOverview(); - } - @Test - @DisplayName("addIncome method throws exception when it should") - void addIncomeThrows(){ - itemOverview.addIncome(new Income("description", 59.9f, false, IncomeCategory.SALARY, "03.03.23")); - itemOverview.addIncome(new Income("description", 59.9f, false, IncomeCategory.SALARY, "03.03.23")); - } - - @Test - @DisplayName("addExpense method throws exception when it should") - void addExpenseThrows(){ - itemOverview.addExpense(new Expense("description", 59.9f, false, ExpenseCategory.BOOKS, "03.03.23")); - itemOverview.addExpense(new Expense("description", 59.9f, false, ExpenseCategory.BOOKS, "03.03.23")); - } - - @Test - @DisplayName("getTotalIncome method gives correct amount") - void getTotalIncomeCorrectAmount(){ - itemOverview.addIncome(new Income("description1", 59.9f, false, IncomeCategory.SALARY, "03.03.23")); - itemOverview.addIncome(new Income("description2", 62.4f, true, IncomeCategory.GIFT, "01.02.21")); - itemOverview.addIncome(new Income("description3", 9.81f, false, IncomeCategory.SALARY, "05.07.23")); - - double totalIncome = 59.9f + 62.4f + 9.81f; - assertEquals(Math.round(itemOverview.getTotalIncome()), Math.round(totalIncome)); - } - - @Test - @DisplayName("getTotalExpense method gives correct amount") - void getTotalExpenseCorrectAmount(){ - itemOverview.addExpense(new Expense("description1", 59.9f, false, ExpenseCategory.BOOKS, "03.03.23")); - itemOverview.addExpense(new Expense("description2", 78.2f, true, ExpenseCategory.FOOD, "03.04.23")); - itemOverview.addExpense(new Expense("description3", 103.5f, true, ExpenseCategory.OTHER, "07.03.23")); - - double totalExpense = 59.9f + 78.2f + 103.5f; - assertEquals(Math.round(itemOverview.getTotalExpense()), Math.round(totalExpense)); - } -} diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/ItemTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/ItemTest.java deleted file mode 100644 index 7ab5a18f900b32ea7ba05230739bdb74fa8c42c4..0000000000000000000000000000000000000000 --- a/src/test/java/no/ntnu/idatt1002/demo/data/ItemTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package no.ntnu.idatt1002.demo.data; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class ItemTest { - - @Test - @DisplayName("The Item constructor throws exceptions when it should.") - void constructorThrows(){ - assertThrows(IllegalArgumentException.class, () -> new Item("description", 0f, false, "03.03.23")); - assertThrows(IllegalArgumentException.class, () -> new Item("description", -10.0f, false, "03.03.23")); - assertThrows(IllegalArgumentException.class, () -> new Item("description", -10.0f, false, "")); - }; - - @Test - @DisplayName("The Item constructor does not throw exceptions when it should not.") - void constructorDoesThrow() { - assertDoesNotThrow(() -> new Item("description", 59.9f, false, "03.03.23")); - } - -} \ No newline at end of file