package com.example.spring.bank.dev; import java.math.BigDecimal; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; import com.example.spring.bank.account.Account; import com.example.spring.bank.account.AccountManager; import com.example.spring.bank.customer.Customer; import com.example.spring.bank.customer.CustomerManager; @Component public class AppInit implements CommandLineRunner { @Autowired private AccountManager accountManager; @Autowired private CustomerManager customerManager; @Value("${bankapp.init-testdata}") private boolean initTestData; @Override public void run(String... args) throws Exception { // Create test accounts. if (initTestData) { Account acc1 = accountManager.create(new Account(new BigDecimal("0.00"))); Account acc2 = accountManager.create(new Account(new BigDecimal("0.00"))); Customer c1 = customerManager.create(new Customer("Madushi")); Customer c2 = customerManager.create(new Customer("Anuradha")); Customer customerSamitha = customerManager.create(new Customer("Samitha")); Account accountSamitha = accountManager.create(new Account(new BigDecimal("0.00"))); customerManager.addAccount(customerSamitha, accountSamitha); } } }