Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
#80[30m]. Fix all tests.
  • Loading branch information
Evgenii Kanivets committed Jun 3, 2016
commit 841ab5f58d7ef4db26c733f8fef88c818a5cd7cd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void testReadDefaultCurrency() throws Exception {
Mockito.when(accountMock.readDefaultAccount()).thenReturn(null);
assertEquals("NON", currencyController.readDefaultCurrency());

Account account = new Account(1, "a1", 100, "ACM", decimals);
Account account = new Account(1, "a1", 100, "ACM", 0);
Mockito.when(prefsMock.readDefaultCurrency()).thenReturn(null);
Mockito.when(accountMock.readDefaultAccount()).thenReturn(account);
assertEquals(account.getCurrency(), currencyController.readDefaultCurrency());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void tearDown() throws Exception {
@Test
public void testRecordAdded() throws Exception {
Category category = new Category(1, "c1");
Account account = new Account(1, "a1", 100, "NON", decimals);
Account account = new Account(1, "a1", 100, "NON", 0);
repo.create(account);

Record income = new Record(1, 1, Record.TYPE_INCOME, "income", category, 10, account,
Expand All @@ -78,7 +78,7 @@ public void testRecordAdded() throws Exception {
@Test
public void testRecordDeleted() throws Exception {
Category category = new Category(1, "c1");
Account account = new Account(1, "a1", 100, "NON", decimals);
Account account = new Account(1, "a1", 100, "NON", 0);
repo.create(account);

Record income = new Record(1, 1, Record.TYPE_INCOME, "income", category, 10, account,
Expand All @@ -104,7 +104,7 @@ public void testRecordDeleted() throws Exception {
@Test
public void testRecordUpdated() throws Exception {
Category category = new Category(1, "c1");
Account account = new Account(1, "a1", 100, "NON", decimals);
Account account = new Account(1, "a1", 100, "NON", 0);
repo.create(account);

Record incomeOld = new Record(1, 1, Record.TYPE_INCOME, "income", category, 10, account,
Expand Down Expand Up @@ -139,8 +139,8 @@ public void testRecordUpdated() throws Exception {

@Test
public void testTransferDone() throws Exception {
Account account1 = new Account(1, "a1", 100, "NON", decimals);
Account account2 = new Account(2, "a2", 0, "NON", decimals);
Account account1 = new Account(1, "a1", 100, "NON", 0);
Account account2 = new Account(2, "a2", 0, "NON", 0);

repo.create(account1);
repo.create(account2);
Expand All @@ -149,22 +149,22 @@ public void testTransferDone() throws Exception {
assertEquals(100, account1.getCurSum());
assertEquals(0, account2.getCurSum());

Transfer transfer = new Transfer(1, 1, account1.getId(), account2.getId(), 10, 10, fromDecimals, toDecimals);
Transfer transfer = new Transfer(1, 1, account1.getId(), account2.getId(), 10, 10, 0, 0);
accountController.transferDone(transfer);
assertEquals(90, account1.getCurSum());
assertEquals(10, account2.getCurSum());

transfer = new Transfer(2, 1, account1.getId(), account2.getId(), 10, 10, fromDecimals, toDecimals);
transfer = new Transfer(2, 1, account1.getId(), account2.getId(), 10, 10, 0, 0);
accountController.transferDone(transfer);
assertEquals(80, account1.getCurSum());
assertEquals(20, account2.getCurSum());

transfer = new Transfer(2, 1, account2.getId(), account1.getId(), 20, 20, fromDecimals, toDecimals);
transfer = new Transfer(2, 1, account2.getId(), account1.getId(), 20, 20, 0, 0);
accountController.transferDone(transfer);
assertEquals(100, account1.getCurSum());
assertEquals(0, account2.getCurSum());

transfer = new Transfer(2, 1, account1.getId(), account2.getId(), 0, 100, fromDecimals, toDecimals);
transfer = new Transfer(2, 1, account1.getId(), account2.getId(), 0, 100, 0, 0);
accountController.transferDone(transfer);
assertEquals(100, account1.getCurSum());
assertEquals(100, account2.getCurSum());
Expand All @@ -174,11 +174,11 @@ public void testTransferDone() throws Exception {
public void testReadDefaultAccount() throws Exception {
assertNull(accountController.readDefaultAccount());

Account account1 = new Account(1, "a1", 100, "NON", decimals);
Account account1 = new Account(1, "a1", 100, "NON", 0);
repo.create(account1);
assertEquals(account1, accountController.readDefaultAccount());

Account account2 = new Account(2, "a2", 0, "NON", decimals);
Account account2 = new Account(2, "a2", 0, "NON", 0);
repo.create(account2);
assertEquals(account1, accountController.readDefaultAccount());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testCreate() throws Exception {
Mockito.verify(accountMock, Mockito.times(0)).recordAdded(null);

Category category = new Category(1, "c1");
Account account = new Account(1, "a1", 100, "NON", decimals);
Account account = new Account(1, "a1", 100, "NON", 0);
Record record = new Record(1, 1, Record.TYPE_INCOME, "r1", category, 10, account, "NON");
Mockito.when(categoryMock.readOrCreate(category.getName())).thenReturn(category);

Expand All @@ -78,7 +78,7 @@ public void testUpdate() throws Exception {
Mockito.verify(accountMock, Mockito.times(0)).recordAdded(null);

Category category = new Category(1, "c1");
Account account = new Account(1, "a1", 100, "NON", decimals);
Account account = new Account(1, "a1", 100, "NON", 0);
Record record = new Record(1, 1, Record.TYPE_INCOME, "r1", category, 10, account, "NON");
Mockito.when(categoryMock.readOrCreate(category.getName())).thenReturn(category);

Expand All @@ -95,7 +95,7 @@ public void testDelete() throws Exception {
Mockito.verify(accountMock, Mockito.times(0)).recordDeleted(null);

Category category = new Category(1, "c1");
Account account = new Account(1, "a1", 100, "NON", decimals);
Account account = new Account(1, "a1", 100, "NON", 0);
Record record = new Record(1, 1, Record.TYPE_INCOME, "r1", category, 10, account, "NON");

assertFalse(recordController.delete(record));
Expand All @@ -112,8 +112,9 @@ public void testRead() throws Exception {
assertNull(recordController.read(-1));

Category category = new Category(1, "c1");
Account account = new Account(1, "a1", 100, "NON", decimals);
Record recordNotFull = new Record(1, 1, Record.TYPE_INCOME, "r1", category.getId(), 10, account.getId(), "NON");
Account account = new Account(1, "a1", 100, "NON", 0);
Record recordNotFull = new Record(1, 1, Record.TYPE_INCOME, "r1", category.getId(), 10,
account.getId(), "NON", 0);
Record record = new Record(1, 1, Record.TYPE_INCOME, "r1", category, 10, account, "NON");

repo.create(recordNotFull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class TransferControllerTest {
@Test
public void testCreate() throws Exception {
AccountController mock = Mockito.mock(AccountController.class);
Transfer transfer = new Transfer(1, 1, 1, 2, 10, 20, fromDecimals, toDecimals);
Transfer transfer = new Transfer(1, 1, 1, 2, 10, 20, 0, 0);

Mockito.when(mock.transferDone(transfer)).thenReturn(true);
Mockito.when(mock.transferDone(null)).thenReturn(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public void testGetRate() throws Exception {
provider = new ExchangeRateProvider("USD", rateController);

assertEquals(new ExchangeRate(1, "UAH", "USD", 4),
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "UAH")));
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "UAH", 0)));

assertEquals(new ExchangeRate(0, "AFN", "USD", 3),
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "AFN")));
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "AFN", 0)));

assertNull(provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "SMTH")));
assertNull(provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "SMTH", 0)));
}

private static class TestRepo implements IRepo<ExchangeRate> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public void testGetSummary() throws Exception {
List<Record> recordList = new ArrayList<>();

Category category = new Category(1, "category");
Account account1 = new Account(1, "account1", 100, "UAH", decimals);
Account account2 = new Account(2, "account2", 100, "USD", decimals);
Account account1 = new Account(1, "account1", 100, "UAH", 0);
Account account2 = new Account(2, "account2", 100, "USD", 0);

Record record1 = new Record(1, 0, Record.TYPE_INCOME, "1", category, 10, account2, "USD");
recordList.add(record1);
Expand Down Expand Up @@ -220,8 +220,8 @@ private List<Record> getRecordList() {
List<Record> recordList = new ArrayList<>();

Category category = new Category(1, "category");
Account account1 = new Account(1, "account1", 100, "UAH", decimals);
Account account2 = new Account(2, "account2", 100, "USD", decimals);
Account account1 = new Account(1, "account1", 100, "UAH", 0);
Account account2 = new Account(2, "account2", 100, "USD", 0);

Record record1 = new Record(1, 0, Record.TYPE_INCOME, "1", category, 10, account2, "USD");
recordList.add(record1);
Expand Down