Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • demo
  • master
  • renovate/assertj-core.version
  • renovate/datatables.version
  • renovate/junit-jupiter-engine.version
  • renovate/major-fontawesome.version
  • renovate/opencsv.version
  • renovate/org.springframework.boot-spring-boot-starter-parent-3.x
  • renovate/selenium.version
  • renovate/testcontainer.version
  • v1_8_1
  • testPipeline2
  • v.2.5.0
  • v.2.5.1
  • v1.0.0
  • v1.1.0
  • v1.2.0
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.4.0
  • v1.4.1
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.7.1
  • v1.8.0
  • v2.0.0
  • v2.0.1
  • v2.1.0
  • v2.1.1
  • v2.1.2
  • v2.10.0
  • v2.11.0
  • v2.12.0
  • v2.13.0
  • v2.14.0
  • v2.15.0
  • v2.15.1
  • v2.16.0
  • v2.16.1
  • v2.17.0
  • v2.17.1
  • v2.17.2
  • v2.18.0
  • v2.18.1
  • v2.2.0
  • v2.2.1
  • v2.3.0
  • v2.3.1
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v2.4.5
  • v2.5.0
  • v2.5.1
  • v2.6.0
  • v2.6.1
  • v2.7.0
  • v2.8.0
  • v2.9.0
  • v2.9.1
  • v2.9.2
65 results

Target

Select target project
  • deadlocker8/BudgetMaster
1 result
Select Git revision
  • demo
  • master
  • renovate/assertj-core.version
  • renovate/datatables.version
  • renovate/junit-jupiter-engine.version
  • renovate/major-fontawesome.version
  • renovate/opencsv.version
  • renovate/org.springframework.boot-spring-boot-starter-parent-3.x
  • renovate/selenium.version
  • renovate/testcontainer.version
  • v1_8_1
  • testPipeline2
  • v.2.5.0
  • v.2.5.1
  • v1.0.0
  • v1.1.0
  • v1.2.0
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.4.0
  • v1.4.1
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.7.1
  • v1.8.0
  • v2.0.0
  • v2.0.1
  • v2.1.0
  • v2.1.1
  • v2.1.2
  • v2.10.0
  • v2.11.0
  • v2.12.0
  • v2.13.0
  • v2.14.0
  • v2.15.0
  • v2.15.1
  • v2.16.0
  • v2.16.1
  • v2.17.0
  • v2.17.1
  • v2.17.2
  • v2.18.0
  • v2.18.1
  • v2.2.0
  • v2.2.1
  • v2.3.0
  • v2.3.1
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v2.4.5
  • v2.5.0
  • v2.5.1
  • v2.6.0
  • v2.6.1
  • v2.7.0
  • v2.8.0
  • v2.9.0
  • v2.9.1
  • v2.9.2
