FINERACT-1724: Swagger enhancements + Batch API enhancements

This commit is contained in:
Arnold Galovics
2022-11-03 15:40:01 +01:00
committed by Arnold Gálovics
parent 6c72ee49d8
commit 532bc507b6
3 changed files with 8 additions and 13 deletions
@@ -35,12 +35,11 @@ import org.springframework.stereotype.Component;
@Component @Component
public class CommandStrategyProvider { public class CommandStrategyProvider {
public static final String CREATE_TRANSACTION_LOAN_COMMAND_STRATEGY = "createTransactionLoanCommandStrategy";
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
private static final Map<CommandContext, String> commandStrategies = new ConcurrentHashMap<>(); private static final Map<CommandContext, String> commandStrategies = new ConcurrentHashMap<>();
/** /**
* Constructs a CommandStrategyProvider with argument of ApplicationContext type. It also initialize * Constructs a CommandStrategyProvider with argument of ApplicationContext type. It also initializes
* commandStrategies using init() function by filling it with available CommandStrategies in * commandStrategies using init() function by filling it with available CommandStrategies in
* {@link org.apache.fineract.batch.command.internal}. * {@link org.apache.fineract.batch.command.internal}.
* *
@@ -56,7 +55,7 @@ public class CommandStrategyProvider {
/** /**
* Returns an appropriate commandStrategy after determining it using the CommandContext of the request. If no such * Returns an appropriate commandStrategy after determining it using the CommandContext of the request. If no such
* Strategy is found then a default strategy is returned back. * Strategy is found then a default strategy is returned.
* *
* @param commandContext * @param commandContext
* @return CommandStrategy * @return CommandStrategy
@@ -93,16 +92,8 @@ public class CommandStrategyProvider {
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/charges").method("GET").build(), "collectChargesCommandStrategy"); commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/charges").method("GET").build(), "collectChargesCommandStrategy");
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/charges\\/\\d+").method("GET").build(), commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/charges\\/\\d+").method("GET").build(),
"getChargeByIdCommandStrategy"); "getChargeByIdCommandStrategy");
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\?command=repayment").method("POST").build(), commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\?(\\w+(\\=[\\w]+))").method("POST").build(),
CREATE_TRANSACTION_LOAN_COMMAND_STRATEGY); "createTransactionLoanCommandStrategy");
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\?command=creditBalanceRefund").method("POST").build(),
CREATE_TRANSACTION_LOAN_COMMAND_STRATEGY);
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\?command=goodwillCredit").method("POST").build(),
CREATE_TRANSACTION_LOAN_COMMAND_STRATEGY);
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\?command=merchantIssuedRefund").method("POST").build(),
CREATE_TRANSACTION_LOAN_COMMAND_STRATEGY);
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\?command=payoutRefund").method("POST").build(),
CREATE_TRANSACTION_LOAN_COMMAND_STRATEGY);
commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\/\\d+").method("POST").build(), commandStrategies.put(CommandContext.resource("loans\\/\\d+\\/transactions\\/\\d+").method("POST").build(),
"adjustTransactionCommandStrategy"); "adjustTransactionCommandStrategy");
commandStrategies.put(CommandContext.resource("clients\\/\\d+\\?command=activate").method("POST").build(), commandStrategies.put(CommandContext.resource("clients\\/\\d+\\?command=activate").method("POST").build(),
@@ -212,6 +212,8 @@ final class LoanTransactionsApiResourceSwagger {
public String receiptNumber; public String receiptNumber;
@Schema(example = "ban123") @Schema(example = "ban123")
public String bankNumber; public String bankNumber;
@Schema(example = "3")
public Integer loanChargeId;
} }
@@ -84,6 +84,8 @@ public class CommandStrategyProviderTest {
mock(CreateTransactionLoanCommandStrategy.class)), mock(CreateTransactionLoanCommandStrategy.class)),
Arguments.of("loans/123/transactions?command=payoutRefund", HttpMethod.POST, "createTransactionLoanCommandStrategy", Arguments.of("loans/123/transactions?command=payoutRefund", HttpMethod.POST, "createTransactionLoanCommandStrategy",
mock(CreateTransactionLoanCommandStrategy.class)), mock(CreateTransactionLoanCommandStrategy.class)),
Arguments.of("loans/123/transactions?command=chargeRefund", HttpMethod.POST, "createTransactionLoanCommandStrategy",
mock(CreateTransactionLoanCommandStrategy.class)),
Arguments.of("loans/123/transactions/123", HttpMethod.POST, "adjustTransactionCommandStrategy", Arguments.of("loans/123/transactions/123", HttpMethod.POST, "adjustTransactionCommandStrategy",
mock(AdjustTransactionCommandStrategy.class)), mock(AdjustTransactionCommandStrategy.class)),
Arguments.of("clients/456?command=activate", HttpMethod.POST, "activateClientCommandStrategy", Arguments.of("clients/456?command=activate", HttpMethod.POST, "activateClientCommandStrategy",