From f036f2ce3521ce8330d3802d6c895ec47ae646b1 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Sun, 23 Jun 2024 22:34:28 +0200 Subject: [PATCH] #764 - added new property "endDate" for class account --- .../budgetmaster/accounts/Account.java | 29 +++++++-- .../budgetmaster/accounts/AccountService.java | 5 +- .../settings/demo/DemoDataCreator.java | 6 +- ...reAllIconizableHaveAnIconInstanceTest.java | 2 +- .../budgetmaster/unit/AccountServiceTest.java | 60 +++++++++---------- .../budgetmaster/unit/IconServiceTest.java | 2 +- .../budgetmaster/unit/IconizableTest.java | 8 +-- .../unit/TemplateServiceTest.java | 16 ++--- .../unit/TransactionImportServiceTest.java | 2 +- .../TransactionSearchSpecificationsTest.java | 6 +- .../unit/TransactionServiceDatabaseTest.java | 2 +- .../unit/TransactionServiceTest.java | 2 +- .../unit/TransactionSpecificationsTest.java | 6 +- .../unit/database/DatabaseExportTest.java | 4 +- ...abaseParser_v11_convertToInternalTest.java | 6 +- .../unit/database/ImportServiceTest.java | 14 ++--- .../importer/AccountImporterTest.java | 16 ++--- .../importer/TemplateImporterTest.java | 8 +-- .../importer/TransactionImporterTest.java | 12 ++-- .../RepeatingTransactionUpdaterTest.java | 2 +- 20 files changed, 114 insertions(+), 94 deletions(-) diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/Account.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/Account.java index 2e40135cc..567f22515 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/Account.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/Account.java @@ -8,7 +8,9 @@ import de.deadlocker8.budgetmaster.utils.ProvidesID; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDate; import java.util.List; import java.util.Objects; @@ -48,7 +50,11 @@ public class Account implements ProvidesID, Iconizable @Expose private String description; - public Account(String name, String description, AccountType type, Icon iconReference) + @DateTimeFormat(pattern = "dd.MM.yyyy") + @Expose + private LocalDate endDate; + + public Account(String name, String description, AccountType type, Icon iconReference, LocalDate endDate) { this.name = name; this.description = description; @@ -57,11 +63,12 @@ public class Account implements ProvidesID, Iconizable this.isDefault = false; this.accountState = AccountState.FULL_ACCESS; this.iconReference = iconReference; + this.endDate = endDate; } - public Account(String name, String description, AccountType type) + public Account(String name, String description, AccountType type, LocalDate endDate) { - this(name, description, type, null); + this(name, description, type, null, endDate); } public Account() @@ -148,6 +155,16 @@ public class Account implements ProvidesID, Iconizable this.description = description; } + public LocalDate getEndDate() + { + return endDate; + } + + public void setEndDate(LocalDate endDate) + { + this.endDate = endDate; + } + @Override public Icon getIconReference() { @@ -202,6 +219,7 @@ public class Account implements ProvidesID, Iconizable ", type=" + type + ", iconReference=" + iconReference + ", description='" + description + '\'' + + ", endDate=" + endDate + '}'; } @@ -218,12 +236,13 @@ public class Account implements ProvidesID, Iconizable accountState == account.accountState && Objects.equals(iconReference, account.iconReference) && type == account.type && - Objects.equals(description, account.description); + Objects.equals(description, account.description) && + Objects.equals(endDate, account.endDate); } @Override public int hashCode() { - return Objects.hash(ID, name, description, isSelected, isDefault, accountState, iconReference, type); + return Objects.hash(ID, name, description, isSelected, isDefault, accountState, iconReference, type, endDate); } } \ No newline at end of file diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountService.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountService.java index 1a9b5b2e2..fd4f3d1ce 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountService.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/accounts/AccountService.java @@ -133,14 +133,14 @@ public class AccountService implements Resettable, AccessAllEntities<Account>, A { if(accountRepository.findAll().isEmpty()) { - Account placeholder = new Account("Placeholder", "", AccountType.ALL); + Account placeholder = new Account("Placeholder", "", AccountType.ALL, null); final Icon newIcon = iconService.createIconReference(null, PLACEHOLDER_ICON, null); iconService.getRepository().save(newIcon); placeholder.setIconReference(newIcon); accountRepository.save(placeholder); LOGGER.debug("Created placeholder account"); - Account account = accountRepository.save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM)); + Account account = accountRepository.save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM, null)); final Icon iconDefaultAccount = iconService.createIconReference(null, null, null); iconService.getRepository().save(iconDefaultAccount); account.setIconReference(iconDefaultAccount); @@ -287,6 +287,7 @@ public class AccountService implements Resettable, AccessAllEntities<Account>, A existingAccount.setIconReference(newAccount.getIconReference()); existingAccount.setType(AccountType.CUSTOM); existingAccount.setAccountState(newAccount.getAccountState()); + existingAccount.setEndDate(newAccount.getEndDate()); accountRepository.save(existingAccount); if(existingAccount.isDefault() && existingAccount.getAccountState() != AccountState.FULL_ACCESS) diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/demo/DemoDataCreator.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/demo/DemoDataCreator.java index d4f6ddfb7..8539da872 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/demo/DemoDataCreator.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/demo/DemoDataCreator.java @@ -71,19 +71,19 @@ public class DemoDataCreator { final Icon icon = iconService.createIconReference(null, null, null); iconService.getRepository().save(icon); - final Account oldAccount = new Account("Old account", "", AccountType.CUSTOM, icon); + final Account oldAccount = new Account("Old account", "", AccountType.CUSTOM, icon, null); oldAccount.setAccountState(AccountState.HIDDEN); accountService.getRepository().save(oldAccount); final Icon icon2 = iconService.createIconReference(null, null, null); iconService.getRepository().save(icon2); - final Account readOnlyAccount = new Account("Read-only account", "", AccountType.CUSTOM, icon2); + final Account readOnlyAccount = new Account("Read-only account", "", AccountType.CUSTOM, icon2, null); readOnlyAccount.setAccountState(AccountState.READ_ONLY); accountService.getRepository().save(readOnlyAccount); final Icon icon3 = iconService.createIconReference(null, "fas fa-piggy-bank", null); iconService.getRepository().save(icon3); - final Account savingsBankAccount = new Account("Savings Bank", "", AccountType.CUSTOM, icon3); + final Account savingsBankAccount = new Account("Savings Bank", "", AccountType.CUSTOM, icon3, null); accountService.getRepository().save(savingsBankAccount); } diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/EnsureAllIconizableHaveAnIconInstanceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/EnsureAllIconizableHaveAnIconInstanceTest.java index a8fa80d39..1971843ce 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/EnsureAllIconizableHaveAnIconInstanceTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/integration/EnsureAllIconizableHaveAnIconInstanceTest.java @@ -68,7 +68,7 @@ class EnsureAllIconizableHaveAnIconInstanceTest @BeforeEach void beforeEach() { - final Account accountWithoutIconReference = new Account("My Account", "", AccountType.CUSTOM); + final Account accountWithoutIconReference = new Account("My Account", "", AccountType.CUSTOM, null); accountRepository.save(accountWithoutIconReference); final Category categoryWithoutIconReference = new Category("Car", "#ffcc00", CategoryType.CUSTOM); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/AccountServiceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/AccountServiceTest.java index 831d6d993..2547e7988 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/AccountServiceTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/AccountServiceTest.java @@ -58,18 +58,18 @@ class AccountServiceTest @BeforeEach void beforeEach() { - ACCOUNT_DEFAULT = new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM); + ACCOUNT_DEFAULT = new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM, null); - ACCOUNT_PLACEHOLDER = new Account("Placeholder", "", AccountType.ALL); + ACCOUNT_PLACEHOLDER = new Account("Placeholder", "", AccountType.ALL, null); ACCOUNT_PLACEHOLDER.setID(1); - ACCOUNT_NORMAL = new Account("Normal account", "awesome description", AccountType.CUSTOM); + ACCOUNT_NORMAL = new Account("Normal account", "awesome description", AccountType.CUSTOM, null); ACCOUNT_NORMAL.setID(3); - ACCOUNT_READONLY = new Account("Readonly account", "", AccountType.CUSTOM); + ACCOUNT_READONLY = new Account("Readonly account", "", AccountType.CUSTOM, null); ACCOUNT_READONLY.setAccountState(AccountState.READ_ONLY); - ACCOUNT_HIDDEN = new Account("Hidden account", "", AccountType.CUSTOM); + ACCOUNT_HIDDEN = new Account("Hidden account", "", AccountType.CUSTOM, null); ACCOUNT_HIDDEN.setAccountState(AccountState.HIDDEN); ACCOUNT_DEFAULT.setID(15); @@ -77,7 +77,7 @@ class AccountServiceTest ICON_PLACEHOLDER = new Icon("fas fa-landmark", null); - Mockito.when(accountRepository.save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM))).thenReturn(ACCOUNT_DEFAULT); + Mockito.when(accountRepository.save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM, null))).thenReturn(ACCOUNT_DEFAULT); Mockito.when(accountRepository.findByIsDefault(true)).thenReturn(ACCOUNT_DEFAULT); Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER)); Mockito.when(accountRepository.findById(1)).thenReturn(Optional.of(ACCOUNT_PLACEHOLDER)); @@ -97,9 +97,9 @@ class AccountServiceTest accounts.add(ACCOUNT_READONLY); accounts.add(ACCOUNT_HIDDEN); - final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM); + final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM, null); accounts.add(accountNormal2); - final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM); + final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM, null); accounts.add(accountNormal3); Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER)); @@ -115,9 +115,9 @@ class AccountServiceTest final List<Account> accounts = new ArrayList<>(); accounts.add(ACCOUNT_NORMAL); - final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM); + final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM, null); accounts.add(accountNormal2); - final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM); + final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM, null); accounts.add(accountNormal3); Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER)); @@ -133,9 +133,9 @@ class AccountServiceTest final List<Account> accounts = new ArrayList<>(); accounts.add(ACCOUNT_NORMAL); - final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM); + final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM, null); accounts.add(accountNormal2); - final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM); + final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM, null); accounts.add(accountNormal3); Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER)); @@ -159,13 +159,13 @@ class AccountServiceTest Mockito.verify(templateService, Mockito.atLeast(1)).unsetTemplatesWithAccount(Mockito.any()); // placeholder account is set as selected account - final Account accountSelected = new Account("Placeholder", "", AccountType.ALL); + final Account accountSelected = new Account("Placeholder", "", AccountType.ALL, null); accountSelected.setSelected(true); accountSelected.setID(1); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(accountSelected); // default account is set another account - final Account newDefault = new Account("Normal account", "awesome description", AccountType.CUSTOM); + final Account newDefault = new Account("Normal account", "awesome description", AccountType.CUSTOM, null); newDefault.setDefault(true); newDefault.setID(3); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(newDefault); @@ -177,8 +177,8 @@ class AccountServiceTest accountService.createDefaults(); // createDefaults() may also be called in constructor so 2 calls are possible - Mockito.verify(accountRepository, Mockito.atLeast(1)).save(new Account("Placeholder", "", AccountType.ALL)); - Mockito.verify(accountRepository, Mockito.atLeast(1)).save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM)); + Mockito.verify(accountRepository, Mockito.atLeast(1)).save(new Account("Placeholder", "", AccountType.ALL, null)); + Mockito.verify(accountRepository, Mockito.atLeast(1)).save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM, null)); } @Test @@ -186,7 +186,7 @@ class AccountServiceTest { accountService.selectAccount(3); - final Account accountSelected = new Account(ACCOUNT_NORMAL.getName(), "awesome description", AccountType.CUSTOM); + final Account accountSelected = new Account(ACCOUNT_NORMAL.getName(), "awesome description", AccountType.CUSTOM, null); accountSelected.setSelected(true); accountSelected.setID(ACCOUNT_NORMAL.getID()); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(accountSelected); @@ -200,13 +200,13 @@ class AccountServiceTest accountService.setAsDefaultAccount(3); // old default unset - final Account oldDefault = new Account(ACCOUNT_DEFAULT.getName(), "", AccountType.CUSTOM); + final Account oldDefault = new Account(ACCOUNT_DEFAULT.getName(), "", AccountType.CUSTOM, null); oldDefault.setDefault(false); oldDefault.setID(ACCOUNT_DEFAULT.getID()); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(oldDefault); // new default set - final Account newDefault = new Account(ACCOUNT_NORMAL.getName(), "awesome description", AccountType.CUSTOM); + final Account newDefault = new Account(ACCOUNT_NORMAL.getName(), "awesome description", AccountType.CUSTOM, null); newDefault.setDefault(true); newDefault.setID(ACCOUNT_NORMAL.getID()); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(newDefault); @@ -215,11 +215,11 @@ class AccountServiceTest @Test void test_updateExistingAccount() { - final Account account = new Account("my account", "awesome new description", AccountType.CUSTOM); + final Account account = new Account("my account", "awesome new description", AccountType.CUSTOM, null); account.setAccountState(AccountState.FULL_ACCESS); account.setID(22); - final Account existingAccount = new Account("existing account", "awesome description", AccountType.CUSTOM); + final Account existingAccount = new Account("existing account", "awesome description", AccountType.CUSTOM, null); existingAccount.setAccountState(AccountState.READ_ONLY); existingAccount.setIconReference(new Icon()); existingAccount.setID(22); @@ -228,7 +228,7 @@ class AccountServiceTest accountService.updateExistingAccount(account); - final Account expected = new Account("my account", "awesome new description", AccountType.CUSTOM); + final Account expected = new Account("my account", "awesome new description", AccountType.CUSTOM, null); expected.setAccountState(AccountState.FULL_ACCESS); expected.setID(22); @@ -238,12 +238,12 @@ class AccountServiceTest @Test void test_updateExistingAccount_isDefaultAccount_noFullAccessAnymore() { - final Account account = new Account("my account", "", AccountType.CUSTOM); + final Account account = new Account("my account", "", AccountType.CUSTOM, null); account.setAccountState(AccountState.READ_ONLY); account.setDefault(true); account.setID(22); - final Account existingAccount = new Account("existing account", "", AccountType.CUSTOM); + final Account existingAccount = new Account("existing account", "", AccountType.CUSTOM, null); existingAccount.setAccountState(AccountState.FULL_ACCESS); existingAccount.setIconReference(new Icon()); existingAccount.setDefault(true); @@ -255,14 +255,14 @@ class AccountServiceTest accountService.updateExistingAccount(account); // account updated - final Account expected = new Account("my account", "", AccountType.CUSTOM); + final Account expected = new Account("my account", "", AccountType.CUSTOM, null); expected.setAccountState(AccountState.READ_ONLY); expected.setDefault(true); expected.setID(22); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(expected); // new default set - final Account newDefault = new Account(ACCOUNT_NORMAL.getName(), "awesome description", AccountType.CUSTOM); + final Account newDefault = new Account(ACCOUNT_NORMAL.getName(), "awesome description", AccountType.CUSTOM, null); newDefault.setDefault(true); newDefault.setID(ACCOUNT_NORMAL.getID()); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(newDefault); @@ -271,12 +271,12 @@ class AccountServiceTest @Test void test_updateExistingAccount_isSelected_nowHidden() { - final Account account = new Account("my account", "", AccountType.CUSTOM); + final Account account = new Account("my account", "", AccountType.CUSTOM, null); account.setAccountState(AccountState.HIDDEN); account.setSelected(true); account.setID(22); - final Account existingAccount = new Account("existing account", "", AccountType.CUSTOM); + final Account existingAccount = new Account("existing account", "", AccountType.CUSTOM, null); existingAccount.setAccountState(AccountState.FULL_ACCESS); existingAccount.setIconReference(new Icon()); existingAccount.setSelected(true); @@ -287,14 +287,14 @@ class AccountServiceTest accountService.updateExistingAccount(account); // account updated - final Account expected = new Account("my account", "", AccountType.CUSTOM); + final Account expected = new Account("my account", "", AccountType.CUSTOM, null); expected.setAccountState(AccountState.HIDDEN); expected.setSelected(true); expected.setID(22); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(expected); // placeholder set as selected account - final Account accountSelected = new Account("Placeholder", "", AccountType.ALL); + final Account accountSelected = new Account("Placeholder", "", AccountType.ALL, null); accountSelected.setSelected(true); accountSelected.setID(1); Mockito.verify(accountRepository, Mockito.atLeast(1)).save(accountSelected); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconServiceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconServiceTest.java index 447688f87..9a5d7acdd 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconServiceTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconServiceTest.java @@ -47,7 +47,7 @@ class IconServiceTest void test_deleteIcon_withReferringAccount() { final Icon icon = Mockito.spy(new Icon("fas fa-icons")); - final Account account = Mockito.spy(new Account("account with icon", "", AccountType.CUSTOM, icon)); + final Account account = Mockito.spy(new Account("account with icon", "", AccountType.CUSTOM, icon, null)); Mockito.when(icon.getReferringAccount()).thenReturn(account); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconizableTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconizableTest.java index 6d267ded3..7cf4ef79e 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconizableTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/IconizableTest.java @@ -33,7 +33,7 @@ class IconizableTest @Test void test_updateIcon_noExistingItem_newEmptyIcon() { - final Account account = Mockito.spy(new Account("account with icon", "", AccountType.CUSTOM)); + final Account account = Mockito.spy(new Account("account with icon", "", AccountType.CUSTOM, null)); final Icon icon = new Icon(null, null); @@ -52,7 +52,7 @@ class IconizableTest @Test void test_updateIcon_noExistingItem_newBuiltinIcon() { - final Account account = Mockito.spy(new Account("account with icon", "", AccountType.CUSTOM)); + final Account account = Mockito.spy(new Account("account with icon", "", AccountType.CUSTOM, null)); final String builtinIdentifier = "fas fa-icons"; final Icon icon = new Icon(builtinIdentifier); @@ -75,7 +75,7 @@ class IconizableTest final String builtinIdentifier = "fas fa-icons"; final Icon icon = new Icon(builtinIdentifier); - final Account account = new Account("account with icon", "", AccountType.CUSTOM, icon); + final Account account = new Account("account with icon", "", AccountType.CUSTOM, icon, null); account.setID(18); final Account accountSpy = Mockito.spy(account); @@ -95,7 +95,7 @@ class IconizableTest void test_updateIcon_existingItem_newEmptyIcon() { final Icon icon = new Icon("fas fa-icons"); - final Account account = new Account("account with icon", "", AccountType.CUSTOM, icon); + final Account account = new Account("account with icon", "", AccountType.CUSTOM, icon, null); account.setID(18); final Account accountSpy = Mockito.spy(account); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TemplateServiceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TemplateServiceTest.java index 44b6a7df0..b5268ff33 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TemplateServiceTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TemplateServiceTest.java @@ -25,7 +25,7 @@ class TemplateServiceTest { private static final Category CATEGORY_NONE = new Category("No category", "#FFFFFF", CategoryType.NONE); - private static final Account ACCOUNT_SELECTED = new Account("Selected Account", "", AccountType.CUSTOM); + private static final Account ACCOUNT_SELECTED = new Account("Selected Account", "", AccountType.CUSTOM, null); @Mock private TemplateRepository templateRepository; @@ -58,14 +58,14 @@ class TemplateServiceTest final Template expectedTemplate = new Template(); expectedTemplate.setCategory(CATEGORY_NONE); - templateService.prepareTemplateForNewTransaction(template, false, new Account("my account", "", AccountType.CUSTOM)); + templateService.prepareTemplateForNewTransaction(template, false, new Account("my account", "", AccountType.CUSTOM, null)); assertThat(template).isEqualTo(expectedTemplate); } @Test void test_prepareTemplateForNewTransaction_accountIsFullAccess_noPreparation() { - final Account account = new Account("Account", "", AccountType.CUSTOM); + final Account account = new Account("Account", "", AccountType.CUSTOM, null); account.setAccountState(AccountState.FULL_ACCESS); final Template template = new Template(); @@ -83,7 +83,7 @@ class TemplateServiceTest @Test void test_prepareTemplateForNewTransaction_accountIsNotFullAccess_noPreparation() { - final Account account = new Account("Account", "", AccountType.CUSTOM); + final Account account = new Account("Account", "", AccountType.CUSTOM, null); account.setAccountState(AccountState.READ_ONLY); final Template template = new Template(); @@ -104,10 +104,10 @@ class TemplateServiceTest @Test void test_prepareTemplateForNewTransaction_transferAccountIsFullAccess_noPreparation() { - final Account account = new Account("Account", "", AccountType.CUSTOM); + final Account account = new Account("Account", "", AccountType.CUSTOM, null); account.setAccountState(AccountState.FULL_ACCESS); - final Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM); + final Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM, null); transferAccount.setAccountState(AccountState.FULL_ACCESS); final Template template = new Template(); @@ -127,10 +127,10 @@ class TemplateServiceTest @Test void test_prepareTemplateForNewTransaction_transferAccountIsNotFullAccess_noPreparation() { - final Account account = new Account("Account", "", AccountType.CUSTOM); + final Account account = new Account("Account", "", AccountType.CUSTOM, null); account.setAccountState(AccountState.FULL_ACCESS); - final Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM); + final Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM, null); transferAccount.setAccountState(AccountState.READ_ONLY); final Template template = new Template(); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionImportServiceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionImportServiceTest.java index 30e12772d..f29571d1f 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionImportServiceTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionImportServiceTest.java @@ -32,7 +32,7 @@ class TransactionImportServiceTest { private static final Category CATEGORY_NONE = new Category("No category", "#FFFFFF", CategoryType.NONE); private static final Category CATEGORY_CUSTOM = new Category("CustomCategory", "#0F0F0F", CategoryType.CUSTOM); - private static final Account ACCOUNT = new Account("MyAccount", "", AccountType.CUSTOM); + private static final Account ACCOUNT = new Account("MyAccount", "", AccountType.CUSTOM, null); @Mock private HelpersService helpersService; diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSearchSpecificationsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSearchSpecificationsTest.java index c6c27fafa..3de3b390a 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSearchSpecificationsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSearchSpecificationsTest.java @@ -90,9 +90,9 @@ class TransactionSearchSpecificationsTest @BeforeEach public void init() { - account = accountRepository.save(new Account("TestAccount", "", AccountType.CUSTOM)); - account2 = accountRepository.save(new Account("TestAccount2", "", AccountType.CUSTOM)); - accountHidden = accountRepository.save(new Account("Hidden account", "", AccountType.CUSTOM)); + account = accountRepository.save(new Account("TestAccount", "", AccountType.CUSTOM, null)); + account2 = accountRepository.save(new Account("TestAccount2", "", AccountType.CUSTOM, null)); + accountHidden = accountRepository.save(new Account("Hidden account", "", AccountType.CUSTOM, null)); accountHidden.setAccountState(AccountState.HIDDEN); category1 = categoryRepository.save(new Category("Category1", "#ff0000", CategoryType.CUSTOM)); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceDatabaseTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceDatabaseTest.java index cb6302dcc..aa4430c07 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceDatabaseTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceDatabaseTest.java @@ -77,7 +77,7 @@ class TransactionServiceDatabaseTest @BeforeEach void beforeEach() { - Account secondAccount = new Account("Second Account", "", AccountType.CUSTOM); + Account secondAccount = new Account("Second Account", "", AccountType.CUSTOM, null); secondAccount = accountRepository.save(secondAccount); Category category1 = new Category("Regen", "#ffcc00", CategoryType.CUSTOM); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceTest.java index f38c17e79..44f62632e 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionServiceTest.java @@ -29,7 +29,7 @@ class TransactionServiceTest private static final Category CATEGORY_REST = new Category("Balance", "#FFFF00", CategoryType.REST); private static final Category CATEGORY_CUSTOM = new Category("CustomCategory", "#0F0F0F", CategoryType.CUSTOM); - private static final Account ACCOUNT = new Account("MyAccount", "", AccountType.CUSTOM); + private static final Account ACCOUNT = new Account("MyAccount", "", AccountType.CUSTOM, null); @Mock private TransactionRepository transactionRepository; diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSpecificationsTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSpecificationsTest.java index 73061e91d..748394280 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSpecificationsTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/TransactionSpecificationsTest.java @@ -94,9 +94,9 @@ class TransactionSpecificationsTest @BeforeEach public void init() { - account = accountRepository.save(new Account("TestAccount", "", AccountType.CUSTOM)); - account2 = accountRepository.save(new Account("TestAccount2", "", AccountType.CUSTOM)); - accountHidden = accountRepository.save(new Account("Hidden Account", "", AccountType.CUSTOM)); + account = accountRepository.save(new Account("TestAccount", "", AccountType.CUSTOM, null)); + account2 = accountRepository.save(new Account("TestAccount2", "", AccountType.CUSTOM, null)); + accountHidden = accountRepository.save(new Account("Hidden Account", "", AccountType.CUSTOM, null)); accountHidden.setAccountState(AccountState.HIDDEN); categoryUnused = categoryRepository.save(new Category("CategoryUnused", "#00ff00", CategoryType.CUSTOM)); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseExportTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseExportTest.java index b86238ec0..1dd44679b 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseExportTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseExportTest.java @@ -206,9 +206,9 @@ class DatabaseExportTest Mockito.when(categoryService.getAllEntitiesAsc()).thenReturn(List.of(categoryNone, categoryCustom)); // accounts - Account account1 = new Account("Source_Account_1", "awesome description", AccountType.CUSTOM); + Account account1 = new Account("Source_Account_1", "awesome description", AccountType.CUSTOM, null); account1.setID(2); - Account account2 = new Account("Source_Account_2", "", AccountType.CUSTOM); + Account account2 = new Account("Source_Account_2", "", AccountType.CUSTOM, null); account2.setID(3); AccountRepository accountRepositoryMock = Mockito.mock(AccountRepository.class); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseParser_v11_convertToInternalTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseParser_v11_convertToInternalTest.java index 2c22f94f9..a1b45ea18 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseParser_v11_convertToInternalTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/DatabaseParser_v11_convertToInternalTest.java @@ -121,7 +121,7 @@ class DatabaseParser_v11_convertToInternalTest final Icon icon = new Icon(accountImage); icon.setID(1); - final Account account = new Account("Second Account", "Lorem Ipsum", AccountType.CUSTOM, icon); + final Account account = new Account("Second Account", "Lorem Ipsum", AccountType.CUSTOM, icon, null); account.setID(3); assertThat(database.getAccounts()).hasSize(3) @@ -206,7 +206,7 @@ class DatabaseParser_v11_convertToInternalTest DatabaseParser_v11 importer = new DatabaseParser_v11(json); InternalDatabase database = importer.parseDatabaseFromJSON().convertToInternal(); - Account account1 = new Account("Default", "", AccountType.CUSTOM); + Account account1 = new Account("Default", "", AccountType.CUSTOM, null); account1.setID(2); Image image = new Image(new Byte[0], "awesomeIcon.png", ImageFileExtension.PNG); @@ -215,7 +215,7 @@ class DatabaseParser_v11_convertToInternalTest Icon accountIcon = new Icon(image); accountIcon.setID(1); - Account account2 = new Account("Second Account", "Lorem Ipsum", AccountType.CUSTOM); + Account account2 = new Account("Second Account", "Lorem Ipsum", AccountType.CUSTOM, null); account2.setIconReference(accountIcon); account2.setID(3); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/ImportServiceTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/ImportServiceTest.java index d5ddf919a..fd37759f2 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/ImportServiceTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/ImportServiceTest.java @@ -215,11 +215,11 @@ class ImportServiceTest categoryRent); // assert accounts - final Account accountPlaceholder = createAccount(1, "Placeholder", "", AccountType.ALL, AccountState.FULL_ACCESS, iconAllAccounts, false, false); - final Account accountDefault = createAccount(2, "Default Account", "", AccountType.CUSTOM, AccountState.FULL_ACCESS, iconAccountDefault, true, true); - final Account accountDefaultNew = createAccount(3, "My Default Account", "", AccountType.CUSTOM, AccountState.FULL_ACCESS, iconAccountDefaultNew, false, false); - final Account accountReadOnly = createAccount(4, "Read-only account", "", AccountType.CUSTOM, AccountState.READ_ONLY, iconAccountReadOnly, false, false); - final Account accountSecond = createAccount(5, "Second Account", "Lorem Ipsum", AccountType.CUSTOM, AccountState.FULL_ACCESS, iconAccountSecond, false, false); + final Account accountPlaceholder = createAccount(1, "Placeholder", "", AccountType.ALL, AccountState.FULL_ACCESS, iconAllAccounts, false, false, null); + final Account accountDefault = createAccount(2, "Default Account", "", AccountType.CUSTOM, AccountState.FULL_ACCESS, iconAccountDefault, true, true, null); + final Account accountDefaultNew = createAccount(3, "My Default Account", "", AccountType.CUSTOM, AccountState.FULL_ACCESS, iconAccountDefaultNew, false, false, null); + final Account accountReadOnly = createAccount(4, "Read-only account", "", AccountType.CUSTOM, AccountState.READ_ONLY, iconAccountReadOnly, false, false, null); + final Account accountSecond = createAccount(5, "Second Account", "Lorem Ipsum", AccountType.CUSTOM, AccountState.FULL_ACCESS, iconAccountSecond, false, false, null); assertThat(accountRepository.findAll()) .hasSize(5) .contains(accountPlaceholder, @@ -461,9 +461,9 @@ class ImportServiceTest return category; } - private Account createAccount(int ID, String name, String description, AccountType type, AccountState state, Icon icon, boolean isSelected, boolean isDefault) + private Account createAccount(int ID, String name, String description, AccountType type, AccountState state, Icon icon, boolean isSelected, boolean isDefault, LocalDate endDate) { - final Account account = new Account(name, description, type, icon); + final Account account = new Account(name, description, type, icon, endDate); account.setID(ID); account.setAccountState(state); account.setSelected(isSelected); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/AccountImporterTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/AccountImporterTest.java index bc9b7169a..a91317eca 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/AccountImporterTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/AccountImporterTest.java @@ -27,16 +27,16 @@ class AccountImporterTest extends ImporterTestBase @Test void test_importAccounts() { - final Account sourceAccount = new Account("SourceAccount", "", AccountType.CUSTOM); + final Account sourceAccount = new Account("SourceAccount", "", AccountType.CUSTOM, null); sourceAccount.setID(2); - final Account sourceAccount2 = new Account("SourceAccount 2", "", AccountType.CUSTOM); + final Account sourceAccount2 = new Account("SourceAccount 2", "", AccountType.CUSTOM, null); sourceAccount2.setID(7); - final Account destinationAccount = new Account("DestinationAccount", "", AccountType.CUSTOM); + final Account destinationAccount = new Account("DestinationAccount", "", AccountType.CUSTOM, null); destinationAccount.setID(1); - final Account destinationAccount2 = new Account("DestinationAccount 2", "", AccountType.CUSTOM); + final Account destinationAccount2 = new Account("DestinationAccount 2", "", AccountType.CUSTOM, null); destinationAccount2.setID(2); final AccountImporter importer = new AccountImporter(accountRepository); @@ -51,10 +51,10 @@ class AccountImporterTest extends ImporterTestBase @Test void test_importAccounts_placeholder() { - final Account placeholderAccount = new Account("Placeholder", "", AccountType.ALL); + final Account placeholderAccount = new Account("Placeholder", "", AccountType.ALL, null); placeholderAccount.setID(12); - final Account existingPlaceholderAccount = new Account("Placeholder", "", AccountType.ALL); + final Account existingPlaceholderAccount = new Account("Placeholder", "", AccountType.ALL, null); existingPlaceholderAccount.setID(1); accountRepository.save(existingPlaceholderAccount); @@ -69,10 +69,10 @@ class AccountImporterTest extends ImporterTestBase @Test void test_importAccounts_nameAlreadyExists() { - final Account account = new Account("ABC", "", AccountType.CUSTOM); + final Account account = new Account("ABC", "", AccountType.CUSTOM, null); account.setID(12); - final Account existingAccount = new Account("ABC", "", AccountType.CUSTOM); + final Account existingAccount = new Account("ABC", "", AccountType.CUSTOM, null); existingAccount.setID(1); accountRepository.save(existingAccount); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TemplateImporterTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TemplateImporterTest.java index 505c7e694..2ff33c045 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TemplateImporterTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TemplateImporterTest.java @@ -59,10 +59,10 @@ class TemplateImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); - Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM); + Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM, null); transferAccount = accountRepository.save(transferAccount); Icon icon = new Icon("fas fa-icons"); @@ -115,7 +115,7 @@ class TemplateImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); Icon icon = new Icon("fas fa-icons"); @@ -179,7 +179,7 @@ class TemplateImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); Icon icon = new Icon("fas fa-icons"); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TransactionImporterTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TransactionImporterTest.java index c8d21e2a4..710589a63 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TransactionImporterTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/database/importer/TransactionImporterTest.java @@ -52,7 +52,7 @@ class TransactionImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); final Transaction transaction = new Transaction(); @@ -96,10 +96,10 @@ class TransactionImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); - Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM); + Account transferAccount = new Account("Transfer Account", "", AccountType.CUSTOM, null); transferAccount = accountRepository.save(transferAccount); final Transaction transaction = new Transaction(); @@ -144,7 +144,7 @@ class TransactionImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); final Transaction transaction = new Transaction(); @@ -192,7 +192,7 @@ class TransactionImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); final Transaction transaction = new Transaction(); @@ -246,7 +246,7 @@ class TransactionImporterTest extends ImporterTestBase Category category = new Category("Awesome Category", "#ff0000", CategoryType.CUSTOM); category = categoryRepository.save(category); - Account account = new Account("Awesome Account", "", AccountType.CUSTOM); + Account account = new Account("Awesome Account", "", AccountType.CUSTOM, null); account = accountRepository.save(account); diff --git a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/repeating/RepeatingTransactionUpdaterTest.java b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/repeating/RepeatingTransactionUpdaterTest.java index e6a67bf1c..59be543a0 100644 --- a/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/repeating/RepeatingTransactionUpdaterTest.java +++ b/BudgetMasterServer/src/test/java/de/deadlocker8/budgetmaster/unit/repeating/RepeatingTransactionUpdaterTest.java @@ -63,7 +63,7 @@ class RepeatingTransactionUpdaterTest new RepeatingModifierYears(1), new RepeatingEndAfterXTimes(2)); - final Account account = new Account("Account", "", AccountType.CUSTOM); + final Account account = new Account("Account", "", AccountType.CUSTOM, null); TRANSACTION_1 = new Transaction(); TRANSACTION_1.setName("abc"); -- GitLab