|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+package com.zipcoder.payment;
|
|
|
2
|
+
|
|
|
3
|
+
|
|
|
4
|
+import org.junit.Assert;
|
|
|
5
|
+import org.junit.Before;
|
|
|
6
|
+import org.junit.Test;
|
|
|
7
|
+
|
|
|
8
|
+public class CreditCardTest {
|
|
|
9
|
+ CreditCard testCard;
|
|
|
10
|
+
|
|
|
11
|
+
|
|
|
12
|
+ @Before
|
|
|
13
|
+ public void initialize() {
|
|
|
14
|
+ testCard = new CreditCard(10, "John Hurt", "0043783590454335", 03,2020);
|
|
|
15
|
+
|
|
|
16
|
+ }
|
|
|
17
|
+
|
|
|
18
|
+ @Test
|
|
|
19
|
+ public void getSetIdTest() {
|
|
|
20
|
+ long expected = 100;
|
|
|
21
|
+ testCard.setId(100);
|
|
|
22
|
+ long actual = testCard.getId();
|
|
|
23
|
+
|
|
|
24
|
+ Assert.assertEquals(expected, actual);
|
|
|
25
|
+
|
|
|
26
|
+ }
|
|
|
27
|
+
|
|
|
28
|
+ @Test
|
|
|
29
|
+ public void getSetPayerNameTest() {
|
|
|
30
|
+ String expected = "Bob";
|
|
|
31
|
+ testCard.setPayerName("Bob");
|
|
|
32
|
+
|
|
|
33
|
+ String actual = testCard.getPayerName();
|
|
|
34
|
+
|
|
|
35
|
+ Assert.assertEquals(expected, actual);
|
|
|
36
|
+
|
|
|
37
|
+ }
|
|
|
38
|
+
|
|
|
39
|
+ @Test
|
|
|
40
|
+ public void getSetNumberTest() {
|
|
|
41
|
+ String expected = "4536";
|
|
|
42
|
+ testCard.setNumber("4536");
|
|
|
43
|
+
|
|
|
44
|
+ String actual = testCard.getNumber();
|
|
|
45
|
+
|
|
|
46
|
+ Assert.assertEquals(expected, actual);
|
|
|
47
|
+ }
|
|
|
48
|
+
|
|
|
49
|
+ @Test
|
|
|
50
|
+ public void getSetExpiredMonthTest() {
|
|
|
51
|
+ int expected = 10;
|
|
|
52
|
+ testCard.setExpiredMonth(10);
|
|
|
53
|
+
|
|
|
54
|
+ int actual = testCard.getExpiredMonth();
|
|
|
55
|
+
|
|
|
56
|
+ Assert.assertEquals(expected, actual);
|
|
|
57
|
+
|
|
|
58
|
+ }
|
|
|
59
|
+
|
|
|
60
|
+ @Test
|
|
|
61
|
+ public void getSetExpiredYearTest() {
|
|
|
62
|
+ int expected = 2021;
|
|
|
63
|
+ testCard.setExpiredYear(2021);
|
|
|
64
|
+
|
|
|
65
|
+ int actual = testCard.getExpiredYear();
|
|
|
66
|
+
|
|
|
67
|
+ Assert.assertEquals(expected, actual);
|
|
|
68
|
+ }
|
|
|
69
|
+
|
|
|
70
|
+ @Test
|
|
|
71
|
+ public void getLastFourDigitsTest() {
|
|
|
72
|
+ String expected = "4556";
|
|
|
73
|
+ String fullNumber = "230598904556";
|
|
|
74
|
+
|
|
|
75
|
+ String actual = testCard.getLastFourDigits(fullNumber);
|
|
|
76
|
+
|
|
|
77
|
+ Assert.assertEquals(expected, actual);
|
|
|
78
|
+
|
|
|
79
|
+ }
|
|
|
80
|
+
|
|
|
81
|
+ @Test
|
|
|
82
|
+ public void getShortDescriptionTest() {
|
|
|
83
|
+ String expected = "CC John Hurt 4335 3/2020";
|
|
|
84
|
+ String actual = testCard.getShortDescription();
|
|
|
85
|
+
|
|
|
86
|
+ Assert.assertEquals(expected, actual);
|
|
|
87
|
+ }
|
|
|
88
|
+}
|