X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Ftest%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FMobileLedgerProfileTest.java;fp=app%2Fsrc%2Ftest%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FMobileLedgerProfileTest.java;h=0000000000000000000000000000000000000000;hp=edbd5a7407123ee07aab9326cef0e96eaf33dd63;hb=5df10dc0b58df4d4be4e9ab34f1e0f477ca46766;hpb=7c71910950d18868e1f419eed5234f113ee51776
diff --git a/app/src/test/java/net/ktnx/mobileledger/model/MobileLedgerProfileTest.java b/app/src/test/java/net/ktnx/mobileledger/model/MobileLedgerProfileTest.java
deleted file mode 100644
index edbd5a74..00000000
--- a/app/src/test/java/net/ktnx/mobileledger/model/MobileLedgerProfileTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright © 2020 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see .
- */
-
-package net.ktnx.mobileledger.model;
-
-import org.junit.Test;
-import org.junit.internal.ArrayComparisonFailure;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
-
-public class MobileLedgerProfileTest {
- private List listFromArray(LedgerAccount[] array) {
- ArrayList result = new ArrayList<>();
- Collections.addAll(result, array);
-
- return result;
- }
- private void aTest(LedgerAccount[] oldList, LedgerAccount[] newList,
- LedgerAccount[] expectedResult) {
- List result =
- MobileLedgerProfile.mergeAccountListsFromWeb(listFromArray(oldList),
- listFromArray(newList));
- assertArrayEquals(expectedResult, result.toArray());
- }
- private void negTest(LedgerAccount[] oldList, LedgerAccount[] newList,
- LedgerAccount[] expectedResult) {
- List result =
- MobileLedgerProfile.mergeAccountListsFromWeb(listFromArray(oldList),
- listFromArray(newList));
- assertThrows(ArrayComparisonFailure.class,
- () -> assertArrayEquals(expectedResult, result.toArray()));
- }
- private LedgerAccount[] emptyArray() {
- return new LedgerAccount[]{};
- }
- @Test
- public void mergeEmptyLists() {
- aTest(emptyArray(), emptyArray(), emptyArray());
- }
- @Test
- public void mergeIntoEmptyLists() {
- LedgerAccount acc1 = new LedgerAccount(null, "Acc1", null);
- aTest(emptyArray(), new LedgerAccount[]{acc1}, new LedgerAccount[]{acc1});
- }
- @Test
- public void mergeEmptyList() {
- LedgerAccount acc1 = new LedgerAccount(null, "Acc1", null);
- aTest(new LedgerAccount[]{acc1}, emptyArray(), emptyArray());
- }
- @Test
- public void mergeEqualLists() {
- LedgerAccount acc1 = new LedgerAccount(null, "Acc1", null);
- aTest(new LedgerAccount[]{acc1}, new LedgerAccount[]{acc1}, new LedgerAccount[]{acc1});
- }
- @Test
- public void mergeFlags() {
- LedgerAccount acc1a = new LedgerAccount(null, "Acc1", null);
- LedgerAccount acc1b = new LedgerAccount(null, "Acc1", null);
- acc1b.setExpanded(true);
- acc1b.setAmountsExpanded(true);
- List merged = MobileLedgerProfile.mergeAccountListsFromWeb(
- listFromArray(new LedgerAccount[]{acc1a}),
- listFromArray(new LedgerAccount[]{acc1b}));
- assertArrayEquals(new LedgerAccount[]{acc1b}, merged.toArray());
- assertSame(merged.get(0), acc1a);
- // restore original values, modified by the merge
- acc1a.setExpanded(false);
- acc1a.setAmountsExpanded(false);
- negTest(new LedgerAccount[]{acc1a}, new LedgerAccount[]{acc1b},
- new LedgerAccount[]{new LedgerAccount(null, "Acc1", null)});
- }
-}
\ No newline at end of file