diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 610e13b..74c1214 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -22,7 +22,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: '21' + java-version: '25' distribution: 'liberica' cache: maven diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index d58dfb7..c0bcafe 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,19 +1,3 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -wrapperVersion=3.3.2 +wrapperVersion=3.3.4 distributionType=only-script -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip diff --git a/jitpack.yml b/jitpack.yml index 5208eaf..3c79b1d 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -7,4 +7,4 @@ # Later may be supported by jdk: - - openjdk11 \ No newline at end of file + - openjdk25 \ No newline at end of file diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..ca07262 --- /dev/null +++ b/lombok.config @@ -0,0 +1,4 @@ +# Fixes compile time warning +# Spring Boot 4 requires Jackson 3 +# See https://projectlombok.org/features/experimental/Jacksonized +lombok.jacksonized.jacksonVersion += 3 diff --git a/mvnw b/mvnw index 19529dd..bd8896b 100644 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.3.2 +# Apache Maven Wrapper startup batch script, version 3.3.4 # # Optional ENV vars # ----------------- @@ -105,14 +105,17 @@ trim() { printf "%s" "${1}" | tr -d '[:space:]' } +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties while IFS="=" read -r key value; do case "${key-}" in distributionUrl) distributionUrl=$(trim "${value-}") ;; distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; esac -done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" -[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" case "${distributionUrl##*/}" in maven-mvnd-*bin.*) @@ -130,7 +133,7 @@ maven-mvnd-*bin.*) distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" ;; maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; -*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; esac # apply MVNW_REPOURL and calculate MAVEN_HOME @@ -227,7 +230,7 @@ if [ -n "${distributionSha256Sum-}" ]; then echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 exit 1 elif command -v sha256sum >/dev/null; then - if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then distributionSha256Result=true fi elif command -v shasum >/dev/null; then @@ -252,8 +255,41 @@ if command -v unzip >/dev/null; then else tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" -mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" + +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi +fi + +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f +fi + +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi + +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" clean || : exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 249bdf3..92450f9 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -19,7 +19,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM Apache Maven Wrapper startup batch script, version 3.3.4 @REM @REM Optional ENV vars @REM MVNW_REPOURL - repo url base for downloading maven distribution @@ -40,7 +40,7 @@ @SET __MVNW_ARG0_NAME__= @SET MVNW_USERNAME= @SET MVNW_PASSWORD= -@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) @echo Cannot start maven from wrapper >&2 && exit /b 1 @GOTO :EOF : end batch / begin powershell #> @@ -73,16 +73,30 @@ switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { # apply MVNW_REPOURL and calculate MAVEN_HOME # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ if ($env:MVNW_REPOURL) { - $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } - $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" } $distributionUrlName = $distributionUrl -replace '^.*/','' $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' -$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" + +$MAVEN_M2_PATH = "$HOME/.m2" if ($env:MAVEN_USER_HOME) { - $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" } -$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { @@ -134,7 +148,33 @@ if ($distributionSha256Sum) { # unzip and move Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null -Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null try { Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null } catch { diff --git a/pom.xml b/pom.xml index 5eb468d..70dd4e3 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.spacious-team broker-report-parser-api - 2025.1 + 2026.1 jar Broker Report Parser API @@ -43,11 +43,11 @@ - 11 + 17 UTF-8 UTF-8 - 1.18.38 - 3.49.1 + 1.18.46 + 4.2.0 @@ -69,7 +69,7 @@ com.github.spacious-team table-wrapper-api - 2025.1 + 2026.1 org.projectlombok @@ -85,15 +85,15 @@ provided - com.fasterxml.jackson.core + tools.jackson.core jackson-databind - 2.18.3 + 3.2.0 provided io.swagger.core.v3 - swagger-annotations - 2.2.30 + swagger-annotations-jakarta + 2.2.52 provided @@ -105,19 +105,19 @@ org.junit.jupiter junit-jupiter - 5.12.2 + 6.1.0 test org.mockito mockito-junit-jupiter - 5.17.0 + 5.23.0 test nl.jqno.equalsverifier equalsverifier - 3.19.3 + 4.5 test @@ -127,7 +127,7 @@ maven-surefire-plugin - 3.5.3 + 3.5.6 @@ -135,7 +135,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.0 + 3.15.0 true true @@ -168,6 +168,7 @@ -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED @@ -178,7 +179,7 @@ org.jacoco jacoco-maven-plugin - 0.8.13 + 0.8.15 prepare-agent @@ -198,7 +199,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.1 + 3.4.0 attach-sources diff --git a/src/main/java/org/spacious_team/broker/pojo/Portfolio.java b/src/main/java/org/spacious_team/broker/pojo/Account.java similarity index 77% rename from src/main/java/org/spacious_team/broker/pojo/Portfolio.java rename to src/main/java/org/spacious_team/broker/pojo/Account.java index 52a196d..d1b1da0 100644 --- a/src/main/java/org/spacious_team/broker/pojo/Portfolio.java +++ b/src/main/java/org/spacious_team/broker/pojo/Account.java @@ -34,14 +34,13 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Счет") -public class Portfolio { +@Schema(name = "Account") +public class Account { - @Schema(description = "Номер счета в системе учета брокера", example = "10200I", requiredMode = REQUIRED) + @Schema(description = "Account number in the broker's accounting system", example = "10200I", requiredMode = REQUIRED) private final @NotEmpty String id; - @Schema(description = "Признак активного счета: если false то счет исключается из аналитического расчета", - requiredMode = REQUIRED) + @Schema(description = "Active account flag: if false, the account is archived", requiredMode = REQUIRED) @Builder.Default private final boolean enabled = true; } diff --git a/src/main/java/org/spacious_team/broker/pojo/PortfolioCash.java b/src/main/java/org/spacious_team/broker/pojo/AccountCash.java similarity index 70% rename from src/main/java/org/spacious_team/broker/pojo/PortfolioCash.java rename to src/main/java/org/spacious_team/broker/pojo/AccountCash.java index eb30fc3..9d3b65e 100644 --- a/src/main/java/org/spacious_team/broker/pojo/PortfolioCash.java +++ b/src/main/java/org/spacious_team/broker/pojo/AccountCash.java @@ -41,26 +41,26 @@ @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) @JsonInclude(JsonInclude.Include.NON_NULL) -@Schema(name = "Остаток денежных средств") -public class PortfolioCash { +@Schema(name = "AccountCash") +public class AccountCash { // autoincrement - @Schema(description = "Внутренний идентификатор", example = "123", nullable = true) + @Schema(description = "Record ID", example = "123", nullable = true) private final @Nullable Integer id; - @Schema(description = "Номер счета в системе учета брокера", example = "10200I", requiredMode = REQUIRED) - private final @NotEmpty String portfolio; + @Schema(description = "Account number in the broker's accounting system", example = "10200I", requiredMode = REQUIRED) + private final @NotEmpty String account; - @Schema(description = "Значение актуально на дату", example = "2021-01-23T12:00:00+03:00", requiredMode = REQUIRED) + @Schema(description = "Date and time", example = "2021-01-23T12:00:00+03:00", requiredMode = REQUIRED) private final Instant timestamp; - @Schema(description = "Рынок", example = "Фондовый", requiredMode = REQUIRED) + @Schema(description = "Market", example = "Stock market", requiredMode = REQUIRED) private final String market; @EqualsAndHashCode.Exclude - @Schema(description = "Остаток денежных средств", example = "102.30", requiredMode = REQUIRED) + @Schema(description = "Cash balance", example = "102.30", requiredMode = REQUIRED) private final BigDecimal value; - @Schema(description = "Валюта", example = "RUB", requiredMode = REQUIRED) + @Schema(description = "Currency", example = "RUB", requiredMode = REQUIRED) private final @NotEmpty String currency; @EqualsAndHashCode.Include diff --git a/src/main/java/org/spacious_team/broker/pojo/PortfolioProperty.java b/src/main/java/org/spacious_team/broker/pojo/AccountProperty.java similarity index 66% rename from src/main/java/org/spacious_team/broker/pojo/PortfolioProperty.java rename to src/main/java/org/spacious_team/broker/pojo/AccountProperty.java index e278041..3dfecec 100644 --- a/src/main/java/org/spacious_team/broker/pojo/PortfolioProperty.java +++ b/src/main/java/org/spacious_team/broker/pojo/AccountProperty.java @@ -37,21 +37,21 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Свойства счета") -public class PortfolioProperty { +@Schema(name = "AccountProperty") +public class AccountProperty { // autoincrement - @Schema(description = "Внутренний идентификатор записи", example = "111", nullable = true) + @Schema(description = "Record ID", example = "111", nullable = true) private final @Nullable Integer id; - @Schema(description = "Номер счета", example = "10200I", requiredMode = REQUIRED) - private final @NotEmpty String portfolio; + @Schema(description = "Account number in the broker's accounting system", example = "10200I", requiredMode = REQUIRED) + private final @NotEmpty String account; - @Schema(description = "Информация актуальна на время", example = "2021-01-01T12:00:00+03:00", nullable = true) + @Schema(description = "Date and time", example = "2021-01-01T12:00:00+03:00", nullable = true) private final @Nullable Instant timestamp; - @Schema(description = "Свойство портфеля", example = "TOTAL_ASSETS_RUB", requiredMode = REQUIRED) - private final PortfolioPropertyType property; + @Schema(description = "Property", example = "TOTAL_ASSETS_RUB", requiredMode = REQUIRED) + private final AccountPropertyType property; - @Schema(description = "Значение свойства", example = "100.20", requiredMode = REQUIRED) + @Schema(description = "Value", example = "100.20", requiredMode = REQUIRED) private final String value; } diff --git a/src/main/java/org/spacious_team/broker/pojo/PortfolioPropertyType.java b/src/main/java/org/spacious_team/broker/pojo/AccountPropertyType.java similarity index 96% rename from src/main/java/org/spacious_team/broker/pojo/PortfolioPropertyType.java rename to src/main/java/org/spacious_team/broker/pojo/AccountPropertyType.java index 844327b..4a44532 100644 --- a/src/main/java/org/spacious_team/broker/pojo/PortfolioPropertyType.java +++ b/src/main/java/org/spacious_team/broker/pojo/AccountPropertyType.java @@ -18,7 +18,7 @@ package org.spacious_team.broker.pojo; -public enum PortfolioPropertyType { +public enum AccountPropertyType { TOTAL_ASSETS_RUB, TOTAL_ASSETS_USD // if TOTAL_ASSETS_RUB and TOTAL_ASSETS_USD exists for same date, total assets is sum of them } diff --git a/src/main/java/org/spacious_team/broker/pojo/EventCashFlow.java b/src/main/java/org/spacious_team/broker/pojo/EventCashFlow.java index c45140d..93e1393 100644 --- a/src/main/java/org/spacious_team/broker/pojo/EventCashFlow.java +++ b/src/main/java/org/spacious_team/broker/pojo/EventCashFlow.java @@ -43,31 +43,31 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Движение ДС по счету", description = "Ввод и вывод ДС, налоги, комиссии, а также выплаты по инструментам другого счета") +@Schema(name = "EventCashFlow", description = "Cash deposits and withdrawals, taxes, fees, and payouts on instruments from another account") public class EventCashFlow { // autoincrement - @Schema(description = "Идентификатор записи", example = "123", nullable = true) + @Schema(description = "Record ID", example = "123", nullable = true) private final @Nullable Integer id; - @Schema(description = "Номер счета", example = "10200I", requiredMode = REQUIRED) - private final @NotEmpty String portfolio; + @Schema(description = "Account number in the broker's accounting system", example = "10200I", requiredMode = REQUIRED) + private final @NotEmpty String account; - @Schema(description = "Время события", example = "2021-01-01T12:00:00+03:00", requiredMode = REQUIRED) + @Schema(description = "Event time", example = "2021-01-01T12:00:00+03:00", requiredMode = REQUIRED) private final Instant timestamp; @JsonProperty("event-type") - @Schema(description = "Тип события", example = "CASH", requiredMode = REQUIRED) + @Schema(description = "Event type", example = "CASH", requiredMode = REQUIRED) private final CashFlowType eventType; @EqualsAndHashCode.Exclude - @Schema(description = "Значение", example = "100.50", requiredMode = REQUIRED) + @Schema(description = "Amount", example = "100.50", requiredMode = REQUIRED) private final BigDecimal value; @Builder.Default - @Schema(description = "Валюта", example = "RUB", defaultValue = "RUB") + @Schema(description = "Currency", example = "RUB", defaultValue = "RUB") private final String currency = "RUB"; - @Schema(description = "Описание события", example = "Внесение наличных", nullable = true) + @Schema(description = "Description", example = "Deposit", nullable = true) private final @Nullable String description; /** @@ -80,7 +80,7 @@ public static boolean checkEquality(EventCashFlow cash1, EventCashFlow cash2) { //noinspection NumberEquality return Objects.equals(cash1.getEventType(), cash2.getEventType()) && Objects.equals(cash1.getTimestamp(), cash2.getTimestamp()) && - Objects.equals(cash1.getPortfolio(), cash2.getPortfolio()) && + Objects.equals(cash1.getAccount(), cash2.getAccount()) && Objects.equals(cash1.getCurrency(), cash2.getCurrency()) && ((value1 == value2) || (value1.compareTo(value2) == 0)); } diff --git a/src/main/java/org/spacious_team/broker/pojo/ForeignExchangeRate.java b/src/main/java/org/spacious_team/broker/pojo/ForeignExchangeRate.java index ed50c99..d9b800a 100644 --- a/src/main/java/org/spacious_team/broker/pojo/ForeignExchangeRate.java +++ b/src/main/java/org/spacious_team/broker/pojo/ForeignExchangeRate.java @@ -38,18 +38,18 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Официальный обменный курс") +@Schema(name = "ForeignExchangeRate") public class ForeignExchangeRate { - @Schema(description = "Дата", example = "2021-21-23", requiredMode = REQUIRED) + @Schema(description = "Date", example = "2026-06-17", requiredMode = REQUIRED) private final LocalDate date; @JsonProperty("currency-pair") - @Schema(description = "Валютная пара, для курса доллара в рублях - USDRUB", example = "USDRUB", requiredMode = REQUIRED) + @Schema(description = "Currency pair", example = "USDRUB", requiredMode = REQUIRED) private final @NotEmpty String currencyPair; @EqualsAndHashCode.Exclude - @Schema(description = "Значение обменного курса", example = "75.67", requiredMode = REQUIRED) + @Schema(description = "Currency exchange rate", example = "75.67", requiredMode = REQUIRED) private final BigDecimal rate; @EqualsAndHashCode.Include diff --git a/src/main/java/org/spacious_team/broker/pojo/Issuer.java b/src/main/java/org/spacious_team/broker/pojo/Issuer.java index 211a672..8f5caca 100644 --- a/src/main/java/org/spacious_team/broker/pojo/Issuer.java +++ b/src/main/java/org/spacious_team/broker/pojo/Issuer.java @@ -34,16 +34,16 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Эмитент") +@Schema(name = "Issuer") public class Issuer { - @Schema(description = "Внутренний идентификатор эмитента", nullable = true) + @Schema(description = "Record ID", nullable = true) private final @Nullable Integer id; - @Schema(description = "Идентификатор налогоплательщика (Россия - ИНН, США - EIN и т.д.)", + @Schema(description = "Taxpayer identification number (Russia: INN, US: EIN, etc.)", example = "7736050003", nullable = true) private final @Nullable String taxpayerId; - @Schema(description = "Наименование", example = "ПАО Газпром") + @Schema(description = "Issuer name", example = "Apple Inc.") private final @NotEmpty String name; } diff --git a/src/main/java/org/spacious_team/broker/pojo/Security.java b/src/main/java/org/spacious_team/broker/pojo/Security.java index d9ce86d..97a7423 100644 --- a/src/main/java/org/spacious_team/broker/pojo/Security.java +++ b/src/main/java/org/spacious_team/broker/pojo/Security.java @@ -35,21 +35,21 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Инструмент", description = "Акция, облигация, валютная пара, фьючерс, опцион или произвольный актив") +@Schema(name = "Security", description = "Stocks, bonds, futures, options, currency pairs and custom assets") public class Security { // autoincrement - @Schema(description = "Внутренний идентификатор инструмента", example = "123", nullable = true) + @Schema(description = "Record ID", example = "123", nullable = true) private final @Nullable Integer id; - @Schema(description = "Тип ценной бумаги", example = "STOCK", requiredMode = REQUIRED) + @Schema(description = "Security type", example = "STOCK", requiredMode = REQUIRED) private final SecurityType type; - @Schema(description = "ISIN акций и облигаций (опционально)", example = "NL0009805522", nullable = true) + @Schema(description = "ISIN of stocks and bonds", example = "NL0009805522", nullable = true) private final @Nullable @Pattern(regexp = "^[A-Z]{2}[A-Z0-9]{9}\\d$") String isin; - @Schema(description = "Тикер (опционально)", example = "YNDX, USDRUB_TOM или Si-12.21", nullable = true) + @Schema(description = "Ticker", example = "YNDX, USDRUB_TOM или Si-12.21", nullable = true) private final @Nullable String ticker; - @Schema(description = "Наименование (опционально)", example = "Yandex clA", nullable = true) + @Schema(description = "Asset name", example = "Apple Inc", nullable = true) private final @Nullable String name; } diff --git a/src/main/java/org/spacious_team/broker/pojo/SecurityDescription.java b/src/main/java/org/spacious_team/broker/pojo/SecurityDescription.java index c4f91e0..b5780f3 100644 --- a/src/main/java/org/spacious_team/broker/pojo/SecurityDescription.java +++ b/src/main/java/org/spacious_team/broker/pojo/SecurityDescription.java @@ -34,15 +34,15 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Свойства инструмента", description = "Информация об инструменте") +@Schema(name = "SecurityDescription") public class SecurityDescription { - @Schema(description = "Внутренний идентификатор инструмента", example = "123", requiredMode = REQUIRED) + @Schema(description = "Security record ID", example = "123", requiredMode = REQUIRED) private final int security; - @Schema(description = "Сектор экономики (опционально)", example = "Финансы", nullable = true) + @Schema(description = "Industry sector", example = "Information Technology", nullable = true) private final @Nullable String sector; - @Schema(description = "Внутренний идентификатор эмитента (опционально)", example = "10", nullable = true) + @Schema(description = "Issuer record ID", example = "10", nullable = true) private final @Nullable Integer issuer; } diff --git a/src/main/java/org/spacious_team/broker/pojo/SecurityEventCashFlow.java b/src/main/java/org/spacious_team/broker/pojo/SecurityEventCashFlow.java index 4f7d64e..db463e6 100644 --- a/src/main/java/org/spacious_team/broker/pojo/SecurityEventCashFlow.java +++ b/src/main/java/org/spacious_team/broker/pojo/SecurityEventCashFlow.java @@ -42,34 +42,34 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Событие по бумаге", description = "Дивиденды, купоны, амортизация, вариационная маржа, налоги, комиссии") +@Schema(name = "SecurityEventCashFlow", description = "Dividends, coupons, amortizations, variation margin, taxes, fees") public class SecurityEventCashFlow { // autoincrement - @Schema(description = "Внутренний идентификатор записи", example = "222", nullable = true) + @Schema(description = "Record ID", example = "222", nullable = true) private final @Nullable Integer id; - @Schema(description = "Номер счета в системе учета брокера", example = "10200I", requiredMode = REQUIRED) - private final @NotEmpty String portfolio; + @Schema(description = "Account number in the broker's accounting system", example = "10200I", requiredMode = REQUIRED) + private final @NotEmpty String account; - @Schema(description = "Время события", example = "2021-01-01T19:00:00+03:00", requiredMode = REQUIRED) + @Schema(description = "Event time", example = "2021-01-01T19:00:00+03:00", requiredMode = REQUIRED) private final Instant timestamp; - @Schema(description = "Инструмент", example = "123", requiredMode = REQUIRED) + @Schema(description = "Security", example = "123", requiredMode = REQUIRED) private final int security; - @Schema(description = "Количество бумаг (контрактов)", example = "10", requiredMode = REQUIRED) + @Schema(description = "Number of securities (contracts)", example = "10", requiredMode = REQUIRED) private final Integer count; @JsonProperty("event-type") - @Schema(description = "Тип события", example = "DIVIDEND", requiredMode = REQUIRED) + @Schema(description = "Event type", example = "DIVIDEND", requiredMode = REQUIRED) private final CashFlowType eventType; @EqualsAndHashCode.Exclude - @Schema(description = "Сумма", example = "100.20", requiredMode = REQUIRED) + @Schema(description = "Amount", example = "100.20", requiredMode = REQUIRED) private final BigDecimal value; @Builder.Default - @Schema(description = "Валюта", example = "RUB", defaultValue = "RUB", nullable = true) + @Schema(description = "Currency", example = "RUB", defaultValue = "RUB", nullable = true) private final String currency = "RUR"; /** @@ -80,7 +80,7 @@ public static boolean checkEquality(SecurityEventCashFlow cash1, SecurityEventCa return cash1.getSecurity() == cash2.getSecurity() && Objects.equals(cash1.getEventType(), cash2.getEventType()) && Objects.equals(cash1.getTimestamp(), cash2.getTimestamp()) && - Objects.equals(cash1.getPortfolio(), cash2.getPortfolio()); + Objects.equals(cash1.getAccount(), cash2.getAccount()); } /** diff --git a/src/main/java/org/spacious_team/broker/pojo/SecurityQuote.java b/src/main/java/org/spacious_team/broker/pojo/SecurityQuote.java index 592acdf..b8575ce 100644 --- a/src/main/java/org/spacious_team/broker/pojo/SecurityQuote.java +++ b/src/main/java/org/spacious_team/broker/pojo/SecurityQuote.java @@ -39,34 +39,34 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Котировка") +@Schema(name = "SecurityQuote", description = "Quotes for traded instruments and valuations for custom assets") public class SecurityQuote { // autoincrement - @Schema(description = "Внутренний идентификатор записи", example = "333", nullable = true) + @Schema(description = "Record ID", example = "333", nullable = true) private final @Nullable Integer id; - @Schema(description = "Инструмент", example = "123", requiredMode = REQUIRED) + @Schema(description = "Asset", example = "123", requiredMode = REQUIRED) private final int security; - @Schema(description = "Время", example = "2021-01-01T19:00:00+03:00", requiredMode = REQUIRED) + @Schema(description = "Date and time", example = "2021-01-01T19:00:00+03:00", requiredMode = REQUIRED) private final Instant timestamp; @EqualsAndHashCode.Exclude - @Schema(description = "Котировка (для облигаций - в процентах, деривативы - в пунктах)", example = "4800.20", requiredMode = REQUIRED) + @Schema(description = "Quote (for bonds - in percent, for derivatives - in points)", example = "4800.20", requiredMode = REQUIRED) private final BigDecimal quote; // for stock, currency pair and asset in currency, for bond - in percent, for derivative - in quote @EqualsAndHashCode.Exclude - @Schema(description = "Котировка (в валюте, только для облигаций и деривативов)", example = "1020.30", nullable = true) + @Schema(description = "Quote in currency (for bonds and derivatives only)", example = "1020.30", nullable = true) private final @Nullable BigDecimal price; // for bond and derivative - in currency, for others is null @EqualsAndHashCode.Exclude @JsonProperty("accrued-interest") - @Schema(description = "НКД (в валюте, только для облигаций)", example = "10.20", nullable = true) + @Schema(description = "Accrued coupon interest (in currency, for bonds only)", example = "10.20", nullable = true) private final @Nullable BigDecimal accruedInterest; // for bond in currency, for others is null @JsonProperty("currency") - @Schema(description = "Валюта котировки для акций, облигаций, произвольных активов и опционально для деривативов", + @Schema(description = "Quote currency for stocks, bonds, and custom assets and optionally for derivatives", example = "RUB", nullable = true) private final @Nullable String currency; diff --git a/src/main/java/org/spacious_team/broker/pojo/SecurityType.java b/src/main/java/org/spacious_team/broker/pojo/SecurityType.java index da5fba2..a741c0b 100644 --- a/src/main/java/org/spacious_team/broker/pojo/SecurityType.java +++ b/src/main/java/org/spacious_team/broker/pojo/SecurityType.java @@ -25,12 +25,12 @@ @SuppressWarnings("unused") public enum SecurityType { - STOCK("акция"), - BOND("облигация"), - STOCK_OR_BOND("акция/облигация"), // not exactly known: STOCK or BOND - DERIVATIVE("срочный контракт"), - CURRENCY_PAIR("валютная пара"), - ASSET("произвольный актив"); + STOCK("stock"), + BOND("bond"), + STOCK_OR_BOND("stock or bond"), // not exactly known: STOCK or BOND + DERIVATIVE("derivative"), + CURRENCY_PAIR("currency pair"), + ASSET("asset"); @Getter private final String description; diff --git a/src/main/java/org/spacious_team/broker/pojo/Transaction.java b/src/main/java/org/spacious_team/broker/pojo/Transaction.java index 98eab97..d1e6e28 100644 --- a/src/main/java/org/spacious_team/broker/pojo/Transaction.java +++ b/src/main/java/org/spacious_team/broker/pojo/Transaction.java @@ -38,25 +38,25 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Сделка") +@Schema(name = "Transaction") public class Transaction { // autoincrement - @Schema(description = "Внутренний идентификатор сделки", example = "123", nullable = true) + @Schema(description = "Record ID", example = "123", nullable = true) private final @Nullable Integer id; @JsonProperty("trade-id") - @Schema(description = "Номер сделки в системе учета брокера", example = "123SP", requiredMode = REQUIRED) + @Schema(description = "Trade ID in the broker's accounting system", example = "123SP", requiredMode = REQUIRED) private final @NotEmpty String tradeId; - @Schema(description = "Номер счета в системе учета брокера", example = "10200I", requiredMode = REQUIRED) - private final @NotEmpty String portfolio; + @Schema(description = "Account number in the broker's accounting system", example = "10200I", requiredMode = REQUIRED) + private final @NotEmpty String account; - @Schema(description = "Инструмент", example = "123", requiredMode = REQUIRED) + @Schema(description = "Security", example = "123", requiredMode = REQUIRED) private final int security; - @Schema(description = "Время сделки", example = "2021-01-23T12:00:00+03:00", requiredMode = REQUIRED) + @Schema(description = "Trade date and time", example = "2021-01-23T12:00:00+03:00", requiredMode = REQUIRED) private final Instant timestamp; - @Schema(description = "Количество бумаг (контрактов), шт", example = "10", requiredMode = REQUIRED) + @Schema(description = "Number of securities (contracts)", example = "10", requiredMode = REQUIRED) private final int count; } diff --git a/src/main/java/org/spacious_team/broker/pojo/TransactionCashFlow.java b/src/main/java/org/spacious_team/broker/pojo/TransactionCashFlow.java index b1b347a..c142e10 100644 --- a/src/main/java/org/spacious_team/broker/pojo/TransactionCashFlow.java +++ b/src/main/java/org/spacious_team/broker/pojo/TransactionCashFlow.java @@ -38,26 +38,26 @@ @Jacksonized @Builder(toBuilder = true) @EqualsAndHashCode(cacheStrategy = LAZY) -@Schema(name = "Движение ДС по сделке") +@Schema(name = "TransactionCashFlow") public class TransactionCashFlow { // autoincrement - @Schema(description = "Внутренний идентификатор записи", example = "1", nullable = true) + @Schema(description = "Record ID", example = "1", nullable = true) private final @Nullable Integer id; @JsonProperty("transaction-id") - @Schema(description = "Внутренний идентификатор сделки", example = "123", requiredMode = REQUIRED) + @Schema(description = "Transaction record ID", example = "123", requiredMode = REQUIRED) private final int transactionId; @JsonProperty("event-type") - @Schema(description = "Тип события (стоимость бумаг без НКД, НКД, комиссия)", example = "PRICE", requiredMode = REQUIRED) + @Schema(description = "Event type", example = "PRICE", requiredMode = REQUIRED) private final CashFlowType eventType; @EqualsAndHashCode.Exclude - @Schema(description = "Сумма по событию", example = "1000.20", requiredMode = REQUIRED) + @Schema(description = "Transaction amount", example = "1000.20", requiredMode = REQUIRED) private final BigDecimal value; @Builder.Default - @Schema(description = "Валюта", example = "RUB", defaultValue = "RUB", nullable = true) + @Schema(description = "Currency", example = "RUB", defaultValue = "RUB", nullable = true) private final String currency = "RUB"; @EqualsAndHashCode.Include diff --git a/src/main/java/org/spacious_team/broker/report_parser/api/AbstractReportTable.java b/src/main/java/org/spacious_team/broker/report_parser/api/AbstractReportTable.java index 8f3addd..1eb87bf 100644 --- a/src/main/java/org/spacious_team/broker/report_parser/api/AbstractReportTable.java +++ b/src/main/java/org/spacious_team/broker/report_parser/api/AbstractReportTable.java @@ -46,23 +46,25 @@ public abstract class AbstractReportTable extends InitializableReportTable private @MonotonicNonNull String tableName; private final Predicate<@Nullable Object> tableNameFinder; + private final int tableNameRowCount; // 0 for CreateMode.NAMELESS_TABLE_BY_PREDICATE + private final int headerRowsCount; // -1 if header row count is determined by firstDataRowFinder + private final @Nullable Predicate<@Nullable Object> firstDataRowFinder; private final @Nullable Predicate<@Nullable Object> tableFooterFinder; private final Class headerDescription; // & TableHeaderColumn> - private final int headersRowCount; private final CreateMode createMode; /** - * Finds and creates a table in a report, whose title case-insensitive matches to {@code "^.*"}. - * Table last row locates before the row, which case-insensitive matches to {@code "^.*"}. - * If tableFooter is null, when table last row locates before empty row. - * If tableFooter is null and empty row not found, when table ends with report last row. + * Finds and creates a table in a report, whose title case-insensitive matches to {@code tableName>} prefix. + * The last row of the table precedes the row, which case-insensitive matches to {@code tableFooter} prefix. + * If {@code tableFooter} is null, the last row of the table precedes the empty row. + * If {@code tableFooter} is null and empty row not found, when table ends with report last row. */ protected & TableHeaderColumn> AbstractReportTable(BrokerReport report, String tableName, @Nullable String tableFooter, Class headerDescription) { - this(report, tableName, tableFooter, headerDescription, 1); + this(report, tableName, 1, tableFooter, headerDescription, 1); } protected & TableHeaderColumn> @@ -70,97 +72,206 @@ public abstract class AbstractReportTable extends InitializableReportTable String tableName, @Nullable String tableFooter, Class headerDescription, - int headersRowCount) { - this(report, getPrefixPredicate(tableName), getPrefixPredicateOrNull(tableFooter), - headerDescription, headersRowCount); + int headerRowsCount) { + this(report, tableName, 1, tableFooter, headerDescription, headerRowsCount); + } + + protected & TableHeaderColumn> + AbstractReportTable(BrokerReport report, + String tableName, + int tableNameRowCount, + @Nullable String tableFooter, + Class headerDescription, + int headerRowsCount) { + this(report, getPrefixPredicate(tableName), tableNameRowCount, getPrefixPredicateOrNull(tableFooter), + headerDescription, headerRowsCount); this.tableName = tableName; } /** - * Finds and creates a table in a report, whose title matches to tableNameFinder predicate. - * Table last row locates before the row, which matches to tableFooterFinder. - * If tableFooterFinder is null, when table last row locates before empty row. - * If tableFooterFinder is null and empty row not found, when table ends with report last row. + * Finds and creates a table in a report, whose title matches to {@code tableName} prefix. + * The first data row of the table matches to {@code firstDataRow} prefix. + * The last row of the table precedes the row, which matches to {@code tableFooter} prefix. + * If {@code tableFooter} is null, the last row of the table precedes the empty row. + * If {@code tableFooter} is null and empty row not found, when table ends with report last row. + */ + protected & TableHeaderColumn> + AbstractReportTable(BrokerReport report, + String tableName, + int tableNameRowCount, + String firstDataRow, + @Nullable String tableFooter, + Class headerDescription) { + this(report, getPrefixPredicate(tableName), tableNameRowCount, getPrefixPredicate(firstDataRow), + getPrefixPredicateOrNull(tableFooter), headerDescription); + this.tableName = tableName; + } + + /** + * Finds and creates a table in a report, whose title matches to {@code tableNameFinder} predicate. + * The last row of the table precedes the row, which matches to {@code tableFooterFinder}. + * If {@code tableFooterFinder} is null, the last row of the table precedes the empty row. + * If {@code tableFooterFinder} is null and empty row not found, when table ends with report last row. */ protected & TableHeaderColumn> AbstractReportTable(BrokerReport report, Predicate tableNameFinder, @Nullable Predicate tableFooterFinder, Class headerDescription) { - this(report, tableNameFinder, tableFooterFinder, headerDescription, 1); + this(report, tableNameFinder, 1, tableFooterFinder, headerDescription, 1); + } + + protected & TableHeaderColumn> + AbstractReportTable(BrokerReport report, + Predicate tableNameFinder, + @Nullable Predicate tableFooterFinder, + Class headerDescription, + int headerRowsCount) { + this(report, tableNameFinder, 1, tableFooterFinder, headerDescription, headerRowsCount); } protected & TableHeaderColumn> AbstractReportTable(BrokerReport report, Predicate tableNameFinder, + int tableNameRowCount, @Nullable Predicate tableFooterFinder, Class headerDescription, - int headersRowCount) { + int headerRowsCount) { + super(report); + this.createMode = CreateMode.TABLE_BY_PREDICATE; + //noinspection DataFlowIssue + this.tableName = null; + this.tableNameFinder = cast(tableNameFinder); + this.tableNameRowCount = tableNameRowCount; + this.firstDataRowFinder = null; + this.tableFooterFinder = castOrNull(tableFooterFinder); + this.headerDescription = headerDescription; + this.headerRowsCount = headerRowsCount; + } + + /** + * Finds and creates a table in a report, whose title matches to {@code tableNameFinder} predicate. + * The first data row of the table matches to {@code firstDataRowFinder} predicate. + * The last row of the table precedes the row, which matches to {@code tableFooterFinder}. + * If {@code tableFooterFinder} is null, the last row of the table precedes the empty row. + * If {@code tableFooterFinder} is null and empty row not found, when table ends with report last row. + */ + protected & TableHeaderColumn> + AbstractReportTable(BrokerReport report, + Predicate tableNameFinder, + int tableNameRowCount, + Predicate firstDataRowFinder, + @Nullable Predicate tableFooterFinder, + Class headerDescription) { super(report); this.createMode = CreateMode.TABLE_BY_PREDICATE; //noinspection DataFlowIssue this.tableName = null; this.tableNameFinder = cast(tableNameFinder); + this.tableNameRowCount = tableNameRowCount; + this.firstDataRowFinder = castOrNull(firstDataRowFinder); this.tableFooterFinder = castOrNull(tableFooterFinder); this.headerDescription = headerDescription; - this.headersRowCount = headersRowCount; + this.headerRowsCount = -1; } /** - * Finds and creates a table without title, whose first header row case-insensitive matches to {@code "^.*"}. - * Table last row locates before the row, which case-insensitive matches to {@code "^.*"}. - * If tableFooter is null, when table last row locates before empty row. - * If tableFooter is null and empty row not found, when table ends with report last row. + * Finds and creates a table without title, whose first header row case-insensitive matches to {@code headerRowPrefix} prefix. + * The last row of the table precedes the row, which case-insensitive matches to {@code tableFooter} prefix. + * If {@code tableFooter} is null, the last row of the table precedes the empty row. + * If {@code tableFooter} is null and empty row not found, when table ends with report last row. + * + * @param providedTableName assigned table name (doesn't exist in the broker report) */ protected & TableHeaderColumn> AbstractReportTable(BrokerReport report, String providedTableName, - String namelessTableFirstLine, + String headerRowPrefix, @Nullable String tableFooter, Class headerDescription) { - this(report, providedTableName, namelessTableFirstLine, tableFooter, headerDescription, 1); + this(report, providedTableName, headerRowPrefix, tableFooter, headerDescription, 1); } protected & TableHeaderColumn> AbstractReportTable(BrokerReport report, String providedTableName, - String namelessTableFirstLine, + String headerRowPrefix, @Nullable String tableFooter, Class headerDescription, - int headersRowCount) { - this(report, providedTableName, getPrefixPredicate(namelessTableFirstLine), - getPrefixPredicateOrNull(tableFooter), headerDescription, headersRowCount); + int headerRowsCount) { + this(report, providedTableName, getPrefixPredicate(headerRowPrefix), + getPrefixPredicateOrNull(tableFooter), headerDescription, headerRowsCount); } /** - * Finds and creates a table without title, whose first header row matches to namelessTableFirstLineFinder predicate. - * Table last row locates before the row, which matches to tableFooterFinder predicate. - * If tableFooterFinder is null, when table last row locates before empty row. - * If tableFooterFinder is null and empty row not found, when table ends with report last row. + * Finds and creates a table without title, whose first header row case-insensitive matches to {@code headerRowPrefix} prefix. + * The first data row of the table matches to {@code firstDataRowPrefix} prefix. + * The last row of the table precedes the row, which matches to {@code tableFooter}. + * If {@code tableFooter} is null, the last row of the table precedes the empty row. + * If {@code tableFooter} is null and empty row not found, when table ends with report last row. */ protected & TableHeaderColumn> AbstractReportTable(BrokerReport report, String providedTableName, - Predicate namelessTableFirstLineFinder, + String headerRowPrefix, + String firstDataRowPrefix, + @Nullable String tableFooter, + Class headerDescription) { + this(report, providedTableName, getPrefixPredicate(headerRowPrefix), getPrefixPredicate(firstDataRowPrefix), + getPrefixPredicateOrNull(tableFooter), headerDescription); + } + + /** + * Finds and creates a table without title, whose first header row matches to {@code headerRowFinder} predicate. + * TThe last row of the table precedes the row, which matches to {@code tableFooterFinder} predicate. + * If {@code tableFooterFinder} is null, the last row of the table precedes the empty row. + * If {@code tableFooterFinder} is null and empty row not found, when table ends with report last row. + * + * @param providedTableName assigned table name (doesn't exist in the broker report) + */ + protected & TableHeaderColumn> + AbstractReportTable(BrokerReport report, + String providedTableName, + Predicate headerRowFinder, @Nullable Predicate tableFooterFinder, Class headerDescription) { - this(report, providedTableName, namelessTableFirstLineFinder, tableFooterFinder, headerDescription, 1); + this(report, providedTableName, headerRowFinder, tableFooterFinder, headerDescription, 1); } protected & TableHeaderColumn> AbstractReportTable(BrokerReport report, String providedTableName, - Predicate namelessTableFirstLineFinder, + Predicate headerRowFinder, @Nullable Predicate tableFooterFinder, Class headerDescription, - int headersRowCount) { + int headerRowsCount) { super(report); this.createMode = CreateMode.NAMELESS_TABLE_BY_PREDICATE; this.tableName = providedTableName; - this.tableNameFinder = cast(namelessTableFirstLineFinder); + this.tableNameRowCount = 0; + this.tableNameFinder = cast(headerRowFinder); + this.firstDataRowFinder = null; this.tableFooterFinder = castOrNull(tableFooterFinder); this.headerDescription = headerDescription; - this.headersRowCount = headersRowCount; + this.headerRowsCount = headerRowsCount; + } + + protected & TableHeaderColumn> + AbstractReportTable(BrokerReport report, + String providedTableName, + Predicate headerRowFinder, + Predicate firstDataRowFinder, + @Nullable Predicate tableFooterFinder, + Class headerDescription) { + super(report); + this.createMode = CreateMode.NAMELESS_TABLE_BY_PREDICATE; + this.tableName = providedTableName; + this.tableNameRowCount = 0; + this.tableNameFinder = cast(headerRowFinder); + this.firstDataRowFinder = cast(firstDataRowFinder); + this.tableFooterFinder = castOrNull(tableFooterFinder); + this.headerDescription = headerDescription; + this.headerRowsCount = -1; } private static @Nullable Predicate getPrefixPredicateOrNull(@Nullable String prefix) { @@ -195,18 +306,24 @@ protected Collection parseTable() { Table createTable(ReportPage reportPage) { @SuppressWarnings("unchecked") Class headerDesc = (Class) headerDescription; + Table table; if (createMode == CreateMode.TABLE_BY_PREDICATE) { - return (tableFooterFinder != null) ? - reportPage.create(tableNameFinder, tableFooterFinder, headerDesc, headersRowCount).excludeTotalRow() : - reportPage.create(tableNameFinder, headerDesc, headersRowCount); + table = (firstDataRowFinder == null) ? + reportPage.createTable(tableNameFinder, tableNameRowCount, tableFooterFinder, headerDesc, headerRowsCount) : + reportPage.createTable(tableNameFinder, tableNameRowCount, firstDataRowFinder, tableFooterFinder, headerDesc); } else if (createMode == CreateMode.NAMELESS_TABLE_BY_PREDICATE) { @SuppressWarnings({"nullness", "ConstantConditions"}) String providedTableName = requireNonNull(tableName); - return (tableFooterFinder != null) ? - reportPage.createNameless(providedTableName, tableNameFinder, tableFooterFinder, headerDesc, headersRowCount).excludeTotalRow() : - reportPage.createNameless(providedTableName, tableNameFinder, headerDesc, headersRowCount); + table = (firstDataRowFinder == null) ? + reportPage.createNamelessTable(providedTableName, tableNameFinder, tableFooterFinder, headerDesc, headerRowsCount) : + reportPage.createNamelessTable(providedTableName, tableNameFinder, firstDataRowFinder, tableFooterFinder, headerDesc); + } else { + throw new IllegalArgumentException("Unexpected create mode = " + createMode); + } + if (tableFooterFinder != null) { + table = table.excludeLastRow(); } - throw new IllegalArgumentException("Unexpected create mode = " + createMode); + return table; } @DefaultQualifier(NonNull.class) // checkerframework bug fix diff --git a/src/main/java/org/spacious_team/broker/report_parser/api/AbstractTransaction.java b/src/main/java/org/spacious_team/broker/report_parser/api/AbstractTransaction.java index c411680..3ef4ac7 100644 --- a/src/main/java/org/spacious_team/broker/report_parser/api/AbstractTransaction.java +++ b/src/main/java/org/spacious_team/broker/report_parser/api/AbstractTransaction.java @@ -43,7 +43,7 @@ public abstract class AbstractTransaction { protected final Integer id; protected final String tradeId; - protected final String portfolio; + protected final String account; protected final int security; protected final Instant timestamp; protected final int count; @@ -60,7 +60,7 @@ public Transaction getTransaction() { return Transaction.builder() .id(id) .tradeId(tradeId) - .portfolio(portfolio) + .account(account) .security(security) .timestamp(timestamp) .count(count) diff --git a/src/main/java/org/spacious_team/broker/report_parser/api/ReportTables.java b/src/main/java/org/spacious_team/broker/report_parser/api/ReportTables.java index 1a5da2b..44f14e9 100644 --- a/src/main/java/org/spacious_team/broker/report_parser/api/ReportTables.java +++ b/src/main/java/org/spacious_team/broker/report_parser/api/ReportTables.java @@ -18,10 +18,10 @@ package org.spacious_team.broker.report_parser.api; +import org.spacious_team.broker.pojo.AccountCash; +import org.spacious_team.broker.pojo.AccountProperty; import org.spacious_team.broker.pojo.EventCashFlow; import org.spacious_team.broker.pojo.ForeignExchangeRate; -import org.spacious_team.broker.pojo.PortfolioCash; -import org.spacious_team.broker.pojo.PortfolioProperty; import org.spacious_team.broker.pojo.Security; import org.spacious_team.broker.pojo.SecurityEventCashFlow; import org.spacious_team.broker.pojo.SecurityQuote; @@ -30,9 +30,9 @@ public interface ReportTables { BrokerReport getReport(); - ReportTable getPortfolioPropertyTable(); + ReportTable getAccountPropertyTable(); - ReportTable getPortfolioCashTable(); + ReportTable getAccountCashTable(); ReportTable getCashFlowTable(); diff --git a/src/main/java/org/spacious_team/broker/report_parser/api/WrappingReportTable.java b/src/main/java/org/spacious_team/broker/report_parser/api/WrappingReportTable.java index b1c2811..cb4bef6 100644 --- a/src/main/java/org/spacious_team/broker/report_parser/api/WrappingReportTable.java +++ b/src/main/java/org/spacious_team/broker/report_parser/api/WrappingReportTable.java @@ -48,8 +48,7 @@ public static WrappingReportTable of(ReportTable... tables) assertIsTrue(tables.length > 0, "Can't wrap, report tables not provided"); BrokerReport report = tables[0].getReport(); boolean isAllReportsIsSame = Arrays.stream(tables) - .map(ReportTable::getReport) - .allMatch(tableReport -> tableReport == report); + .allMatch(t -> t.getReport() == report); assertIsTrue(isAllReportsIsSame, "Wrapping report tables should be built for same broker report"); return new WrappingReportTable<>(new LazyWrappingReportTable<>(report, tables)); } diff --git a/src/test/java/org/spacious_team/broker/pojo/PortfolioCashTest.java b/src/test/java/org/spacious_team/broker/pojo/AccountCashTest.java similarity index 82% rename from src/test/java/org/spacious_team/broker/pojo/PortfolioCashTest.java rename to src/test/java/org/spacious_team/broker/pojo/AccountCashTest.java index afbb754..da8f0ee 100644 --- a/src/test/java/org/spacious_team/broker/pojo/PortfolioCashTest.java +++ b/src/test/java/org/spacious_team/broker/pojo/AccountCashTest.java @@ -27,22 +27,22 @@ import static nl.jqno.equalsverifier.Warning.STRICT_INHERITANCE; import static org.junit.jupiter.api.Assertions.assertEquals; -class PortfolioCashTest { +class AccountCashTest { @Test void testEqualsAndHashCode() { EqualsVerifier - .forClass(PortfolioCash.class) + .forClass(AccountCash.class) .suppress(STRICT_INHERITANCE) // no subclass for test - .withLombokCachedHashCode(PortfolioCash.builder().build()) + .withLombokCachedHashCode(AccountCash.builder().build()) .verify(); } @Test void testToString() { - PortfolioCash cash = PortfolioCash.builder() + AccountCash cash = AccountCash.builder() .id(1) - .portfolio("123") + .account("123") .timestamp(Instant.MIN) .market("forts") .value(BigDecimal.ONE) @@ -50,7 +50,7 @@ void testToString() { .build(); assertEquals( - "PortfolioCash(id=1, portfolio=123, timestamp=-1000000000-01-01T00:00:00Z, " + + "AccountCash(id=1, account=123, timestamp=-1000000000-01-01T00:00:00Z, " + "market=forts, value=1, currency=USD)", cash.toString()); } diff --git a/src/test/java/org/spacious_team/broker/pojo/PortfolioPropertyTest.java b/src/test/java/org/spacious_team/broker/pojo/AccountPropertyTest.java similarity index 77% rename from src/test/java/org/spacious_team/broker/pojo/PortfolioPropertyTest.java rename to src/test/java/org/spacious_team/broker/pojo/AccountPropertyTest.java index 239b710..dc53ce8 100644 --- a/src/test/java/org/spacious_team/broker/pojo/PortfolioPropertyTest.java +++ b/src/test/java/org/spacious_team/broker/pojo/AccountPropertyTest.java @@ -25,31 +25,31 @@ import static nl.jqno.equalsverifier.Warning.STRICT_INHERITANCE; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.spacious_team.broker.pojo.PortfolioPropertyType.TOTAL_ASSETS_USD; +import static org.spacious_team.broker.pojo.AccountPropertyType.TOTAL_ASSETS_USD; -class PortfolioPropertyTest { +class AccountPropertyTest { @Test void testEqualsAndHashCode() { EqualsVerifier - .forClass(PortfolioProperty.class) + .forClass(AccountProperty.class) .suppress(STRICT_INHERITANCE) // no subclass for test - .withLombokCachedHashCode(PortfolioProperty.builder().build()) + .withLombokCachedHashCode(AccountProperty.builder().build()) .verify(); } @Test void testToString() { - PortfolioProperty cash = PortfolioProperty.builder() + AccountProperty cash = AccountProperty.builder() .id(1) - .portfolio("123") + .account("123") .timestamp(Instant.MIN) .property(TOTAL_ASSETS_USD) .value("123.45") .build(); assertEquals( - "PortfolioProperty(id=1, portfolio=123, timestamp=-1000000000-01-01T00:00:00Z, " + + "AccountProperty(id=1, account=123, timestamp=-1000000000-01-01T00:00:00Z, " + "property=TOTAL_ASSETS_USD, value=123.45)", cash.toString()); } diff --git a/src/test/java/org/spacious_team/broker/pojo/PortfolioTest.java b/src/test/java/org/spacious_team/broker/pojo/AccountTest.java similarity index 82% rename from src/test/java/org/spacious_team/broker/pojo/PortfolioTest.java rename to src/test/java/org/spacious_team/broker/pojo/AccountTest.java index da88079..373d3e5 100644 --- a/src/test/java/org/spacious_team/broker/pojo/PortfolioTest.java +++ b/src/test/java/org/spacious_team/broker/pojo/AccountTest.java @@ -24,23 +24,23 @@ import static nl.jqno.equalsverifier.Warning.STRICT_INHERITANCE; import static org.junit.jupiter.api.Assertions.assertEquals; -class PortfolioTest { +class AccountTest { @Test void testEqualsAndHashCode() { EqualsVerifier - .forClass(Portfolio.class) + .forClass(Account.class) .suppress(STRICT_INHERITANCE) // no subclass for test - .withLombokCachedHashCode(Portfolio.builder().build()) + .withLombokCachedHashCode(Account.builder().build()) .verify(); } @Test void testToString() { - Portfolio portfolio = Portfolio.builder() + Account account = Account.builder() .id("123") .build(); - assertEquals("Portfolio(id=123, enabled=true)", portfolio.toString()); + assertEquals("Account(id=123, enabled=true)", account.toString()); } } \ No newline at end of file diff --git a/src/test/java/org/spacious_team/broker/pojo/EventCashFlowTest.java b/src/test/java/org/spacious_team/broker/pojo/EventCashFlowTest.java index 1d8aca9..53747be 100644 --- a/src/test/java/org/spacious_team/broker/pojo/EventCashFlowTest.java +++ b/src/test/java/org/spacious_team/broker/pojo/EventCashFlowTest.java @@ -33,7 +33,7 @@ class EventCashFlowTest { EventCashFlow flow = EventCashFlow.builder() - .portfolio("1") + .account("1") .timestamp(Instant.MIN) .eventType(CASH) .value(new BigDecimal("100.0")) // scale = 1 @@ -44,7 +44,7 @@ class EventCashFlowTest { .build(); EventCashFlow equalsFlow = EventCashFlow.builder() - .portfolio("1") + .account("1") .timestamp(Instant.MIN) .eventType(CASH) .value(new BigDecimal("100.00")) // scale = 2 @@ -71,7 +71,7 @@ void checkEquality_exponentValue_equals() { @Test void checkEquality_anotherPortfolio_notEquals() { EventCashFlow notEqualsFlow = flow.toBuilder() - .portfolio("2") + .account("2") .build(); assertFalse(EventCashFlow.checkEquality(flow, notEqualsFlow)); @@ -137,7 +137,7 @@ void testEqualsAndHashCode() { @Test void testToString() { - assertEquals("EventCashFlow(id=0, portfolio=1, timestamp=-1000000000-01-01T00:00:00Z, eventType=CASH, " + + assertEquals("EventCashFlow(id=0, account=1, timestamp=-1000000000-01-01T00:00:00Z, eventType=CASH, " + "value=100.0, currency=RUB, description=desc1)", flow.toString()); } diff --git a/src/test/java/org/spacious_team/broker/pojo/SecurityDescriptionTest.java b/src/test/java/org/spacious_team/broker/pojo/SecurityDescriptionTest.java index 89af748..81b2e9a 100644 --- a/src/test/java/org/spacious_team/broker/pojo/SecurityDescriptionTest.java +++ b/src/test/java/org/spacious_team/broker/pojo/SecurityDescriptionTest.java @@ -39,10 +39,10 @@ void testEqualsAndHashCode() { void testToString() { SecurityDescription description = SecurityDescription.builder() .security(1) - .sector("Финансы") + .sector("Information Technology") .issuer(10) .build(); - assertEquals("SecurityDescription(security=1, sector=Финансы, issuer=10)", description.toString()); + assertEquals("SecurityDescription(security=1, sector=Information Technology, issuer=10)", description.toString()); } } \ No newline at end of file diff --git a/src/test/java/org/spacious_team/broker/pojo/SecurityEventCashFlowTest.java b/src/test/java/org/spacious_team/broker/pojo/SecurityEventCashFlowTest.java index ccaa573..23cbe6d 100644 --- a/src/test/java/org/spacious_team/broker/pojo/SecurityEventCashFlowTest.java +++ b/src/test/java/org/spacious_team/broker/pojo/SecurityEventCashFlowTest.java @@ -34,7 +34,7 @@ class SecurityEventCashFlowTest { SecurityEventCashFlow flow = SecurityEventCashFlow.builder() .id(1) - .portfolio("123") + .account("123") .timestamp(Instant.MIN) .security(2) .eventType(DIVIDEND) @@ -46,7 +46,7 @@ class SecurityEventCashFlowTest { SecurityEventCashFlow equalsFlow = SecurityEventCashFlow.builder() .id(1) - .portfolio("123") + .account("123") .timestamp(Instant.MIN) .security(2) .eventType(DIVIDEND) @@ -64,7 +64,7 @@ void checkEquality_equals() { @Test void checkEquality_anotherPortfolio_notEquals() { SecurityEventCashFlow notEqualsFlow = flow.toBuilder() - .portfolio("2") + .account("2") .build(); assertFalse(SecurityEventCashFlow.checkEquality(flow, notEqualsFlow)); @@ -140,7 +140,7 @@ void testEqualsAndHashCode() { @Test void testToString() { assertEquals( - "SecurityEventCashFlow(id=1, portfolio=123, timestamp=-1000000000-01-01T00:00:00Z, " + + "SecurityEventCashFlow(id=1, account=123, timestamp=-1000000000-01-01T00:00:00Z, " + "security=2, count=3, eventType=DIVIDEND, value=1, currency=USD)", flow.toString()); } diff --git a/src/test/java/org/spacious_team/broker/pojo/TransactionTest.java b/src/test/java/org/spacious_team/broker/pojo/TransactionTest.java index cf5a30c..d4a3647 100644 --- a/src/test/java/org/spacious_team/broker/pojo/TransactionTest.java +++ b/src/test/java/org/spacious_team/broker/pojo/TransactionTest.java @@ -42,14 +42,14 @@ void testToString() { Transaction transaction = Transaction.builder() .id(1) .tradeId("AB123") - .portfolio("2") + .account("2") .security(3) .timestamp(Instant.MIN) .count(4) .build(); assertEquals( - "Transaction(id=1, tradeId=AB123, portfolio=2, security=3, " + + "Transaction(id=1, tradeId=AB123, account=2, security=3, " + "timestamp=-1000000000-01-01T00:00:00Z, count=4)", transaction.toString()); } diff --git a/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTableTest.java b/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTableTest.java index 0fa4678..f710ad2 100644 --- a/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTableTest.java +++ b/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTableTest.java @@ -65,8 +65,8 @@ void before() { } @Test - void createExceptionally() { - when(reportPage.create(any(Predicate.class), eq(TableHeader.class), eq(1))) + void createTable_exception() { + when(reportPage.createTable(any(Predicate.class), eq(1), eq(null), eq(TableHeader.class), eq(1))) .thenThrow(IllegalArgumentException.class); ReportTable reportTable = new ReportTable(brokerReport, "table1", null); @@ -74,34 +74,35 @@ void createExceptionally() { } @Test - void createTableByPrefixAndWithoutFooter() { - when(reportPage.create(any(Predicate.class), eq(TableHeader.class), eq(1))).thenReturn(table); + void createTable_byPrefixAndWithoutFooter() { + when(reportPage.createTable(any(Predicate.class), eq(1), eq(null), eq(TableHeader.class), eq(1))).thenReturn(table); ReportTable reportTable = new ReportTable(brokerReport, "table1", null); reportTable.parseTable(); - verify(table, never()).excludeTotalRow(); + verify(table, never()).excludeLastRow(); verify(table).getDataCollection(eq(brokerReport), any(), any(), any()); - verify(reportPage).create(tableNamePredicateCaptor.capture(), eq(TableHeader.class), eq(1)); + verify(reportPage).createTable(tableNamePredicateCaptor.capture(), eq(1), eq(null), eq(TableHeader.class), eq(1)); Predicate tableNameFinder = tableNamePredicateCaptor.getValue(); matches(tableNameFinder, "table1", "TABLE1", " table1 ", "table12"); notMatches(tableNameFinder, "table2", "table", "", new Object(), null); } @Test - void createTableByPrefixAndFooter() { - when(reportPage.create(any(Predicate.class), any(Predicate.class), eq(TableHeader.class), eq(1))) + void createTable_byPrefixAndFooter() { + when(reportPage.createTable(any(Predicate.class), eq(1), any(Predicate.class), eq(TableHeader.class), eq(1))) .thenReturn(table); - when(table.excludeTotalRow()).thenReturn(tableWithoutTotal); + when(table.excludeLastRow()).thenReturn(tableWithoutTotal); ReportTable reportTable = new ReportTable(brokerReport, "table1", "total1"); reportTable.parseTable(); - verify(table).excludeTotalRow(); + verify(table).excludeLastRow(); verify(table, never()).getDataCollection(any(), any(), any(), any()); verify(tableWithoutTotal).getDataCollection(eq(brokerReport), any(), any(), any()); - verify(reportPage).create( + verify(reportPage).createTable( tableNamePredicateCaptor.capture(), + eq(1), tableFooterPredicateCaptor.capture(), eq(TableHeader.class), eq(1)); @@ -114,7 +115,7 @@ void createTableByPrefixAndFooter() { } @Test - void createTableByPredicateAndWithoutFooter() { + void createTable_byPredicateAndWithoutFooter() { Predicate tableNameFinder = v -> Objects.equals(v, "table1"); Predicate tableFooterFinder = v -> Objects.equals(v, "total1"); @@ -124,38 +125,69 @@ void createTableByPredicateAndWithoutFooter() { } @Test - void createNamelessTableByPrefixAndWithoutFooter() { - when(reportPage.createNameless(eq("providedName"), any(Predicate.class), eq(TableHeader.class), eq(1))) + void createTable_byHeaderRowCount() { + int headerRowCnt = 2; + when(reportPage.createTable(any(Predicate.class), anyInt(), any(), any(), anyInt())).thenReturn(table); + ReportTable reportTable = new ReportTable(brokerReport, "table1", "", headerRowCnt); + + reportTable.parseTable(); + + verify(reportPage).createTable(any(Predicate.class), eq(1), eq(null), eq(TableHeader.class), eq(headerRowCnt)); + } + + @Test + void createTable_byTableFirstRow() { + when(reportPage.createTable(any(Predicate.class), anyInt(), any(), any(), any())).thenReturn(table); + ReportTable reportTable = new ReportTable(brokerReport, "table1", 2, "firstData", null); + + reportTable.parseTable(); + + verify(reportPage).createTable(any(Predicate.class), eq(2), any(Predicate.class), eq(null), eq(TableHeader.class)); + } + + @Test + void createTableNameless_byTableFirstRow() { + when(reportPage.createNamelessTable(any(String.class), any(Predicate.class), any(), any(), any())).thenReturn(table); + ReportTable reportTable = new ReportTable(brokerReport, "provided-name", "header", "firstData", null); + + reportTable.parseTable(); + + verify(reportPage).createNamelessTable(eq("provided-name"), any(Predicate.class), any(Predicate.class), eq(null), eq(TableHeader.class)); + } + + @Test + void createNamelessTable_byPrefixAndWithoutFooter() { + when(reportPage.createNamelessTable(eq("providedName"), any(Predicate.class), eq(null), eq(TableHeader.class), eq(1))) .thenReturn(table); ReportTable reportTable = new ReportTable(brokerReport, "providedName", "row1", null); reportTable.parseTable(); - verify(table, never()).excludeTotalRow(); + verify(table, never()).excludeLastRow(); verify(table).getDataCollection(eq(brokerReport), any(), any(), any()); - verify(reportPage).createNameless( - eq("providedName"), tableNamePredicateCaptor.capture(), eq(TableHeader.class), eq(1)); + verify(reportPage).createNamelessTable( + eq("providedName"), tableNamePredicateCaptor.capture(), eq(null), eq(TableHeader.class), eq(1)); Predicate tableFirstLineFinder = tableNamePredicateCaptor.getValue(); matches(tableFirstLineFinder, "row1", "ROW1", " row1 ", "row12"); notMatches(tableFirstLineFinder, "row2", "row", "", new Object(), null); } @Test - void createNamelessTableByPrefixAndFooter() { - when(reportPage.createNameless( + void createNamelessTable_byPrefixAndFooter() { + when(reportPage.createNamelessTable( eq("providedName"), any(Predicate.class), any(Predicate.class), eq(TableHeader.class), eq(1))) .thenReturn(table); - when(table.excludeTotalRow()).thenReturn(tableWithoutTotal); + when(table.excludeLastRow()).thenReturn(tableWithoutTotal); ReportTable reportTable = new ReportTable(brokerReport, "providedName", "row1", "total1"); reportTable.parseTable(); - verify(table).excludeTotalRow(); + verify(table).excludeLastRow(); verify(table, never()).getDataCollection(any(), any(), any(), any()); verify(tableWithoutTotal).getDataCollection(eq(brokerReport), any(), any(), any()); - verify(reportPage).createNameless( + verify(reportPage).createNamelessTable( eq("providedName"), tableNamePredicateCaptor.capture(), tableFooterPredicateCaptor.capture(), @@ -170,7 +202,7 @@ void createNamelessTableByPrefixAndFooter() { } @Test - void createNamelessTableByPredicateAndWithoutFooter() { + void createNamelessTable_byPredicateAndWithoutFooter() { Predicate tableFirstLineFinder = v -> Objects.equals(v, "table1"); Predicate tableFooterFinder = v -> Objects.equals(v, "total1"); @@ -263,17 +295,37 @@ static class ReportTable extends AbstractReportTable { super(report, tableName, tableFooter, TableHeader.class); } + ReportTable(BrokerReport report, String tableName, @Nullable String tableFooter, int headerRowsCount) { + super(report, tableName, tableFooter, TableHeader.class, headerRowsCount); + } + + ReportTable(BrokerReport report, + String tableName, + int tableNameRowCount, + String firstDataRow, + @Nullable String tableFooter) { + super(report, tableName, tableNameRowCount, firstDataRow, tableFooter, TableHeader.class); + } + ReportTable(BrokerReport report, Predicate tableNameFinder, @Nullable Predicate tableFooterFinder) { super(report, tableNameFinder, tableFooterFinder, TableHeader.class); } ReportTable(BrokerReport report, String providedTableName, String namelessTableFirstLine, - @Nullable String tableFooter) { + @Nullable String tableFooter) { super(report, providedTableName, namelessTableFirstLine, tableFooter, TableHeader.class); } + ReportTable(BrokerReport report, + String providedTableName, + String headerRowPrefix, + String firstDataRowPrefix, + @Nullable String tableFooter) { + super(report, providedTableName, headerRowPrefix, firstDataRowPrefix, tableFooter, TableHeader.class); + } + ReportTable(BrokerReport report, String providedTableName, Predicate namelessTableFirstLineFinder, - @Nullable Predicate tableFooterFinder) { + @Nullable Predicate tableFooterFinder) { super(report, providedTableName, namelessTableFirstLineFinder, tableFooterFinder, TableHeader.class); } @@ -298,11 +350,11 @@ public Collection mergeDuplicates(Object oldObject, Object newObject) { } } - enum TableHeader implements TableHeaderColumn { + enum TableHeader implements TableHeaderColumn { ; @Override - @SuppressWarnings({"ReturnOfNull", "ConstantConditions"}) + @SuppressWarnings({"ReturnOfNull", "ConstantConditions", "NullableProblems"}) public TableColumn getColumn() { return null; } diff --git a/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTablesTest.java b/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTablesTest.java index 275d983..bf3e1fc 100644 --- a/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTablesTest.java +++ b/src/test/java/org/spacious_team/broker/report_parser/api/AbstractReportTablesTest.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.spacious_team.broker.pojo.AccountCash; +import org.spacious_team.broker.pojo.AccountProperty; import org.spacious_team.broker.pojo.EventCashFlow; import org.spacious_team.broker.pojo.ForeignExchangeRate; -import org.spacious_team.broker.pojo.PortfolioCash; -import org.spacious_team.broker.pojo.PortfolioProperty; import org.spacious_team.broker.pojo.Security; import org.spacious_team.broker.pojo.SecurityEventCashFlow; import org.spacious_team.broker.pojo.SecurityQuote; @@ -64,12 +64,12 @@ public EmptyReportTable emptyTable() { } @Override - public ReportTable getPortfolioPropertyTable() { + public ReportTable getAccountPropertyTable() { return null; } @Override - public ReportTable getPortfolioCashTable() { + public ReportTable getAccountCashTable() { return null; } diff --git a/src/test/java/org/spacious_team/broker/report_parser/api/DerivativeTransactionTest.java b/src/test/java/org/spacious_team/broker/report_parser/api/DerivativeTransactionTest.java index 4701006..8fde9ac 100644 --- a/src/test/java/org/spacious_team/broker/report_parser/api/DerivativeTransactionTest.java +++ b/src/test/java/org/spacious_team/broker/report_parser/api/DerivativeTransactionTest.java @@ -38,7 +38,7 @@ class DerivativeTransactionTest { DerivativeTransaction tr = DerivativeTransaction.builder() .id(1) .tradeId("t123") - .portfolio("a123") + .account("a123") .security(2) .timestamp(Instant.MIN) .count(3) @@ -54,7 +54,7 @@ void getTransaction() { Transaction expected = Transaction.builder() .id(tr.getId()) .tradeId(tr.getTradeId()) - .portfolio(tr.getPortfolio()) + .account(tr.getAccount()) .security(tr.getSecurity()) .timestamp(tr.getTimestamp()) .count(tr.getCount()) @@ -181,7 +181,7 @@ void testEqualsAndHashCode() { @Test void testToString() { - assertEquals("DerivativeTransaction(super=AbstractTransaction(id=1, tradeId=t123, portfolio=a123," + + assertEquals("DerivativeTransaction(super=AbstractTransaction(id=1, tradeId=t123, account=a123," + " security=2, timestamp=-1000000000-01-01T00:00:00Z, count=3, value=10, fee=1," + " valueCurrency=USD, feeCurrency=RUB), valueInPoints=2)", tr.toString()); diff --git a/src/test/java/org/spacious_team/broker/report_parser/api/ForeignExchangeTransactionTest.java b/src/test/java/org/spacious_team/broker/report_parser/api/ForeignExchangeTransactionTest.java index 098900e..1b8d314 100644 --- a/src/test/java/org/spacious_team/broker/report_parser/api/ForeignExchangeTransactionTest.java +++ b/src/test/java/org/spacious_team/broker/report_parser/api/ForeignExchangeTransactionTest.java @@ -39,7 +39,7 @@ class ForeignExchangeTransactionTest { ForeignExchangeTransaction tr = ForeignExchangeTransaction.builder() .id(1) .tradeId("t123") - .portfolio("a123") + .account("a123") .security(2) .timestamp(Instant.MIN) .count(3) @@ -54,7 +54,7 @@ void getTransaction() { Transaction expected = Transaction.builder() .id(tr.getId()) .tradeId(tr.getTradeId()) - .portfolio(tr.getPortfolio()) + .account(tr.getAccount()) .security(tr.getSecurity()) .timestamp(tr.getTimestamp()) .count(tr.getCount()) @@ -140,7 +140,7 @@ void testEqualsAndHashCode() { @Test void testToString() { - assertEquals("ForeignExchangeTransaction(super=AbstractTransaction(id=1, tradeId=t123, portfolio=a123, " + + assertEquals("ForeignExchangeTransaction(super=AbstractTransaction(id=1, tradeId=t123, account=a123, " + "security=2, timestamp=-1000000000-01-01T00:00:00Z, count=3, " + "value=10, fee=1, valueCurrency=USD, feeCurrency=RUB))", tr.toString()); diff --git a/src/test/java/org/spacious_team/broker/report_parser/api/SecurityTransactionTest.java b/src/test/java/org/spacious_team/broker/report_parser/api/SecurityTransactionTest.java index 08a5ef1..cd580bd 100644 --- a/src/test/java/org/spacious_team/broker/report_parser/api/SecurityTransactionTest.java +++ b/src/test/java/org/spacious_team/broker/report_parser/api/SecurityTransactionTest.java @@ -38,7 +38,7 @@ class SecurityTransactionTest { SecurityTransaction tr = SecurityTransaction.builder() .id(1) .tradeId("t123") - .portfolio("a123") + .account("a123") .security(2) .timestamp(Instant.MIN) .count(3) @@ -54,7 +54,7 @@ void getTransaction() { Transaction expected = Transaction.builder() .id(tr.getId()) .tradeId(tr.getTradeId()) - .portfolio(tr.getPortfolio()) + .account(tr.getAccount()) .security(tr.getSecurity()) .timestamp(tr.getTimestamp()) .count(tr.getCount()) @@ -180,7 +180,7 @@ void testEqualsAndHashCode() { @Test void testToString() { - assertEquals("SecurityTransaction(super=AbstractTransaction(id=1, tradeId=t123, portfolio=a123, " + + assertEquals("SecurityTransaction(super=AbstractTransaction(id=1, tradeId=t123, account=a123, " + "security=2, timestamp=-1000000000-01-01T00:00:00Z, count=3, " + "value=10, fee=1, valueCurrency=USD, feeCurrency=RUB), accruedInterest=2)", tr.toString());