Skip to content

Commit

Permalink
Final correct LoyaltyCardTest implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Aglag257 committed Jun 11, 2024
1 parent f1f38d1 commit 889e98d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
18 changes: 3 additions & 15 deletions app/src/main/java/protect/card_locker/LoyaltyCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -97,18 +97,6 @@ public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(archiveStatus);
}

public static final Creator<LoyaltyCard> CREATOR = new Creator<LoyaltyCard>() {
@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));
Expand Down Expand Up @@ -215,4 +203,4 @@ public LoyaltyCard[] newArray(int size) {
return new LoyaltyCard[size];
}
};
}
}
7 changes: 4 additions & 3 deletions app/src/test/java/protect/card_locker/LoyaltyCardTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,7 +15,8 @@

import static org.junit.Assert.*;

@RunWith(MockitoJUnitRunner.class)
@RunWith(RobolectricTestRunner.class)
@Config(manifest=Config.NONE)
public class LoyaltyCardTest {

@Test
Expand Down

0 comments on commit 889e98d

Please sign in to comment.