Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 841ab5f

Browse files
author
Evgenii Kanivets
committed
#80[30m]. Fix all tests.
1 parent 0539906 commit 841ab5f

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

app/src/test/java/com/blogspot/e_kanivets/moneytracker/controller/CurrencyControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void testReadDefaultCurrency() throws Exception {
2626
Mockito.when(accountMock.readDefaultAccount()).thenReturn(null);
2727
assertEquals("NON", currencyController.readDefaultCurrency());
2828

29-
Account account = new Account(1, "a1", 100, "ACM", decimals);
29+
Account account = new Account(1, "a1", 100, "ACM", 0);
3030
Mockito.when(prefsMock.readDefaultCurrency()).thenReturn(null);
3131
Mockito.when(accountMock.readDefaultAccount()).thenReturn(account);
3232
assertEquals(account.getCurrency(), currencyController.readDefaultCurrency());

app/src/test/java/com/blogspot/e_kanivets/moneytracker/controller/data/AccountControllerTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void tearDown() throws Exception {
5252
@Test
5353
public void testRecordAdded() throws Exception {
5454
Category category = new Category(1, "c1");
55-
Account account = new Account(1, "a1", 100, "NON", decimals);
55+
Account account = new Account(1, "a1", 100, "NON", 0);
5656
repo.create(account);
5757

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

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

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

140140
@Test
141141
public void testTransferDone() throws Exception {
142-
Account account1 = new Account(1, "a1", 100, "NON", decimals);
143-
Account account2 = new Account(2, "a2", 0, "NON", decimals);
142+
Account account1 = new Account(1, "a1", 100, "NON", 0);
143+
Account account2 = new Account(2, "a2", 0, "NON", 0);
144144

145145
repo.create(account1);
146146
repo.create(account2);
@@ -149,22 +149,22 @@ public void testTransferDone() throws Exception {
149149
assertEquals(100, account1.getCurSum());
150150
assertEquals(0, account2.getCurSum());
151151

152-
Transfer transfer = new Transfer(1, 1, account1.getId(), account2.getId(), 10, 10, fromDecimals, toDecimals);
152+
Transfer transfer = new Transfer(1, 1, account1.getId(), account2.getId(), 10, 10, 0, 0);
153153
accountController.transferDone(transfer);
154154
assertEquals(90, account1.getCurSum());
155155
assertEquals(10, account2.getCurSum());
156156

157-
transfer = new Transfer(2, 1, account1.getId(), account2.getId(), 10, 10, fromDecimals, toDecimals);
157+
transfer = new Transfer(2, 1, account1.getId(), account2.getId(), 10, 10, 0, 0);
158158
accountController.transferDone(transfer);
159159
assertEquals(80, account1.getCurSum());
160160
assertEquals(20, account2.getCurSum());
161161

162-
transfer = new Transfer(2, 1, account2.getId(), account1.getId(), 20, 20, fromDecimals, toDecimals);
162+
transfer = new Transfer(2, 1, account2.getId(), account1.getId(), 20, 20, 0, 0);
163163
accountController.transferDone(transfer);
164164
assertEquals(100, account1.getCurSum());
165165
assertEquals(0, account2.getCurSum());
166166

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

177-
Account account1 = new Account(1, "a1", 100, "NON", decimals);
177+
Account account1 = new Account(1, "a1", 100, "NON", 0);
178178
repo.create(account1);
179179
assertEquals(account1, accountController.readDefaultAccount());
180180

181-
Account account2 = new Account(2, "a2", 0, "NON", decimals);
181+
Account account2 = new Account(2, "a2", 0, "NON", 0);
182182
repo.create(account2);
183183
assertEquals(account1, accountController.readDefaultAccount());
184184

app/src/test/java/com/blogspot/e_kanivets/moneytracker/controller/data/RecordControllerTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void testCreate() throws Exception {
6060
Mockito.verify(accountMock, Mockito.times(0)).recordAdded(null);
6161

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

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

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

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

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

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

114114
Category category = new Category(1, "c1");
115-
Account account = new Account(1, "a1", 100, "NON", decimals);
116-
Record recordNotFull = new Record(1, 1, Record.TYPE_INCOME, "r1", category.getId(), 10, account.getId(), "NON");
115+
Account account = new Account(1, "a1", 100, "NON", 0);
116+
Record recordNotFull = new Record(1, 1, Record.TYPE_INCOME, "r1", category.getId(), 10,
117+
account.getId(), "NON", 0);
117118
Record record = new Record(1, 1, Record.TYPE_INCOME, "r1", category, 10, account, "NON");
118119

119120
repo.create(recordNotFull);

app/src/test/java/com/blogspot/e_kanivets/moneytracker/controller/data/TransferControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class TransferControllerTest {
2424
@Test
2525
public void testCreate() throws Exception {
2626
AccountController mock = Mockito.mock(AccountController.class);
27-
Transfer transfer = new Transfer(1, 1, 1, 2, 10, 20, fromDecimals, toDecimals);
27+
Transfer transfer = new Transfer(1, 1, 1, 2, 10, 20, 0, 0);
2828

2929
Mockito.when(mock.transferDone(transfer)).thenReturn(true);
3030
Mockito.when(mock.transferDone(null)).thenReturn(false);

app/src/test/java/com/blogspot/e_kanivets/moneytracker/report/ExchangeRateProviderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ public void testGetRate() throws Exception {
6868
provider = new ExchangeRateProvider("USD", rateController);
6969

7070
assertEquals(new ExchangeRate(1, "UAH", "USD", 4),
71-
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "UAH")));
71+
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "UAH", 0)));
7272

7373
assertEquals(new ExchangeRate(0, "AFN", "USD", 3),
74-
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "AFN")));
74+
provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "AFN", 0)));
7575

76-
assertNull(provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "SMTH")));
76+
assertNull(provider.getRate(new Record(1, 0, 0, "", 1, 0, 0, "SMTH", 0)));
7777
}
7878

7979
private static class TestRepo implements IRepo<ExchangeRate> {

app/src/test/java/com/blogspot/e_kanivets/moneytracker/report/ReportTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ public void testGetSummary() throws Exception {
175175
List<Record> recordList = new ArrayList<>();
176176

177177
Category category = new Category(1, "category");
178-
Account account1 = new Account(1, "account1", 100, "UAH", decimals);
179-
Account account2 = new Account(2, "account2", 100, "USD", decimals);
178+
Account account1 = new Account(1, "account1", 100, "UAH", 0);
179+
Account account2 = new Account(2, "account2", 100, "USD", 0);
180180

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

222222
Category category = new Category(1, "category");
223-
Account account1 = new Account(1, "account1", 100, "UAH", decimals);
224-
Account account2 = new Account(2, "account2", 100, "USD", decimals);
223+
Account account1 = new Account(1, "account1", 100, "UAH", 0);
224+
Account account2 = new Account(2, "account2", 100, "USD", 0);
225225

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

0 commit comments

Comments
 (0)