I am having trouble compring two strings ... i know its pretty basic but it is not working for some reason ... here is the code ...
Customer customer;
for (int i = 0; i < this.getCustomers().size(); i++) {
customer = this.getCustomerById(i);
if (customer.getFullName().toLowerCase().equals( name.toLowerCase())) {
return customer;
}
}
return new Customer();
customer.getFullName().toLowerCase().equals( name.toLowerCase()) here I compare two strings, thing is if i call the method during the cucumber test it give me this error ...
And Jim opens a current account with account number 234 # StepDefs.opens_a_current_account_with_account_number(String,int) java.lang.NullPointerException at my.bank.Bank.getCustomerByName(Bank.java:111) at my.bank.StepDefs.opens_a_current_account_with_account_number(StepDefs.java:38) at ?.And Jim opens a current account with account number 234(Customer_can_open_accounts.feature:28)
but if i create a draft of these steps in the main method and call the methods with the same parameter they work .... here is the draft ...
is_a_customer("Jim");
is_a_customer("Bob");
opens_a_savings_account_with_account_number("Jim", 123);
and if i debug it go step by step with the code it does what is expected at the end it is storing both the customer and accounts in the bank ... but for some reason when i run the cucumber test it does not work, here is the cucumber stepdef ...
public void opens_a_current_account_with_account_number(String customerName, int accountNumber) throws Throwable {
Account ac = new Account();
ac.setAccountNumber(accountNumber);
Customer customer = bank.getCustomerByName(customerName);
ac.addAccountOwner(customer.getId());
customer.addCustomerAccounts(ac.getAccountId());
bank.addAccount(ac);
}
AND THERE IS NO WAY THAT I AM AWARE OF TO DEBUG THE CUCUMBER TEST EXCEPT GRALDE CUCUMBER --DEBUG, BUT THAT IS NOT REALLY HELPFUL PLEASE HELP ....