Skip to content

Instantly share code, notes, and snippets.

@yanickxia
Created December 9, 2015 02:31
Show Gist options
  • Save yanickxia/693fc2684fc3a65ac915 to your computer and use it in GitHub Desktop.
Save yanickxia/693fc2684fc3a65ac915 to your computer and use it in GitHub Desktop.
Final_Method_In_Abstart_Class
public abstract class BaseLoaneeRepayment implements Repayment {
@Autowired
protected LoanRepository loanRepository;
@Transactional(propagation = Propagation.REQUIRES_NEW)
public final void repay(RepaymentInfo repaymentInfo) {
Loan loan = loanRepository.lockAndLoad(repaymentInfo.getLoan().id());
}
protected abstract void preCheck(final RepaymentInfo repaymentInfo);
protected abstract void updateLoanee(final RepaymentInfo repaymentInfo);
protected abstract void repayment(final RepaymentInfo repaymentInfo);
protected abstract void calcDifference(final RepaymentInfo repaymentInfo);
}
@Service("loaneeNormalRepayment")
public class NormalRepayment extends BaseLoaneeRepayment implements Repayment {
@Override
public final void preCheck(RepaymentInfo repaymentInfo) {}
@Override
public final void updateLoanee(RepaymentInfo repaymentInfo) {}
@Override
public final void repayment(RepaymentInfo repaymentInfo) {}
@Override
public final void calcDifference(RepaymentInfo repaymentInfo) {}
}
@TransactionConfiguration(defaultRollback = true)
public class NormalRepaymentTest extends ServiceTest {
@Autowired
@Qualifier("normalRepayment2")
private NormalRepayment normalRepayment;
@Autowired
private LoanService loanService;
@Test
public void test() {
normalRepayment.repay(repaymentInfo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment