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());
	}


}

@@ -369,52 +369,141 @@
 org.
-mockito.Mock;%0D%0Aimport org.mockito.Mockito;%0D%0A
+junit.runner.RunWith;%0D%0Aimport org.mockito.Mock;%0D%0Aimport org.mockito.runners.MockitoJUnitRunner;%0D%0A%0D%0A@RunWith(MockitoJUnitRunner.class)
 %0D%0Apu
@@ -708,67 +708,8 @@
 );%0D%0A
-%09%09generator = Mockito.mock(AccountNumberGenerator.class);%0D%0A
 %09%7D%0D%0A

implement with mock annotation