Something went wrong in my test with models, since I add a Dependency Injection

37 views Asked by At

I try to make my test simpler with a DI (PicoContainer), but now it doesn't work corrctly anymore.

I get this errormassages:


java.lang.NullPointerException

at org.javalite.activejdbc.Model.setRaw(Model.java:355)

at org.javalite.activejdbc.Model.setInteger(Model.java:1740)

at cash_withdrawal.Account.(Account.java:11)

at support.TestAccount.(TestAccount.java:7)

....


support.TestAccount:

   public class TestAccount extends Account {
    public TestAccount() {
        super(1234);
        saveIt();
        }
    }

cash_withdrawal.Account

 public class Account extends Model {
    private TransactionQueue queue = new TransactionQueue();

    public Account() {}

    public Account(int number){
        setInteger("number", number);
        setString("balance", "0.00");
    }
}

My Stepdefintion:

public class AccountSteps {
TestAccount account;

public AccountSteps(TestAccount account) {
    this.account = account;
}

@Given("^my account has been credited with (\\$\\d+\\.\\d+)$")
public void myAccountHasBeenCreditedWith$(
        @Transform(MoneyConverter.class) Money amount)
        throws Throwable {
    account.credit(amount);
}
0

There are 0 answers