package com.accenture.multibank.dao;

import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import com.accenture.multibank.accounts.AbstractAccount;
import com.accenture.multibank.accounts.SavingAccount;

public class TestHashMapAccountDao {

	Map map = new HashMap();
	AbstractAccount acc = new SavingAccount();

	// zu testen: AccountImpl
	AccountDaoImpl accDao = new AccountDaoImpl();


	@Test
	public void testSafeAndFindAccount() {
		
		accDao.save(acc);
		
		accDao.find(acc.getAccountNumber());
		
		assertEquals(2, acc.getAccountNumber());
		assertEquals(100, acc.getBalance());
		

	}


}

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.mockito.Mock;
import org.mockito.Mockito;

public class TestHashMapAccountDao {

	AbstractDAO<Integer, AccountReadable> accDao;

	@Mock
	AccountNumberGenerator generator;

	@Before
	public void setup() {
		accDao = new AccountDaoImpl();
		generator = Mockito.mock(AccountNumberGenerator.class);
	}

	@Test
	public void testSafeAndFindAccount() {
		int accNr = 1;
		when(generator.generateAccountNumber()).thenReturn(++accNr);
		AccountReadable actual = new SavingAccount(accNr, 100);
		accDao.save(actual);

		AccountReadable expected = accDao.find(actual.getAccountNumber());

		assertEquals(expected.getAccountNumber(), actual.getAccountNumber());
	}


}

add test case (safe and find)