-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b864cc
commit b327188
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...a/de/deadlocker8/budgetmaster/unit/settings/containers/AccountsSettingsContainerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package de.deadlocker8.budgetmaster.unit.settings.containers; | ||
|
||
import de.deadlocker8.budgetmaster.settings.Settings; | ||
import de.deadlocker8.budgetmaster.settings.SettingsService; | ||
import de.deadlocker8.budgetmaster.settings.containers.AccountsSettingsContainer; | ||
import de.deadlocker8.budgetmaster.unit.helpers.LocalizedTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
import org.springframework.validation.BeanPropertyBindingResult; | ||
import org.springframework.validation.Errors; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
@ExtendWith(SpringExtension.class) | ||
@LocalizedTest | ||
class AccountsSettingsContainerTest | ||
{ | ||
@Mock | ||
private SettingsService settingsService; | ||
|
||
@Test | ||
void test_validate_valid() | ||
{ | ||
final AccountsSettingsContainer container = new AccountsSettingsContainer(true); | ||
|
||
final Errors errors = new BeanPropertyBindingResult(container, "container"); | ||
container.validate(errors); | ||
|
||
assertThat(errors.getAllErrors()) | ||
.isEmpty(); | ||
} | ||
|
||
@Test | ||
void test_updateSettings() | ||
{ | ||
final Settings defaultSettings = Settings.getDefault(); | ||
|
||
Mockito.when(settingsService.getSettings()).thenReturn(defaultSettings); | ||
|
||
final AccountsSettingsContainer container = new AccountsSettingsContainer(false); | ||
final Settings updatedSettings = container.updateSettings(settingsService); | ||
|
||
assertThat(updatedSettings) | ||
.hasFieldOrPropertyWithValue("accountEndDateReminderActivated", false); | ||
} | ||
} |