Refactor and improve the test suite for better maintainability, readability, and performance.
var — always explicit types. Project convention.@DirtiesContext unless explicitly asked.Prefer inline setup over helper methods. Each test configures only what it needs.
For product configuration, use get → modify → createOrUpdate:
ProductConfigurationDto product = this.getSimpleProductConfiguration("TopSim", "default", Set.of());
product.getConditionsConfiguration().put("default", new ConditionsConfigurationDto()...);
this.createOrUpdateProductConfiguration(product);
For control groups, use getSimpleCreditPolicyControlGroupWithOneRule or WithRules — unspecified rules are auto-DISABLED:
ControlGroupDto group = this.getSimpleCreditPolicyControlGroupWithOneRule("TopSim", "default", 100, ruleKind, ruleConfig);
this.createOrUpdateCreditPolicyControlGroup(group);
Only create the products the test actually needs. Don't set custom group codes unless asserting them.
Avoid deprecated helpers: getBasicCreditPolicyGroup, createCreditPolicyGroup, getCustomControlGroup, createBasicProductAndCreditPolicy, createOrUpdateBasicProductConfiguration, getBasicProductConfiguration.
completeLoanUntilInState(person, clear, desiredState, overruleDecline, cacheKeyExtras) with cache key extras to enable caching.test-{product}-{configurationCode}) — no random values.@MockitoSpyBean, @SpyBean, or @MockBean in new tests.BoaVistaMockClient, ScrMockClient, FraudSuspicionServiceMockClient, etc.):
@Service / @Primary bean extending the real clientsetMocksToDefault() in AbstractTestHelpertest.properties instead of using @Primary.AssetServiceClient.updateProductItemAsync), use CAPTURE mode to intercept messages instead of querying the external service. Example: AssetServiceMockClient with CAPTURE mode captures AssetProductItemUpdateRequestDto messages for assertion.@DisplayName with a clear description of what the test verifies.// Step 1:, // Step 2:, // Verify:).testChargeOffLateLoan not testChargeOff).@ServiceClientOperation(ignore = true)).payInstallment() helper with positive amounts (not negated).DateTimeHelper.getCurrentLocalDate() instead of LocalDate.now() when clock is manipulated.service/ subpackages: repayments/, application/, underwriting/, formalization/, conditions/, policy/.LoanRePaymentServiceClientTest + LoanRePaymentNegotiationServiceClientTest).beforeEachDefault truncates loan, product_configuration, control_group, re_payment_control_group, portfolio tables and re-installs portfolio seed data from portfolios.json.@DirtiesContext unless explicitly asked.mvn clean install -DskipTests (exclude infrastructure if needed) before surefire:test. AspectJ LTW requires the full build lifecycle.createSimpleProductAndCreditPolicy callersBaseCustomPartnerFormalizationIntegrationTestVortxIntegrationTest, EzzeIntegrationTestInsuranceIntegrationTest, LoanAccountancyVortxServiceClientTestLoanDecisionModelTest, LoanCreditPolicySimulationServiceClientTestLoanRePaymentCommunicationServiceClientTest (seasonal campaign)LoanApplicationServiceClientTest (old) — 6 open-finance testsLoanCreditPolicyControlGroupServiceClientTest (old) — 2 disabled testsLoanCreditPolicySimulationServiceClientTest — entire class disabledLoanConditionsServiceClientTest — 4 disabled tests (payday engine, installment limit, conditions summary, installment overlimit)LoanAccountancyAmFiServiceClientTest — 1 disabled testtestPayBillUsingDeposit + testAnticipatedPartialAndLatePaymentstestNegotiationSimulationWithResidualBalance + testRenegotiationPopulatesConfigAndDecisionModel