package com.accenture.multibank.dao;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

import com.accenture.multibank.accounts.AccountReadable;
import com.accenture.multibank.generator.AccountNumberGenerator;
import org.junit.Before;
import org.junit.Test;

import com.accenture.multibank.accounts.SavingAccount;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class TestHashMapAccountDao {

	AbstractDAO<Integer, AccountReadable> accDao;
	int accNr;

	@Mock
	AccountNumberGenerator generator;

	@Before
	public void setup() {
		accDao = new HashMapAccountDAO();
		accNr = 1;
		when(generator.generateAccountNumber()).thenReturn(++accNr);
	}

	@Test
	public void safeAndFindAccount() {
		AccountReadable actual = new SavingAccount(accNr, 100);
		accDao.save(actual);

		AccountReadable expected = accDao.find(actual.getAccountNumber());
		assertEquals(expected, actual);
	}

	@Test(expected = NullPointerException.class)
	public void safeNullAccount() {
		AccountReadable actual = null;
		accDao.save(actual);
	}

	@Test()
	public void findAccountThatDoesNotExist() {
		AccountReadable actual = accDao.find(0);
		assertEquals(null, actual);
	}

	@Test
	public void deleteAccountThatDoesNotExist() {
		AccountReadable accountReadable = accDao.delete(0);
		assertEquals(null, accountReadable);
	}

	@Test
	public void updateAccountThatDoesNotExist() {
		AccountReadable tmp = new SavingAccount(generator.generateAccountNumber(), 0);
		accDao.update(tmp);

		AccountReadable actual = accDao.find(accNr);
		assertEquals(null, actual);
	}

}

@@ -118,24 +118,84 @@
 to.when;%0D%0A%0D%0A
+import com.accenture.multibank.accounts.AccountModifiable;%0D%0A
 import com.a
@@ -236,24 +236,24 @@
 tReadable;%0D%0A
-
 import com.a
@@ -625,28 +625,30 @@
 ger, Account
-Read
+Modifi
 able%3E accDao
@@ -912,36 +912,38 @@
 t() %7B%0D%0A%09%09Account
-Read
+Modifi
 able actual = ne
@@ -1191,36 +1191,38 @@
 t() %7B%0D%0A%09%09Account
-Read
+Modifi
 able actual = nu
@@ -1313,36 +1313,38 @@
 t() %7B%0D%0A%09%09Account
-Read
+Modifi
 able actual = ac
@@ -1456,28 +1456,30 @@
 %7B%0D%0A%09%09Account
-Read
+Modifi
 able account
@@ -1615,28 +1615,30 @@
 %7B%0D%0A%09%09Account
-Read
+Modifi
 able tmp = n
@@ -1724,28 +1724,30 @@
 %0A%0D%0A%09%09Account
-Read
+Modifi
 able actual 

change type to AccountModifiable