1
This commit is contained in:
@@ -39,14 +39,35 @@ class FinanceFeePoolDirectionBehaviorTest {
|
||||
assertThat(jdbc.costQueryCount).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void payablePoolOnlyQueriesApprovedUnsettledSourcesForTheSelectedSupplier() {
|
||||
DirectionJdbc jdbc = new DirectionJdbc();
|
||||
FinanceQueryService service = new FinanceQueryService(jdbc, new ObjectMapper());
|
||||
|
||||
service.feePool(7L, "PAYABLE", 81L);
|
||||
|
||||
assertThat(jdbc.sourceSql).contains(
|
||||
"review_status='APPROVED'",
|
||||
"settlement_mode='ON_ACCOUNT'",
|
||||
"currency_code='CNY'",
|
||||
"NOT EXISTS (SELECT 1 FROM fin_settlement_line",
|
||||
"s.status<>'VOIDED'",
|
||||
"CAST(JSON_UNQUOTE(JSON_EXTRACT(source_snapshot,'$.supplierId')) AS UNSIGNED)=?");
|
||||
assertThat(jdbc.sourceArgs).containsExactly(7L, "PAYABLE", 81L);
|
||||
}
|
||||
|
||||
private static final class DirectionJdbc extends JdbcTemplate {
|
||||
private final List<String> sourceDirections = new ArrayList<>();
|
||||
private int costQueryCount;
|
||||
private String sourceSql;
|
||||
private List<Object> sourceArgs = List.of();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> List<T> query(String sql, RowMapper<T> mapper, Object... args) {
|
||||
if (sql.contains("FROM fin_fee_source")) {
|
||||
sourceSql = sql;
|
||||
sourceArgs = List.of(args);
|
||||
String direction = String.valueOf(args[1]);
|
||||
sourceDirections.add(direction);
|
||||
return (List<T>) List.of(item(direction, "FIRSTLEG_FEE", 1L));
|
||||
|
||||
Reference in New Issue
Block a user