0

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);
}
Deviasa
  • 153
  • 1
  • 13
  • Remove the no-arg constructor in Account class and check if it works – Grasshopper Nov 27 '18 at 14:41
  • Do you mean: public Account() {} If I do this I get: – Deviasa Nov 27 '18 at 14:45
  • > Task :compileJava FAILED C:\Users....IdeaProjects\cash_withdrawal\src\main\java\cash_withdrawal\AtmServer.java:42: error: constructor Account in class Account cannot be applied to given types; new AtmServer(9988, new CashSlot(), new Account()).start(); ^ required: int found: no arguments reason: actual and formal argument lists differ in length – Deviasa Nov 27 '18 at 14:45

0 Answers0