From ce5ec2c5a9911ddbbd84e2f4d99f8e8d53c835fe Mon Sep 17 00:00:00 2001 From: Aglag257 Date: Sat, 18 May 2024 11:26:36 +0300 Subject: [PATCH 1/6] Fixed formatting and describeContents() --- .../java/protect/card_locker/LoyaltyCard.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCard.java b/app/src/main/java/protect/card_locker/LoyaltyCard.java index 95e68f0775..96afcfc269 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCard.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCard.java @@ -35,10 +35,10 @@ public class LoyaltyCard implements Parcelable { public int zoomLevel; public LoyaltyCard(final int id, final String store, final String note, @Nullable final Date validFrom, - @Nullable final Date expiry, final BigDecimal balance, @Nullable final Currency balanceType, - final String cardId, @Nullable final String barcodeId, @Nullable final CatimaBarcode barcodeType, - @Nullable final Integer headerColor, final int starStatus, - final long lastUsed, final int zoomLevel, final int archiveStatus) { + @Nullable final Date expiry, final BigDecimal balance, @Nullable final Currency balanceType, + final String cardId, @Nullable final String barcodeId, @Nullable final CatimaBarcode barcodeType, + @Nullable final Integer headerColor, final int starStatus, + final long lastUsed, final int zoomLevel, final int archiveStatus) { this.id = id; this.store = store; this.note = note; @@ -103,7 +103,8 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) { String note = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.NOTE)); long validFromLong = cursor.getLong(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.VALID_FROM)); long expiryLong = cursor.getLong(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.EXPIRY)); - BigDecimal balance = new BigDecimal(cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BALANCE))); + BigDecimal balance = new BigDecimal( + cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BALANCE))); String cardId = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.CARD_ID)); String barcodeId = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BARCODE_ID)); int starred = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.STAR_STATUS)); @@ -141,7 +142,8 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) { headerColor = cursor.getInt(headerColorColumn); } - return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, starred, lastUsed, zoomLevel, archived); + return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, + headerColor, starred, lastUsed, zoomLevel, archived); } public static boolean isDuplicate(final LoyaltyCard a, final LoyaltyCard b) { @@ -156,7 +158,9 @@ public static boolean isDuplicate(final LoyaltyCard a, final LoyaltyCard b) { a.cardId.equals(b.cardId) && // non-nullable String Utils.equals(a.barcodeId, b.barcodeId) && // nullable String Utils.equals(a.barcodeType == null ? null : a.barcodeType.format(), - b.barcodeType == null ? null : b.barcodeType.format()) && // nullable CatimaBarcode with no overridden .equals(), so we need to check .format() + b.barcodeType == null ? null : b.barcodeType.format()) + && // nullable CatimaBarcode with no overridden .equals(), so we need to check + // .format() Utils.equals(a.headerColor, b.headerColor) && // nullable Integer a.starStatus == b.starStatus && // non-nullable int a.archiveStatus == b.archiveStatus; // non-nullable int @@ -188,8 +192,7 @@ public String toString() { this.starStatus, this.lastUsed, this.zoomLevel, - this.archiveStatus - ); + this.archiveStatus); } public static final Creator CREATOR = new Creator() { From 84537adb980cb35d2401939c8a0fa7bc84ebea6f Mon Sep 17 00:00:00 2001 From: Aglag257 Date: Mon, 20 May 2024 12:37:31 +0300 Subject: [PATCH 2/6] Revert formatting changes and fix describeContents() to return 0 --- .../java/protect/card_locker/LoyaltyCard.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCard.java b/app/src/main/java/protect/card_locker/LoyaltyCard.java index 96afcfc269..95e68f0775 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCard.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCard.java @@ -35,10 +35,10 @@ public class LoyaltyCard implements Parcelable { public int zoomLevel; public LoyaltyCard(final int id, final String store, final String note, @Nullable final Date validFrom, - @Nullable final Date expiry, final BigDecimal balance, @Nullable final Currency balanceType, - final String cardId, @Nullable final String barcodeId, @Nullable final CatimaBarcode barcodeType, - @Nullable final Integer headerColor, final int starStatus, - final long lastUsed, final int zoomLevel, final int archiveStatus) { + @Nullable final Date expiry, final BigDecimal balance, @Nullable final Currency balanceType, + final String cardId, @Nullable final String barcodeId, @Nullable final CatimaBarcode barcodeType, + @Nullable final Integer headerColor, final int starStatus, + final long lastUsed, final int zoomLevel, final int archiveStatus) { this.id = id; this.store = store; this.note = note; @@ -103,8 +103,7 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) { String note = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.NOTE)); long validFromLong = cursor.getLong(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.VALID_FROM)); long expiryLong = cursor.getLong(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.EXPIRY)); - BigDecimal balance = new BigDecimal( - cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BALANCE))); + BigDecimal balance = new BigDecimal(cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BALANCE))); String cardId = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.CARD_ID)); String barcodeId = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BARCODE_ID)); int starred = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.STAR_STATUS)); @@ -142,8 +141,7 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) { headerColor = cursor.getInt(headerColorColumn); } - return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, - headerColor, starred, lastUsed, zoomLevel, archived); + return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, starred, lastUsed, zoomLevel, archived); } public static boolean isDuplicate(final LoyaltyCard a, final LoyaltyCard b) { @@ -158,9 +156,7 @@ public static boolean isDuplicate(final LoyaltyCard a, final LoyaltyCard b) { a.cardId.equals(b.cardId) && // non-nullable String Utils.equals(a.barcodeId, b.barcodeId) && // nullable String Utils.equals(a.barcodeType == null ? null : a.barcodeType.format(), - b.barcodeType == null ? null : b.barcodeType.format()) - && // nullable CatimaBarcode with no overridden .equals(), so we need to check - // .format() + b.barcodeType == null ? null : b.barcodeType.format()) && // nullable CatimaBarcode with no overridden .equals(), so we need to check .format() Utils.equals(a.headerColor, b.headerColor) && // nullable Integer a.starStatus == b.starStatus && // non-nullable int a.archiveStatus == b.archiveStatus; // non-nullable int @@ -192,7 +188,8 @@ public String toString() { this.starStatus, this.lastUsed, this.zoomLevel, - this.archiveStatus); + this.archiveStatus + ); } public static final Creator CREATOR = new Creator() { From f7d8f70135f74e224961517ec7bf246a3bf3a3e7 Mon Sep 17 00:00:00 2001 From: Aglag257 Date: Tue, 4 Jun 2024 15:35:08 +0300 Subject: [PATCH 3/6] LoyaltyCardTest and necessary changes --- .../protect/card_locker/LoyaltyCardTest.java | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 app/src/test/java/protect/card_locker/LoyaltyCardTest.java diff --git a/app/src/test/java/protect/card_locker/LoyaltyCardTest.java b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java new file mode 100644 index 0000000000..c8bd10f3ee --- /dev/null +++ b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java @@ -0,0 +1,105 @@ +import android.os.Parcel; +import android.os.Parcelable; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +import java.math.BigDecimal; +import java.util.Currency; +import java.util.Date; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +@RunWith(MockitoJUnitRunner.class) +public class LoyaltyCardTest { + + /** + * Test the parcelable implementation of the LoyaltyCard class. + * + * This test creates a LoyaltyCard object, writes it to a Parcel, and then + * recreates the object from the Parcel. It asserts that the original and + * recreated objects have the same values for all their fields. + * + * @throws AssertionError if any of the assertions fail + */ + @Test + public void testParcelable() { + + Date validFrom = new Date(); + Date expiry = new Date(); + BigDecimal balance = new BigDecimal("100.00"); + Currency currency = Currency.getInstance("USD"); + LoyaltyCard card = new LoyaltyCard(1, "Store A", "Note A", validFrom, expiry, balance, currency, "12345", "67890", CatimaBarcode.QR_CODE, 0xFF0000, 1, System.currentTimeMillis(), 10, 0); + + Parcel parcel = Parcel.obtain(); + card.writeToParcel(parcel, card.describeContents()); + + parcel.setDataPosition(0); + + LoyaltyCard createdFromParcel = LoyaltyCard.CREATOR.createFromParcel(parcel); + + assertEquals(card.id, createdFromParcel.id); + assertEquals(card.store, createdFromParcel.store); + assertEquals(card.note, createdFromParcel.note); + assertEquals(card.validFrom, createdFromParcel.validFrom); + assertEquals(card.expiry, createdFromParcel.expiry); + assertEquals(card.balance, createdFromParcel.balance); + assertEquals(card.balanceType, createdFromParcel.balanceType); + assertEquals(card.cardId, createdFromParcel.cardId); + assertEquals(card.barcodeId, createdFromParcel.barcodeId); + assertEquals(card.barcodeType, createdFromParcel.barcodeType); + assertEquals(card.headerColor, createdFromParcel.headerColor); + assertEquals(card.starStatus, createdFromParcel.starStatus); + assertEquals(card.lastUsed, createdFromParcel.lastUsed); + assertEquals(card.zoomLevel, createdFromParcel.zoomLevel); + assertEquals(card.archiveStatus, createdFromParcel.archiveStatus); + + parcel.recycle(); + } + + @Test + public void testIsDuplicate_sameObject() { + Date now = new Date(); + BigDecimal balance = new BigDecimal("50.00"); + Currency currency = Currency.getInstance("EUR"); + LoyaltyCard card1 = new LoyaltyCard(1, "Store B", "Note B", now, now, balance, currency, "22222", "33333", CatimaBarcode.PDF_417, 0x00FF00, 1, System.currentTimeMillis(), 5, 1); + + assertTrue(LoyaltyCard.isDuplicate(card1, card1)); + } + + @Test + public void testIsDuplicate_differentObjects() { + Date now = new Date(); + BigDecimal balance1 = new BigDecimal("50.00"); + BigDecimal balance2 = new BigDecimal("75.00"); + Currency currency = Currency.getInstance("EUR"); + LoyaltyCard card1 = new LoyaltyCard(2, "Store C", "Note C", now, now, balance1, currency, "44444", "55555", CatimaBarcode.DATA_MATRIX, 0x0000FF, 0, System.currentTimeMillis(), 15, 1); + LoyaltyCard card2 = new LoyaltyCard(2, "Store C", "Note C", now, now, balance2, currency, "44444", "55555", CatimaBarcode.DATA_MATRIX, 0x0000FF, 0, System.currentTimeMillis(), 15, 1); + + assertFalse(LoyaltyCard.isDuplicate(card1, card2)); + } + + @Test + public void testToString() { + Date now = new Date(); + BigDecimal balance = new BigDecimal("100.00"); + Currency currency = Currency.getInstance("USD"); + LoyaltyCard card = new LoyaltyCard(3, "Store D", "Note D", now, now, balance, currency, "66666", "77777", CatimaBarcode.AZTEC, null, 2, System.currentTimeMillis(), 20, 2); + + String expected = String.format( + "LoyaltyCard{%n id=%s,%n store=%s,%n note=%s,%n validFrom=%s,%n expiry=%s,%n" + + " balance=%s,%n balanceType=%s,%n cardId=%s,%n barcodeId=%s,%n barcodeType=%s,%n" + + " headerColor=%s,%n starStatus=%s,%n lastUsed=%s,%n zoomLevel=%s,%n archiveStatus=%s%n}", + card.id, card.store, card.note, card.validFrom, card.expiry, + card.balance, card.balanceType, card.cardId, card.barcodeId, + card.barcodeType != null ? card.barcodeType.format() : null, + card.headerColor, card.starStatus, card.lastUsed, card.zoomLevel, card.archiveStatus); + + assertEquals(expected, card.toString()); + } +} From f1f38d1366a280424eb2477c95bd046cdcc53e4c Mon Sep 17 00:00:00 2001 From: Aglag257 Date: Tue, 4 Jun 2024 15:59:59 +0300 Subject: [PATCH 4/6] better handling of the Parcelable implementation --- .../java/protect/card_locker/LoyaltyCard.java | 16 ++++++++-- .../protect/card_locker/LoyaltyCardTest.java | 32 +++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCard.java b/app/src/main/java/protect/card_locker/LoyaltyCard.java index 95e68f0775..4b004f6ae5 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCard.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCard.java @@ -68,8 +68,8 @@ protected LoyaltyCard(Parcel in) { balanceType = (Currency) in.readValue(Currency.class.getClassLoader()); cardId = in.readString(); barcodeId = in.readString(); - String tmpBarcodeType = in.readString(); - barcodeType = !tmpBarcodeType.isEmpty() ? CatimaBarcode.fromName(tmpBarcodeType) : null; + String barcodeTypeName = in.readString(); + barcodeType = barcodeTypeName != null && !barcodeTypeName.isEmpty() ? CatimaBarcode.fromName(barcodeTypeName) : null; int tmpHeaderColor = in.readInt(); headerColor = tmpHeaderColor != -1 ? tmpHeaderColor : null; starStatus = in.readInt(); @@ -97,6 +97,18 @@ public void writeToParcel(Parcel parcel, int i) { parcel.writeInt(archiveStatus); } + public static final Creator CREATOR = new Creator() { + @Override + public LoyaltyCard createFromParcel(Parcel in) { + return new LoyaltyCard(in); + } + + @Override + public LoyaltyCard[] newArray(int size) { + return new LoyaltyCard[size]; + } + }; +} public static LoyaltyCard toLoyaltyCard(Cursor cursor) { int id = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ID)); String store = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.STORE)); diff --git a/app/src/test/java/protect/card_locker/LoyaltyCardTest.java b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java index c8bd10f3ee..575aa01c98 100644 --- a/app/src/test/java/protect/card_locker/LoyaltyCardTest.java +++ b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java @@ -1,3 +1,5 @@ +package protect.card_locker; + import android.os.Parcel; import android.os.Parcelable; @@ -9,32 +11,20 @@ import java.util.Currency; import java.util.Date; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import com.google.zxing.BarcodeFormat; + +import static org.junit.Assert.*; @RunWith(MockitoJUnitRunner.class) public class LoyaltyCardTest { - /** - * Test the parcelable implementation of the LoyaltyCard class. - * - * This test creates a LoyaltyCard object, writes it to a Parcel, and then - * recreates the object from the Parcel. It asserts that the original and - * recreated objects have the same values for all their fields. - * - * @throws AssertionError if any of the assertions fail - */ @Test public void testParcelable() { - Date validFrom = new Date(); Date expiry = new Date(); BigDecimal balance = new BigDecimal("100.00"); Currency currency = Currency.getInstance("USD"); - LoyaltyCard card = new LoyaltyCard(1, "Store A", "Note A", validFrom, expiry, balance, currency, "12345", "67890", CatimaBarcode.QR_CODE, 0xFF0000, 1, System.currentTimeMillis(), 10, 0); + LoyaltyCard card = new LoyaltyCard(1, "Store A", "Note A", validFrom, expiry, balance, currency, "12345", "67890", CatimaBarcode.fromBarcode(BarcodeFormat.QR_CODE), 0xFF0000, 1, System.currentTimeMillis(), 10, 0); Parcel parcel = Parcel.obtain(); card.writeToParcel(parcel, card.describeContents()); @@ -52,7 +42,7 @@ public void testParcelable() { assertEquals(card.balanceType, createdFromParcel.balanceType); assertEquals(card.cardId, createdFromParcel.cardId); assertEquals(card.barcodeId, createdFromParcel.barcodeId); - assertEquals(card.barcodeType, createdFromParcel.barcodeType); + assertEquals(card.barcodeType.name(), createdFromParcel.barcodeType.name()); assertEquals(card.headerColor, createdFromParcel.headerColor); assertEquals(card.starStatus, createdFromParcel.starStatus); assertEquals(card.lastUsed, createdFromParcel.lastUsed); @@ -67,7 +57,7 @@ public void testIsDuplicate_sameObject() { Date now = new Date(); BigDecimal balance = new BigDecimal("50.00"); Currency currency = Currency.getInstance("EUR"); - LoyaltyCard card1 = new LoyaltyCard(1, "Store B", "Note B", now, now, balance, currency, "22222", "33333", CatimaBarcode.PDF_417, 0x00FF00, 1, System.currentTimeMillis(), 5, 1); + LoyaltyCard card1 = new LoyaltyCard(1, "Store B", "Note B", now, now, balance, currency, "22222", "33333", CatimaBarcode.fromBarcode(BarcodeFormat.PDF_417), 0x00FF00, 1, System.currentTimeMillis(), 5, 1); assertTrue(LoyaltyCard.isDuplicate(card1, card1)); } @@ -78,8 +68,8 @@ public void testIsDuplicate_differentObjects() { BigDecimal balance1 = new BigDecimal("50.00"); BigDecimal balance2 = new BigDecimal("75.00"); Currency currency = Currency.getInstance("EUR"); - LoyaltyCard card1 = new LoyaltyCard(2, "Store C", "Note C", now, now, balance1, currency, "44444", "55555", CatimaBarcode.DATA_MATRIX, 0x0000FF, 0, System.currentTimeMillis(), 15, 1); - LoyaltyCard card2 = new LoyaltyCard(2, "Store C", "Note C", now, now, balance2, currency, "44444", "55555", CatimaBarcode.DATA_MATRIX, 0x0000FF, 0, System.currentTimeMillis(), 15, 1); + LoyaltyCard card1 = new LoyaltyCard(2, "Store C", "Note C", now, now, balance1, currency, "44444", "55555", CatimaBarcode.fromBarcode(BarcodeFormat.DATA_MATRIX), 0x0000FF, 0, System.currentTimeMillis(), 15, 1); + LoyaltyCard card2 = new LoyaltyCard(2, "Store C", "Note C", now, now, balance2, currency, "44444", "55555", CatimaBarcode.fromBarcode(BarcodeFormat.DATA_MATRIX), 0x0000FF, 0, System.currentTimeMillis(), 15, 1); assertFalse(LoyaltyCard.isDuplicate(card1, card2)); } @@ -89,7 +79,7 @@ public void testToString() { Date now = new Date(); BigDecimal balance = new BigDecimal("100.00"); Currency currency = Currency.getInstance("USD"); - LoyaltyCard card = new LoyaltyCard(3, "Store D", "Note D", now, now, balance, currency, "66666", "77777", CatimaBarcode.AZTEC, null, 2, System.currentTimeMillis(), 20, 2); + LoyaltyCard card = new LoyaltyCard(3, "Store D", "Note D", now, now, balance, currency, "66666", "77777", CatimaBarcode.fromBarcode(BarcodeFormat.AZTEC), null, 2, System.currentTimeMillis(), 20, 2); String expected = String.format( "LoyaltyCard{%n id=%s,%n store=%s,%n note=%s,%n validFrom=%s,%n expiry=%s,%n" From 889e98d2b24ad10b5a5a6de86ada780119ed8c89 Mon Sep 17 00:00:00 2001 From: Aglag257 Date: Tue, 11 Jun 2024 20:22:39 +0300 Subject: [PATCH 5/6] Final correct LoyaltyCardTest implementation --- .../java/protect/card_locker/LoyaltyCard.java | 18 +++--------------- .../protect/card_locker/LoyaltyCardTest.java | 7 ++++--- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCard.java b/app/src/main/java/protect/card_locker/LoyaltyCard.java index 4b004f6ae5..bfc2e63234 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCard.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCard.java @@ -68,8 +68,8 @@ protected LoyaltyCard(Parcel in) { balanceType = (Currency) in.readValue(Currency.class.getClassLoader()); cardId = in.readString(); barcodeId = in.readString(); - String barcodeTypeName = in.readString(); - barcodeType = barcodeTypeName != null && !barcodeTypeName.isEmpty() ? CatimaBarcode.fromName(barcodeTypeName) : null; + String tmpBarcodeType = in.readString(); + barcodeType = !tmpBarcodeType.isEmpty() ? CatimaBarcode.fromName(tmpBarcodeType) : null; int tmpHeaderColor = in.readInt(); headerColor = tmpHeaderColor != -1 ? tmpHeaderColor : null; starStatus = in.readInt(); @@ -97,18 +97,6 @@ public void writeToParcel(Parcel parcel, int i) { parcel.writeInt(archiveStatus); } - public static final Creator CREATOR = new Creator() { - @Override - public LoyaltyCard createFromParcel(Parcel in) { - return new LoyaltyCard(in); - } - - @Override - public LoyaltyCard[] newArray(int size) { - return new LoyaltyCard[size]; - } - }; -} public static LoyaltyCard toLoyaltyCard(Cursor cursor) { int id = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ID)); String store = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.STORE)); @@ -215,4 +203,4 @@ public LoyaltyCard[] newArray(int size) { return new LoyaltyCard[size]; } }; -} +} \ No newline at end of file diff --git a/app/src/test/java/protect/card_locker/LoyaltyCardTest.java b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java index 575aa01c98..27b30e1adb 100644 --- a/app/src/test/java/protect/card_locker/LoyaltyCardTest.java +++ b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java @@ -1,11 +1,11 @@ package protect.card_locker; import android.os.Parcel; -import android.os.Parcelable; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; import java.math.BigDecimal; import java.util.Currency; @@ -15,7 +15,8 @@ import static org.junit.Assert.*; -@RunWith(MockitoJUnitRunner.class) +@RunWith(RobolectricTestRunner.class) +@Config(manifest=Config.NONE) public class LoyaltyCardTest { @Test From 71c17e292ba5399b1ce93a11b8760df8a48fa7a5 Mon Sep 17 00:00:00 2001 From: Aglag257 Date: Mon, 17 Jun 2024 00:52:47 +0300 Subject: [PATCH 6/6] removing deprecated lines --- app/src/test/java/protect/card_locker/LoyaltyCardTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/test/java/protect/card_locker/LoyaltyCardTest.java b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java index 27b30e1adb..108d122395 100644 --- a/app/src/test/java/protect/card_locker/LoyaltyCardTest.java +++ b/app/src/test/java/protect/card_locker/LoyaltyCardTest.java @@ -5,7 +5,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; import java.math.BigDecimal; import java.util.Currency; @@ -16,7 +15,6 @@ import static org.junit.Assert.*; @RunWith(RobolectricTestRunner.class) -@Config(manifest=Config.NONE) public class LoyaltyCardTest { @Test