Skip to content

Commit c780b30

Browse files
buchenMikerion
authored andcommitted
Added JUnit matcher for outbound and inbound cash transfers
Issue: portfolio-performance#4782 Issue: portfolio-performance#4792
1 parent e8071bd commit c780b30

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/ExtractorMatchers.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
import org.hamcrest.Matcher;
1313
import org.hamcrest.TypeSafeDiagnosingMatcher;
1414

15+
import name.abuchen.portfolio.datatransfer.Extractor.AccountTransferItem;
1516
import name.abuchen.portfolio.datatransfer.Extractor.BuySellEntryItem;
1617
import name.abuchen.portfolio.datatransfer.Extractor.PortfolioTransferItem;
1718
import name.abuchen.portfolio.datatransfer.Extractor.SecurityItem;
1819
import name.abuchen.portfolio.datatransfer.Extractor.TransactionItem;
1920
import name.abuchen.portfolio.model.AccountTransaction;
21+
import name.abuchen.portfolio.model.AccountTransferEntry;
2022
import name.abuchen.portfolio.model.BuySellEntry;
2123
import name.abuchen.portfolio.model.PortfolioTransaction;
2224
import name.abuchen.portfolio.model.PortfolioTransferEntry;
@@ -233,6 +235,28 @@ public static Matcher<Extractor.Item> feeRefund(Matcher<Transaction>... properti
233235
return new AccountTransactionMatcher("fee refund", AccountTransaction.Type.FEES_REFUND, properties); //$NON-NLS-1$
234236
}
235237

238+
@SafeVarargs
239+
public static Matcher<Extractor.Item> inboundCash(Matcher<Transaction>... properties)
240+
{
241+
return new ExtractorItemMatcher<Transaction>("cash transfer", //$NON-NLS-1$
242+
item -> item instanceof AccountTransferItem transfer //
243+
&& transfer.getSubject() instanceof AccountTransferEntry entry
244+
? entry.getTargetTransaction()
245+
: null, //
246+
properties);
247+
}
248+
249+
@SafeVarargs
250+
public static Matcher<Extractor.Item> outboundCash(Matcher<Transaction>... properties)
251+
{
252+
return new ExtractorItemMatcher<Transaction>("cash transfer", //$NON-NLS-1$
253+
item -> item instanceof AccountTransferItem transfer //
254+
&& transfer.getSubject() instanceof AccountTransferEntry entry
255+
? entry.getSourceTransaction()
256+
: null, //
257+
properties);
258+
}
259+
236260
@SafeVarargs
237261
public static Matcher<Extractor.Item> purchase(Matcher<Transaction>... properties)
238262
{

0 commit comments

Comments
 (0)