65 results
Show changes
Showing
with 314 additions and 90 deletions
<#macro scripts> <#macro scripts>
<#import "/spring.ftl" as s> <#import "/spring.ftl" as s>
<script src="<@s.url '/webjars/jquery/3.7.1/jquery.min.js'/>"></script> <script src="<@s.url '/webjars/jquery/jquery.min.js'/>"></script>
<script src="<@s.url '/webjars/materializecss/1.0.0/js/materialize.min.js'/>"></script> <script src="<@s.url '/webjars/materializecss/js/materialize.min.js'/>"></script>
<script src="<@s.url '/webjars/mousetrap/1.6.5/mousetrap.js'/>"></script> <script src="<@s.url '/webjars/mousetrap/mousetrap.js'/>"></script>
<script> <script>
rootURL = "<@s.url ''/>" rootURL = "<@s.url ''/>"
</script> </script>
......
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
<!-- Scripts--> <!-- Scripts-->
<#import "../helpers/scripts.ftl" as scripts> <#import "../helpers/scripts.ftl" as scripts>
<@scripts.scripts/> <@scripts.scripts/>
<script src="<@s.url '/webjars/sortablejs/1.15.3/Sortable.min.js'/>"></script> <script src="<@s.url '/webjars/sortablejs/Sortable.min.js'/>"></script>
<script src="<@s.url '/js/reports.js'/>"></script> <script src="<@s.url '/js/reports.js'/>"></script>
<script src="<@s.url '/js/globalDatePicker.js'/>"></script> <script src="<@s.url '/js/globalDatePicker.js'/>"></script>
<script src="<@s.url '/js/filter.js'/>"></script> <script src="<@s.url '/js/filter.js'/>"></script>
......
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
<!-- Scripts--> <!-- Scripts-->
<#import "../helpers/scripts.ftl" as scripts> <#import "../helpers/scripts.ftl" as scripts>
<@scripts.scripts/> <@scripts.scripts/>
<script src="<@s.url '/webjars/vanilla-picker/2.12.3/dist/vanilla-picker.min.js'/>"></script> <script src="<@s.url '/webjars/vanilla-picker/dist/vanilla-picker.min.js'/>"></script>
<script src="<@s.url '/js/helpers.js'/>"></script> <script src="<@s.url '/js/helpers.js'/>"></script>
<script src="<@s.url '/js/transactions.js'/>"></script> <script src="<@s.url '/js/transactions.js'/>"></script>
<script src="<@s.url '/js/templates.js'/>"></script> <script src="<@s.url '/js/templates.js'/>"></script>
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<#import "../helpers/scripts.ftl" as scripts> <#import "../helpers/scripts.ftl" as scripts>
<@scripts.scripts/> <@scripts.scripts/>
<script src="<@s.url '/webjars/sortablejs/1.15.3/Sortable.min.js'/>"></script> <script src="<@s.url '/webjars/sortablejs/Sortable.min.js'/>"></script>
<script src="<@s.url '/js/templates.js'/>"></script> <script src="<@s.url '/js/templates.js'/>"></script>
</@header.body> </@header.body>
</html> </html>
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<@header.style "transactionImport"/> <@header.style "transactionImport"/>
<@header.style "collapsible"/> <@header.style "collapsible"/>
<#import "/spring.ftl" as s> <#import "/spring.ftl" as s>
<link rel="stylesheet" href="<@s.url '/webjars/datatables/2.1.0/css/dataTables.dataTables.min.css'/>"/> <link rel="stylesheet" href="<@s.url '/webjars/datatables/css/dataTables.dataTables.min.css'/>"/>
</head> </head>
<@header.body> <@header.body>
<#import "../helpers/navbar.ftl" as navbar> <#import "../helpers/navbar.ftl" as navbar>
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<!-- Scripts--> <!-- Scripts-->
<#import "../helpers/scripts.ftl" as scripts> <#import "../helpers/scripts.ftl" as scripts>
<@scripts.scripts/> <@scripts.scripts/>
<script src="<@s.url '/webjars/datatables/2.1.0/js/dataTables.min.js'/>"></script> <script src="<@s.url '/webjars/datatables/js/dataTables.min.js'/>"></script>
<script src="<@s.url '/js/transactionImport.js'/>"></script> <script src="<@s.url '/js/transactionImport.js'/>"></script>
</@header.body> </@header.body>
</html> </html>
...@@ -7,5 +7,5 @@ public class TestConstants ...@@ -7,5 +7,5 @@ public class TestConstants
// empty // empty
} }
public static final String POSTGRES_VERSION = "postgres:17.0"; public static final String POSTGRES_VERSION = "postgres:17.4";
} }
...@@ -45,15 +45,21 @@ class AccountTest extends SeleniumTestBase ...@@ -45,15 +45,21 @@ class AccountTest extends SeleniumTestBase
// delete account "zzzz" if existing // delete account "zzzz" if existing
driver.get(helper.getUrl() + "/accounts"); driver.get(helper.getUrl() + "/accounts");
ensureHiddenAccountsAreIncludedInFilter();
List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr")); List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr"));
for(WebElement row : accountRows) for(WebElement row : accountRows)
{ {
final List<WebElement> columns = row.findElements(By.tagName("td")); final List<WebElement> columns = row.findElements(By.tagName("td"));
final String name = columns.get(2).getText(); if(columns.isEmpty())
{
continue;
}
final String name = columns.get(3).getText();
if(name.equals("zzzz")) if(name.equals("zzzz"))
{ {
columns.get(4).findElements(By.tagName("a")).get(1).click(); columns.get(5).findElements(By.tagName("a")).get(1).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".modal-content h4"), "Delete Account")); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".modal-content h4"), "Delete Account"));
...@@ -90,6 +96,7 @@ class AccountTest extends SeleniumTestBase ...@@ -90,6 +96,7 @@ class AccountTest extends SeleniumTestBase
// assert // assert
assertThat(driver.getCurrentUrl()).endsWith("/accounts"); assertThat(driver.getCurrentUrl()).endsWith("/accounts");
ensureHiddenAccountsAreIncludedInFilter();
accountRows = driver.findElements(By.cssSelector(".account-container tr")); accountRows = driver.findElements(By.cssSelector(".account-container tr"));
assertThat(accountRows).hasSize(numberOfAccountsBefore); assertThat(accountRows).hasSize(numberOfAccountsBefore);
...@@ -119,15 +126,17 @@ class AccountTest extends SeleniumTestBase ...@@ -119,15 +126,17 @@ class AccountTest extends SeleniumTestBase
// assert // assert
assertThat(driver.getCurrentUrl()).endsWith("/accounts"); assertThat(driver.getCurrentUrl()).endsWith("/accounts");
ensureHiddenAccountsAreIncludedInFilter();
List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr")); List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr"));
assertThat(accountRows).hasSize(6); assertThat(accountRows).hasSize(7);
assertAccountColumns(accountRows.get(0).findElements(By.tagName("td")), true, true, AccountState.FULL_ACCESS, "Default Account", ""); assertAccountColumns(accountRows.get(1).findElements(By.tagName("td")), true, true, AccountState.FULL_ACCESS, "Default Account", "");
assertAccountColumns(accountRows.get(1).findElements(By.tagName("td")), true, false, AccountState.FULL_ACCESS, "DefaultAccount0815", ""); assertAccountColumns(accountRows.get(2).findElements(By.tagName("td")), true, false, AccountState.FULL_ACCESS, "DefaultAccount0815", "");
assertAccountColumns(accountRows.get(2).findElements(By.tagName("td")), false, false, AccountState.HIDDEN, "hidden account", ""); assertAccountColumns(accountRows.get(3).findElements(By.tagName("td")), false, false, AccountState.HIDDEN, "hidden account", "");
assertAccountColumns(accountRows.get(3).findElements(By.tagName("td")), false, false, AccountState.READ_ONLY, "read only account", ""); assertAccountColumns(accountRows.get(4).findElements(By.tagName("td")), false, false, AccountState.READ_ONLY, "read only account", "");
assertAccountColumns(accountRows.get(4).findElements(By.tagName("td")), true, false, AccountState.FULL_ACCESS, "sfsdf", ""); assertAccountColumns(accountRows.get(5).findElements(By.tagName("td")), true, false, AccountState.FULL_ACCESS, "sfsdf", "");
assertAccountColumns(accountRows.get(5).findElements(By.tagName("td")), false, false, AccountState.READ_ONLY, name, ""); assertAccountColumns(accountRows.get(6).findElements(By.tagName("td")), false, false, AccountState.READ_ONLY, name, "");
} }
@Test @Test
...@@ -154,11 +163,12 @@ class AccountTest extends SeleniumTestBase ...@@ -154,11 +163,12 @@ class AccountTest extends SeleniumTestBase
// assert // assert
assertThat(driver.getCurrentUrl()).endsWith("/accounts"); assertThat(driver.getCurrentUrl()).endsWith("/accounts");
ensureHiddenAccountsAreIncludedInFilter();
List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr")); List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr"));
assertThat(accountRows).hasSize(6); assertThat(accountRows).hasSize(7);
final WebElement icon = accountRows.get(5).findElements(By.tagName("td")).get(1); final WebElement icon = accountRows.get(6).findElements(By.tagName("td")).get(0);
assertThat(icon).hasFieldOrPropertyWithValue("text", name.substring(0, 1).toUpperCase()); assertThat(icon).hasFieldOrPropertyWithValue("text", name.substring(0, 1).toUpperCase());
assertThat(icon.findElement(By.tagName("span")).getCssValue("color")).isEqualTo("rgb(255, 0, 0)"); assertThat(icon.findElement(By.tagName("span")).getCssValue("color")).isEqualTo("rgb(255, 0, 0)");
} }
...@@ -189,11 +199,12 @@ class AccountTest extends SeleniumTestBase ...@@ -189,11 +199,12 @@ class AccountTest extends SeleniumTestBase
// assert // assert
assertThat(driver.getCurrentUrl()).endsWith("/accounts"); assertThat(driver.getCurrentUrl()).endsWith("/accounts");
ensureHiddenAccountsAreIncludedInFilter();
List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr")); List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr"));
assertThat(accountRows).hasSize(6); assertThat(accountRows).hasSize(7);
final WebElement icon = accountRows.get(5).findElements(By.tagName("td")).get(1); final WebElement icon = accountRows.get(6).findElements(By.tagName("td")).get(0);
assertThat(icon.findElement(By.cssSelector("span i")).getAttribute("class")).isEqualTo("fas fa-address-book account-select-icon"); assertThat(icon.findElement(By.cssSelector("span i")).getAttribute("class")).isEqualTo("fas fa-address-book account-select-icon");
assertThat(icon.findElement(By.tagName("span")).getCssValue("color")).isEqualTo("rgb(255, 0, 0)"); assertThat(icon.findElement(By.tagName("span")).getCssValue("color")).isEqualTo("rgb(255, 0, 0)");
} }
...@@ -224,11 +235,12 @@ class AccountTest extends SeleniumTestBase ...@@ -224,11 +235,12 @@ class AccountTest extends SeleniumTestBase
// assert // assert
assertThat(driver.getCurrentUrl()).endsWith("/accounts"); assertThat(driver.getCurrentUrl()).endsWith("/accounts");
ensureHiddenAccountsAreIncludedInFilter();
List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr")); List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr"));
assertThat(accountRows).hasSize(6); assertThat(accountRows).hasSize(7);
final WebElement icon = accountRows.get(5).findElements(By.tagName("td")).get(1); final WebElement icon = accountRows.get(6).findElements(By.tagName("td")).get(0);
assertThat(icon.findElement(By.cssSelector("span img")).getAttribute("src")).startsWith(helper.getUrl() + "/media/getImageByIconID/"); assertThat(icon.findElement(By.cssSelector("span img")).getAttribute("src")).startsWith(helper.getUrl() + "/media/getImageByIconID/");
} }
...@@ -375,7 +387,7 @@ class AccountTest extends SeleniumTestBase ...@@ -375,7 +387,7 @@ class AccountTest extends SeleniumTestBase
public static void assertAccountColumns(List<WebElement> columns, boolean isDefaultIconVisible, boolean isDefaultIconSelected, AccountState expectedAccountState, String name, String description) public static void assertAccountColumns(List<WebElement> columns, boolean isDefaultIconVisible, boolean isDefaultIconSelected, AccountState expectedAccountState, String name, String description)
{ {
// icons // icons
final List<WebElement> icons = columns.get(0).findElements(By.tagName("i")); final List<WebElement> icons = columns.get(1).findElements(By.tagName("i"));
int numberOfVisibleIcons = 0; int numberOfVisibleIcons = 0;
if(isDefaultIconVisible) if(isDefaultIconVisible)
...@@ -414,10 +426,10 @@ class AccountTest extends SeleniumTestBase ...@@ -414,10 +426,10 @@ class AccountTest extends SeleniumTestBase
assertThat(icons).hasSize(numberOfVisibleIcons); assertThat(icons).hasSize(numberOfVisibleIcons);
// name // name
assertThat(columns.get(2)).hasFieldOrPropertyWithValue("text", name); assertThat(columns.get(3)).hasFieldOrPropertyWithValue("text", name);
// description // description
assertThat(columns.get(3)).hasFieldOrPropertyWithValue("text", description); assertThat(columns.get(4)).hasFieldOrPropertyWithValue("text", description);
} }
private void setAccountState(int accountID, AccountState accountState) private void setAccountState(int accountID, AccountState accountState)
...@@ -431,4 +443,17 @@ class AccountTest extends SeleniumTestBase ...@@ -431,4 +443,17 @@ class AccountTest extends SeleniumTestBase
driver.findElement(By.id("button-save-account")).click(); driver.findElement(By.id("button-save-account")).click();
} }
private void ensureHiddenAccountsAreIncludedInFilter()
{
WebDriverWait wait;
final WebElement checkboxIncludeHidden = driver.findElement(By.name("includeHidden"));
if(!checkboxIncludeHidden.isSelected())
{
driver.findElement(By.id("includeHidden")).click();
driver.findElement(By.id("accounts-filter-button")).click();
wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Accounts"));
}
}
} }
\ No newline at end of file
...@@ -235,12 +235,18 @@ class ChartTest extends SeleniumTestBase ...@@ -235,12 +235,18 @@ class ChartTest extends SeleniumTestBase
assertThat(driver.findElement(By.id("filterActiveBadge")).isDisplayed()).isFalse(); assertThat(driver.findElement(By.id("filterActiveBadge")).isDisplayed()).isFalse();
driver.findElement(By.id("chart-filter-container")).click(); driver.findElement(By.id("chart-filter-container")).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#chart-filter-container .collapsible-header")));
driver.findElement(By.id("section-type")).click(); driver.findElement(By.id("section-type")).click();
wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#section-type .text-default")));
final WebElement checkBox = driver.findElement(By.cssSelector("#section-type .text-default")); final WebElement checkBox = driver.findElement(By.cssSelector("#section-type .text-default"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", checkBox); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", checkBox);
checkBox.click(); checkBox.click();
final WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("filter-button-reset"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("filter-button-reset")));
assertThat(driver.findElement(By.id("filterActiveBadge")).isDisplayed()).isTrue(); assertThat(driver.findElement(By.id("filterActiveBadge")).isDisplayed()).isTrue();
...@@ -252,11 +258,15 @@ class ChartTest extends SeleniumTestBase ...@@ -252,11 +258,15 @@ class ChartTest extends SeleniumTestBase
driver.get(helper.getUrl() + "/charts"); driver.get(helper.getUrl() + "/charts");
driver.findElement(By.id("chart-filter-container")).click(); driver.findElement(By.id("chart-filter-container")).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#chart-filter-container .collapsible-header")));
driver.findElement(By.id("section-type")).click(); driver.findElement(By.id("section-type")).click();
wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#section-type .text-default")));
final WebElement checkBox = driver.findElement(By.cssSelector("#section-type .text-default")); final WebElement checkBox = driver.findElement(By.cssSelector("#section-type .text-default"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", checkBox); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", checkBox);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#section-type .text-default"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#section-type .text-default")));
checkBox.click(); checkBox.click();
...@@ -279,7 +289,12 @@ class ChartTest extends SeleniumTestBase ...@@ -279,7 +289,12 @@ class ChartTest extends SeleniumTestBase
wait.until(ExpectedConditions.attributeContains(By.cssSelector(chartPreviewSelector + " .chart-preview"), "class", "active")); wait.until(ExpectedConditions.attributeContains(By.cssSelector(chartPreviewSelector + " .chart-preview"), "class", "active"));
driver.findElement(By.id("chart-filter-container")).click(); driver.findElement(By.id("chart-filter-container")).click();
wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#chart-filter-container .collapsible-header")));
driver.findElement(By.id("section-type")).click(); driver.findElement(By.id("section-type")).click();
wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#section-type .text-default")));
final WebElement checkBox = driver.findElement(By.cssSelector("#section-type .text-default")); final WebElement checkBox = driver.findElement(By.cssSelector("#section-type .text-default"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", checkBox); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", checkBox);
checkBox.click(); checkBox.click();
......
...@@ -14,6 +14,7 @@ import org.openqa.selenium.support.ui.WebDriverWait; ...@@ -14,6 +14,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.File; import java.io.File;
import java.time.Duration; import java.time.Duration;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
......
...@@ -45,8 +45,8 @@ class FilterTest extends SeleniumTestBase ...@@ -45,8 +45,8 @@ class FilterTest extends SeleniumTestBase
driver.findElement(By.id("section-type")).click(); driver.findElement(By.id("section-type")).click();
wait = new WebDriverWait(driver, Duration.ofSeconds(5)); wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#section-type .text-default"))); wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#section-type .text-default")));
final WebElement checkBox = driver.findElements(By.cssSelector("#section-type .text-default")).get(0); final WebElement checkBox = driver.findElements(By.cssSelector("#section-type .text-default")).getFirst();
checkBox.click(); checkBox.click();
driver.findElement(By.id("buttonApplyFilter")).click(); driver.findElement(By.id("buttonApplyFilter")).click();
......
...@@ -43,18 +43,19 @@ class MediaTest extends SeleniumTestBase ...@@ -43,18 +43,19 @@ class MediaTest extends SeleniumTestBase
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Accounts")); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".headline"), "Accounts"));
List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr")); List<WebElement> accountRows = driver.findElements(By.cssSelector(".account-container tr"));
assertThat(accountRows).hasSize(4); assertThat(accountRows).hasSize(5);
checkImageLoaded(accountRows.get(0), "JPG"); // the first row is the table header
checkImageLoaded(accountRows.get(1), "PNG"); checkImageLoaded(accountRows.get(1), "JPG");
checkImageLoaded(accountRows.get(2), "SVG"); checkImageLoaded(accountRows.get(2), "PNG");
checkImageLoaded(accountRows.get(3), "SVG");
// the last account ist the default account created on database creation and has no image // the last account ist the default account created on database creation and has no image
} }
private void checkImageLoaded(WebElement accountRow, String imageType) private void checkImageLoaded(WebElement accountRow, String imageType)
{ {
final List<WebElement> columns = accountRow.findElements(By.tagName("td")); final List<WebElement> columns = accountRow.findElements(By.tagName("td"));
final WebElement image = columns.get(1).findElement(By.className("account-select-icon")); final WebElement image = columns.get(0).findElement(By.className("account-select-icon"));
Object result = ((JavascriptExecutor) driver).executeScript( Object result = ((JavascriptExecutor) driver).executeScript(
"return arguments[0].complete && " + "return arguments[0].complete && " +
......
...@@ -37,6 +37,7 @@ class MiscSettingsTest extends SeleniumTestBase ...@@ -37,6 +37,7 @@ class MiscSettingsTest extends SeleniumTestBase
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("miscSettingsContainer"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("miscSettingsContainer")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#miscSettingsContainer button")));
driver.findElement(By.cssSelector("#miscSettingsContainer button")).click(); driver.findElement(By.cssSelector("#miscSettingsContainer button")).click();
......
...@@ -17,6 +17,7 @@ import org.mockito.Mock; ...@@ -17,6 +17,7 @@ import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -50,6 +51,8 @@ class AccountServiceTest ...@@ -50,6 +51,8 @@ class AccountServiceTest
private Account ACCOUNT_DEFAULT; private Account ACCOUNT_DEFAULT;
private Account ACCOUNT_PLACEHOLDER; private Account ACCOUNT_PLACEHOLDER;
private Account ACCOUNT_NORMAL; private Account ACCOUNT_NORMAL;
private Account ACCOUNT_NORMAL_2;
private Account ACCOUNT_NORMAL_3;
private Account ACCOUNT_READONLY; private Account ACCOUNT_READONLY;
private Account ACCOUNT_HIDDEN; private Account ACCOUNT_HIDDEN;
...@@ -66,6 +69,9 @@ class AccountServiceTest ...@@ -66,6 +69,9 @@ class AccountServiceTest
ACCOUNT_NORMAL = new Account("Normal account", "awesome description", AccountType.CUSTOM, null); ACCOUNT_NORMAL = new Account("Normal account", "awesome description", AccountType.CUSTOM, null);
ACCOUNT_NORMAL.setID(3); ACCOUNT_NORMAL.setID(3);
ACCOUNT_NORMAL_2 = new Account("normal account", "", AccountType.CUSTOM, LocalDate.of(2025, 4, 7));
ACCOUNT_NORMAL_3 = new Account("123 account", "", AccountType.CUSTOM, null);
ACCOUNT_READONLY = new Account("Readonly account", "", AccountType.CUSTOM, null); ACCOUNT_READONLY = new Account("Readonly account", "", AccountType.CUSTOM, null);
ACCOUNT_READONLY.setAccountState(AccountState.READ_ONLY); ACCOUNT_READONLY.setAccountState(AccountState.READ_ONLY);
...@@ -96,17 +102,14 @@ class AccountServiceTest ...@@ -96,17 +102,14 @@ class AccountServiceTest
accounts.add(ACCOUNT_NORMAL); accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY); accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN); accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM, null); accounts.add(ACCOUNT_NORMAL_3);
accounts.add(accountNormal2);
final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM, null);
accounts.add(accountNormal3);
Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER)); Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER));
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts); Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
assertThat(accountService.getAllEntitiesAsc()).hasSize(6) assertThat(accountService.getAllEntitiesAsc()).hasSize(6)
.containsExactly(ACCOUNT_PLACEHOLDER, accountNormal3, ACCOUNT_HIDDEN, ACCOUNT_NORMAL, accountNormal2, ACCOUNT_READONLY); .containsExactly(ACCOUNT_PLACEHOLDER, ACCOUNT_NORMAL_3, ACCOUNT_HIDDEN, ACCOUNT_NORMAL, ACCOUNT_NORMAL_2, ACCOUNT_READONLY);
} }
@Test @Test
...@@ -114,17 +117,14 @@ class AccountServiceTest ...@@ -114,17 +117,14 @@ class AccountServiceTest
{ {
final List<Account> accounts = new ArrayList<>(); final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL); accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_NORMAL_2);
final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM, null); accounts.add(ACCOUNT_NORMAL_3);
accounts.add(accountNormal2);
final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM, null);
accounts.add(accountNormal3);
Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER)); Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER));
Mockito.when(accountRepository.findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.FULL_ACCESS)).thenReturn(accounts); Mockito.when(accountRepository.findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.FULL_ACCESS)).thenReturn(accounts);
assertThat(accountService.getAllActivatedAccountsAsc()).hasSize(4) assertThat(accountService.getAllActivatedAccountsAsc()).hasSize(4)
.containsExactly(ACCOUNT_PLACEHOLDER, accountNormal3, ACCOUNT_NORMAL, accountNormal2); .containsExactly(ACCOUNT_PLACEHOLDER, ACCOUNT_NORMAL_3, ACCOUNT_NORMAL, ACCOUNT_NORMAL_2);
} }
@Test @Test
...@@ -132,18 +132,15 @@ class AccountServiceTest ...@@ -132,18 +132,15 @@ class AccountServiceTest
{ {
final List<Account> accounts = new ArrayList<>(); final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL); accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_NORMAL_2);
final Account accountNormal2 = new Account("normal account", "", AccountType.CUSTOM, null); accounts.add(ACCOUNT_NORMAL_3);
accounts.add(accountNormal2);
final Account accountNormal3 = new Account("123 account", "", AccountType.CUSTOM, null);
accounts.add(accountNormal3);
Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER)); Mockito.when(accountRepository.findAllByType(AccountType.ALL)).thenReturn(List.of(ACCOUNT_PLACEHOLDER));
Mockito.when(accountRepository.findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.FULL_ACCESS)).thenReturn(accounts); Mockito.when(accountRepository.findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.FULL_ACCESS)).thenReturn(accounts);
Mockito.when(accountRepository.findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.READ_ONLY)).thenReturn(List.of(ACCOUNT_READONLY)); Mockito.when(accountRepository.findAllByTypeAndAccountStateOrderByNameAsc(AccountType.CUSTOM, AccountState.READ_ONLY)).thenReturn(List.of(ACCOUNT_READONLY));
assertThat(accountService.getAllReadableAccounts()).hasSize(5) assertThat(accountService.getAllReadableAccounts()).hasSize(5)
.containsExactly(ACCOUNT_PLACEHOLDER, accountNormal3, ACCOUNT_NORMAL, accountNormal2, ACCOUNT_READONLY); .containsExactly(ACCOUNT_PLACEHOLDER, ACCOUNT_NORMAL_3, ACCOUNT_NORMAL, ACCOUNT_NORMAL_2, ACCOUNT_READONLY);
} }
@Test @Test
...@@ -326,4 +323,166 @@ class AccountServiceTest ...@@ -326,4 +323,166 @@ class AccountServiceTest
assertThat(accountService.getSelectedAccountOrDefaultAsFallback()).isEqualTo(ACCOUNT_DEFAULT); assertThat(accountService.getSelectedAccountOrDefaultAsFallback()).isEqualTo(ACCOUNT_DEFAULT);
} }
@Test
void test_getFilteredEntitiesAsc_noAccounts()
{
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(List.of());
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, true, true, true, true, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration)).isEmpty();
}
@Test
void test_getFilteredEntitiesAsc_noFilter()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, true, true, true, true, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_NORMAL_3, ACCOUNT_HIDDEN, ACCOUNT_NORMAL, ACCOUNT_NORMAL_2, ACCOUNT_READONLY);
}
@Test
void test_getFilteredEntitiesAsc_onlyFullAccess()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, false, false, true, true, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_NORMAL_3, ACCOUNT_NORMAL, ACCOUNT_NORMAL_2);
}
@Test
void test_getFilteredEntitiesAsc_onlyReadOnly()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(false, true, false, true, true, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_READONLY);
}
@Test
void test_getFilteredEntitiesAsc_onlyHidden()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(false, false, true, true, true, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_HIDDEN);
}
@Test
void test_getFilteredEntitiesAsc_onlyWithEndDate()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, true, true, true, false, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_NORMAL_2);
}
@Test
void test_getFilteredEntitiesAsc_onlyWithoutEndDate()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, true, true, false, true, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_NORMAL_3, ACCOUNT_HIDDEN, ACCOUNT_NORMAL, ACCOUNT_READONLY);
}
@Test
void test_getFilteredEntitiesAsc_neitherWithNorWithoutEndDate()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, true, true, false, false, "", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.isEmpty();
}
@Test
void test_getFilteredEntitiesAsc_byName()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, true, true, true, true, "123", "");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_NORMAL_3);
}
@Test
void test_getFilteredEntitiesAsc_byDescription()
{
final List<Account> accounts = new ArrayList<>();
accounts.add(ACCOUNT_NORMAL);
accounts.add(ACCOUNT_READONLY);
accounts.add(ACCOUNT_HIDDEN);
accounts.add(ACCOUNT_NORMAL_2);
accounts.add(ACCOUNT_NORMAL_3);
Mockito.when(accountRepository.findAllByTypeOrderByNameAsc(AccountType.CUSTOM)).thenReturn(accounts);
final AccountsFilterConfiguration filterConfiguration = new AccountsFilterConfiguration(true, true, true, true, true, "", "awesome");
assertThat(accountService.getFilteredEntitiesAsc(filterConfiguration))
.containsExactly(ACCOUNT_NORMAL);
}
} }
...@@ -153,7 +153,7 @@ class TransactionServiceDatabaseTest ...@@ -153,7 +153,7 @@ class TransactionServiceDatabaseTest
LocalDate date1 = LocalDate.of(2020, 4, 30); LocalDate date1 = LocalDate.of(2020, 4, 30);
FilterConfiguration filterConfiguration = new FilterConfiguration(true, true, true, true, true, null, null, ""); FilterConfiguration filterConfiguration = new FilterConfiguration(true, true, true, true, true, null, null, "");
List<Transaction> transactions = transactionService.getTransactionsForAccount(accountRepository.findByName("Second Account"), date1, LocalDate.now(), filterConfiguration); List<Transaction> transactions = transactionService.getTransactionsForAccount(accountRepository.findByName("Second Account"), date1, LocalDate.now(), filterConfiguration, false);
assertThat(transactions) assertThat(transactions)
.hasSize(2) .hasSize(2)
.containsExactly(transactionTransfer, transactionForSecondAccount); .containsExactly(transactionTransfer, transactionForSecondAccount);
...@@ -165,7 +165,7 @@ class TransactionServiceDatabaseTest ...@@ -165,7 +165,7 @@ class TransactionServiceDatabaseTest
LocalDate date1 = LocalDate.of(2020, 4, 30); LocalDate date1 = LocalDate.of(2020, 4, 30);
FilterConfiguration filterConfiguration = new FilterConfiguration(true, true, true, true, true, null, null, ""); FilterConfiguration filterConfiguration = new FilterConfiguration(true, true, true, true, true, null, null, "");
List<Transaction> transactions = transactionService.getTransactionsForAccount(accountRepository.findAllByType(AccountType.ALL).get(0), date1, LocalDate.now(), filterConfiguration); List<Transaction> transactions = transactionService.getTransactionsForAccount(accountRepository.findAllByType(AccountType.ALL).get(0), date1, LocalDate.now(), filterConfiguration, false);
assertThat(transactions).hasSize(8); assertThat(transactions).hasSize(8);
} }
...@@ -176,7 +176,7 @@ class TransactionServiceDatabaseTest ...@@ -176,7 +176,7 @@ class TransactionServiceDatabaseTest
LocalDate date2 = LocalDate.of(2020, 5, 20); LocalDate date2 = LocalDate.of(2020, 5, 20);
FilterConfiguration filterConfiguration = new FilterConfiguration(true, true, true, true, true, null, null, ""); FilterConfiguration filterConfiguration = new FilterConfiguration(true, true, true, true, true, null, null, "");
List<Transaction> transactions = transactionService.getTransactionsForAccount(accountRepository.findByName("Default Account"), date1, date2, filterConfiguration); List<Transaction> transactions = transactionService.getTransactionsForAccount(accountRepository.findByName("Default Account"), date1, date2, filterConfiguration, false);
assertThat(transactions).hasSize(2); assertThat(transactions).hasSize(2);
} }
......
...@@ -183,7 +183,7 @@ class TransactionSpecificationsTest ...@@ -183,7 +183,7 @@ class TransactionSpecificationsTest
@Test @Test
void getIncomesAndExpendituresAndTransfers() void getIncomesAndExpendituresAndTransfers()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(5) assertThat(results).hasSize(5)
...@@ -197,7 +197,7 @@ class TransactionSpecificationsTest ...@@ -197,7 +197,7 @@ class TransactionSpecificationsTest
@Test @Test
void getIncomesAndExpenditures() void getIncomesAndExpenditures()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, false, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, false, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(4) assertThat(results).hasSize(4)
...@@ -210,7 +210,7 @@ class TransactionSpecificationsTest ...@@ -210,7 +210,7 @@ class TransactionSpecificationsTest
@Test @Test
void getIncomes() void getIncomes()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, false, false, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, false, false, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(2) assertThat(results).hasSize(2)
...@@ -221,7 +221,7 @@ class TransactionSpecificationsTest ...@@ -221,7 +221,7 @@ class TransactionSpecificationsTest
@Test @Test
void getExpenditures() void getExpenditures()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, true, false, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, true, false, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(2) assertThat(results).hasSize(2)
...@@ -232,7 +232,7 @@ class TransactionSpecificationsTest ...@@ -232,7 +232,7 @@ class TransactionSpecificationsTest
@Test @Test
void getTransfers() void getTransfers()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, false, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, false, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -242,7 +242,7 @@ class TransactionSpecificationsTest ...@@ -242,7 +242,7 @@ class TransactionSpecificationsTest
@Test @Test
void incomesAndExpendituresFalse() void incomesAndExpendituresFalse()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, false, false, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, false, false, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(4) assertThat(results).hasSize(4)
...@@ -255,7 +255,7 @@ class TransactionSpecificationsTest ...@@ -255,7 +255,7 @@ class TransactionSpecificationsTest
@Test @Test
void getTransferBackReferences_NoReferences() void getTransferBackReferences_NoReferences()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, false, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, false, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(2) assertThat(results).hasSize(2)
...@@ -266,7 +266,7 @@ class TransactionSpecificationsTest ...@@ -266,7 +266,7 @@ class TransactionSpecificationsTest
@Test @Test
void getTransferBackReferences() void getTransferBackReferences()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, false, false, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, false, false, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(2) assertThat(results).hasSize(2)
...@@ -277,7 +277,7 @@ class TransactionSpecificationsTest ...@@ -277,7 +277,7 @@ class TransactionSpecificationsTest
@Test @Test
void getTransferBackReferences_excludeExpenditures() void getTransferBackReferences_excludeExpenditures()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, true, false, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, true, false, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -287,7 +287,7 @@ class TransactionSpecificationsTest ...@@ -287,7 +287,7 @@ class TransactionSpecificationsTest
@Test @Test
void getTransferBackReferences_excludeIncomes() void getTransferBackReferences_excludeIncomes()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, false, true, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, false, true, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -298,7 +298,7 @@ class TransactionSpecificationsTest ...@@ -298,7 +298,7 @@ class TransactionSpecificationsTest
void getTransferBackReferences_WithStartDate() void getTransferBackReferences_WithStartDate()
{ {
LocalDate startDate2019 = LocalDate.of(2019, 1, 1); LocalDate startDate2019 = LocalDate.of(2019, 1, 1);
Specification spec = TransactionSpecifications.withDynamicQuery(startDate2019, LocalDate.now(), account2, false, false, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate2019, LocalDate.now(), account2, false, false, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).isEmpty(); assertThat(results).isEmpty();
...@@ -307,7 +307,7 @@ class TransactionSpecificationsTest ...@@ -307,7 +307,7 @@ class TransactionSpecificationsTest
@Test @Test
void getRepeating() void getRepeating()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, false, true, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, false, true, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -317,7 +317,7 @@ class TransactionSpecificationsTest ...@@ -317,7 +317,7 @@ class TransactionSpecificationsTest
@Test @Test
void noRepeating() void noRepeating()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, false, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, false, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(4) assertThat(results).hasSize(4)
...@@ -332,7 +332,7 @@ class TransactionSpecificationsTest ...@@ -332,7 +332,7 @@ class TransactionSpecificationsTest
{ {
List<Integer> categoryIDs = new ArrayList<>(); List<Integer> categoryIDs = new ArrayList<>();
categoryIDs.add(categoryUnused.getID()); categoryIDs.add(categoryUnused.getID());
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, categoryIDs, List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, categoryIDs, List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).isEmpty(); assertThat(results).isEmpty();
...@@ -343,7 +343,7 @@ class TransactionSpecificationsTest ...@@ -343,7 +343,7 @@ class TransactionSpecificationsTest
{ {
List<Integer> categoryIDs = new ArrayList<>(); List<Integer> categoryIDs = new ArrayList<>();
categoryIDs.add(category1.getID()); categoryIDs.add(category1.getID());
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, categoryIDs, List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, categoryIDs, List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(2) assertThat(results).hasSize(2)
...@@ -354,7 +354,7 @@ class TransactionSpecificationsTest ...@@ -354,7 +354,7 @@ class TransactionSpecificationsTest
@Test @Test
void getByFullName() void getByFullName()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), "Repeating"); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), "Repeating", false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -364,7 +364,7 @@ class TransactionSpecificationsTest ...@@ -364,7 +364,7 @@ class TransactionSpecificationsTest
@Test @Test
void getByPartialName() void getByPartialName()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), "tin"); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), "tin", false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -374,7 +374,7 @@ class TransactionSpecificationsTest ...@@ -374,7 +374,7 @@ class TransactionSpecificationsTest
@Test @Test
void getByPartialName_ExcludeTransfersWithWrongAccount() void getByPartialName_ExcludeTransfersWithWrongAccount()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, true, true, true, null, List.of(), List.of(), "tion"); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account2, true, true, true, null, List.of(), List.of(), "tion", false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -387,7 +387,7 @@ class TransactionSpecificationsTest ...@@ -387,7 +387,7 @@ class TransactionSpecificationsTest
List<Integer> tagIDs = new ArrayList<>(); List<Integer> tagIDs = new ArrayList<>();
tagIDs.add(tag1.getID()); tagIDs.add(tag1.getID());
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), tagIDs, null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), tagIDs, null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(4) assertThat(results).hasSize(4)
...@@ -404,7 +404,7 @@ class TransactionSpecificationsTest ...@@ -404,7 +404,7 @@ class TransactionSpecificationsTest
tagIDs.add(tag1.getID()); tagIDs.add(tag1.getID());
tagIDs.add(tag2.getID()); tagIDs.add(tag2.getID());
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), tagIDs, null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), tagIDs, null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(5) assertThat(results).hasSize(5)
...@@ -422,7 +422,7 @@ class TransactionSpecificationsTest ...@@ -422,7 +422,7 @@ class TransactionSpecificationsTest
List<Integer> tagIDs = new ArrayList<>(); List<Integer> tagIDs = new ArrayList<>();
tagIDs.add(tagUnused.getID()); tagIDs.add(tagUnused.getID());
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), tagIDs, null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), tagIDs, null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(3) assertThat(results).hasSize(3)
...@@ -441,7 +441,7 @@ class TransactionSpecificationsTest ...@@ -441,7 +441,7 @@ class TransactionSpecificationsTest
tagIDs.add(tag1.getID()); tagIDs.add(tag1.getID());
tagIDs.add(tag2.getID()); tagIDs.add(tag2.getID());
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, true, true, true, categoryIDs, tagIDs, "Repeating"); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, false, true, true, true, categoryIDs, tagIDs, "Repeating", false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(1) assertThat(results).hasSize(1)
...@@ -452,7 +452,7 @@ class TransactionSpecificationsTest ...@@ -452,7 +452,7 @@ class TransactionSpecificationsTest
void getFromAllAccountsExceptTransfersWithSpecificEndDate() void getFromAllAccountsExceptTransfersWithSpecificEndDate()
{ {
LocalDate endDate = LocalDate.of(2018, 11, 30); LocalDate endDate = LocalDate.of(2018, 11, 30);
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, endDate, null, true, true, false, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, endDate, null, true, true, false, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(2) assertThat(results).hasSize(2)
...@@ -463,7 +463,7 @@ class TransactionSpecificationsTest ...@@ -463,7 +463,7 @@ class TransactionSpecificationsTest
@Test @Test
void getFromAllAccountsExceptHidden() void getFromAllAccountsExceptHidden()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), null, true, true, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), null, true, true, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(6) assertThat(results).hasSize(6)
...@@ -475,10 +475,27 @@ class TransactionSpecificationsTest ...@@ -475,10 +475,27 @@ class TransactionSpecificationsTest
.contains(transferTransactionWrongAccount); .contains(transferTransactionWrongAccount);
} }
@Test
void getFromAllAccountsIncludeHidden()
{
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), null, true, true, true, null, List.of(), List.of(), null, true);
List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(7)
.contains(transaction1)
.contains(transaction2)
.contains(transaction3)
.contains(repeatingTransaction)
.contains(transferTransaction)
.contains(transferTransactionWrongAccount)
.contains(transactionInHiddenAccount);
}
@Test @Test
void checkOrder() void checkOrder()
{ {
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), null); Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), null, false);
List<Transaction> results = transactionRepository.findAll(spec); List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(5) assertThat(results).hasSize(5)
......
...@@ -44,11 +44,11 @@ import org.junit.jupiter.api.Test; ...@@ -44,11 +44,11 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Container;
...@@ -112,15 +112,15 @@ class ImportServiceTest ...@@ -112,15 +112,15 @@ class ImportServiceTest
private TagRepository tagRepository; private TagRepository tagRepository;
@Autowired @Autowired
@SpyBean @MockitoSpyBean
private TemplateGroupRepository templateGroupRepository; private TemplateGroupRepository templateGroupRepository;
@Autowired @Autowired
@SpyBean @MockitoSpyBean
private TemplateRepository templateRepository; private TemplateRepository templateRepository;
@Autowired @Autowired
@SpyBean @MockitoSpyBean
private ChartService chartService; private ChartService chartService;
@Autowired @Autowired
......
...@@ -8,6 +8,7 @@ import de.deadlocker8.budgetmaster.services.EntityType; ...@@ -8,6 +8,7 @@ import de.deadlocker8.budgetmaster.services.EntityType;
import de.deadlocker8.budgetmaster.services.ImportResultItem; import de.deadlocker8.budgetmaster.services.ImportResultItem;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
...@@ -55,6 +56,7 @@ class AccountImporterTest extends ImporterTestBase ...@@ -55,6 +56,7 @@ class AccountImporterTest extends ImporterTestBase
placeholderAccount.setID(12); placeholderAccount.setID(12);
final Account existingPlaceholderAccount = new Account("Placeholder", "", AccountType.ALL, null); final Account existingPlaceholderAccount = new Account("Placeholder", "", AccountType.ALL, null);
accountRepository.save(existingPlaceholderAccount);
existingPlaceholderAccount.setID(1); existingPlaceholderAccount.setID(1);
accountRepository.save(existingPlaceholderAccount); accountRepository.save(existingPlaceholderAccount);
...@@ -73,6 +75,7 @@ class AccountImporterTest extends ImporterTestBase ...@@ -73,6 +75,7 @@ class AccountImporterTest extends ImporterTestBase
account.setID(12); account.setID(12);
final Account existingAccount = new Account("ABC", "", AccountType.CUSTOM, null); final Account existingAccount = new Account("ABC", "", AccountType.CUSTOM, null);
accountRepository.save(existingAccount);
existingAccount.setID(1); existingAccount.setID(1);
accountRepository.save(existingAccount); accountRepository.save(existingAccount);
......
...@@ -51,8 +51,8 @@ class CategoryImporterTest extends ImporterTestBase ...@@ -51,8 +51,8 @@ class CategoryImporterTest extends ImporterTestBase
void test_importCategories_skipExisting_defaultNone() void test_importCategories_skipExisting_defaultNone()
{ {
final Category category = new Category("No category", "#ff0000", CategoryType.NONE); final Category category = new Category("No category", "#ff0000", CategoryType.NONE);
categoryRepository.save(category);
category.setID(1); category.setID(1);
categoryRepository.save(category); categoryRepository.save(category);
final CategoryImporter importer = new CategoryImporter(categoryRepository); final CategoryImporter importer = new CategoryImporter(categoryRepository);
...@@ -67,8 +67,8 @@ class CategoryImporterTest extends ImporterTestBase ...@@ -67,8 +67,8 @@ class CategoryImporterTest extends ImporterTestBase
void test_importCategories_skipExisting_defaultRest() void test_importCategories_skipExisting_defaultRest()
{ {
final Category category = new Category("Balance", "#ff0000", CategoryType.REST); final Category category = new Category("Balance", "#ff0000", CategoryType.REST);
categoryRepository.save(category);
category.setID(1); category.setID(1);
categoryRepository.save(category); categoryRepository.save(category);
final CategoryImporter importer = new CategoryImporter(categoryRepository); final CategoryImporter importer = new CategoryImporter(categoryRepository);
......
...@@ -54,6 +54,7 @@ class IconImporterTest extends ImporterTestBase ...@@ -54,6 +54,7 @@ class IconImporterTest extends ImporterTestBase
void test_importIcons_alreadyExisting() void test_importIcons_alreadyExisting()
{ {
final Icon icon = new Icon("fas fa-icons"); final Icon icon = new Icon("fas fa-icons");
iconRepository.save(icon);
icon.setID(1); icon.setID(1);
iconRepository.save(icon); iconRepository.save(icon);
......
...@@ -46,6 +46,7 @@ class ImageImporterTest extends ImporterTestBase ...@@ -46,6 +46,7 @@ class ImageImporterTest extends ImporterTestBase
void test_importImages_alreadyExisting() void test_importImages_alreadyExisting()
{ {
final Image image = new Image(new Byte[0], "awesomeIcon.png", ImageFileExtension.PNG); final Image image = new Image(new Byte[0], "awesomeIcon.png", ImageFileExtension.PNG);
imageRepository.save(image);
image.setID(1); image.setID(1);
imageRepository.save(image); imageRepository.save(image);
......