Skip to content

Commit 889e98d

Browse files
committed
Final correct LoyaltyCardTest implementation
1 parent f1f38d1 commit 889e98d

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

app/src/main/java/protect/card_locker/LoyaltyCard.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ protected LoyaltyCard(Parcel in) {
6868
balanceType = (Currency) in.readValue(Currency.class.getClassLoader());
6969
cardId = in.readString();
7070
barcodeId = in.readString();
71-
String barcodeTypeName = in.readString();
72-
barcodeType = barcodeTypeName != null && !barcodeTypeName.isEmpty() ? CatimaBarcode.fromName(barcodeTypeName) : null;
71+
String tmpBarcodeType = in.readString();
72+
barcodeType = !tmpBarcodeType.isEmpty() ? CatimaBarcode.fromName(tmpBarcodeType) : null;
7373
int tmpHeaderColor = in.readInt();
7474
headerColor = tmpHeaderColor != -1 ? tmpHeaderColor : null;
7575
starStatus = in.readInt();
@@ -97,18 +97,6 @@ public void writeToParcel(Parcel parcel, int i) {
9797
parcel.writeInt(archiveStatus);
9898
}
9999

100-
public static final Creator<LoyaltyCard> CREATOR = new Creator<LoyaltyCard>() {
101-
@Override
102-
public LoyaltyCard createFromParcel(Parcel in) {
103-
return new LoyaltyCard(in);
104-
}
105-
106-
@Override
107-
public LoyaltyCard[] newArray(int size) {
108-
return new LoyaltyCard[size];
109-
}
110-
};
111-
}
112100
public static LoyaltyCard toLoyaltyCard(Cursor cursor) {
113101
int id = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ID));
114102
String store = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.STORE));
@@ -215,4 +203,4 @@ public LoyaltyCard[] newArray(int size) {
215203
return new LoyaltyCard[size];
216204
}
217205
};
218-
}
206+
}

app/src/test/java/protect/card_locker/LoyaltyCardTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package protect.card_locker;
22

33
import android.os.Parcel;
4-
import android.os.Parcelable;
54

65
import org.junit.Test;
76
import org.junit.runner.RunWith;
8-
import org.mockito.junit.MockitoJUnitRunner;
7+
import org.robolectric.RobolectricTestRunner;
8+
import org.robolectric.annotation.Config;
99

1010
import java.math.BigDecimal;
1111
import java.util.Currency;
@@ -15,7 +15,8 @@
1515

1616
import static org.junit.Assert.*;
1717

18-
@RunWith(MockitoJUnitRunner.class)
18+
@RunWith(RobolectricTestRunner.class)
19+
@Config(manifest=Config.NONE)
1920
public class LoyaltyCardTest {
2021

2122
@Test

0 commit comments

Comments
 (0)