Ver código fonte

added the Paypal/Paypal test classes

Nicholas Maidanos 8 anos atrás
pai
commit
3341afbc50

+ 40
- 0
src/main/java/com/zipcoder/payment/Paypal.java Ver arquivo

@@ -5,7 +5,47 @@ public class Paypal implements Payment {
5 5
     private long id;
6 6
     private String payerName;
7 7
     private String email;
8
+
8 9
     public Paypal(){};
9 10
 
11
+    public Paypal(long id, String payerName, String email){
12
+        this.id = id;
13
+        this.payerName = payerName;
14
+        this.email = email;
15
+    }
16
+
17
+    public void setId(long id){
18
+        this.id = id;
19
+    }
20
+
21
+    public long getId() {
22
+        return this.id;
23
+    }
24
+
25
+    public void setPayerName(String payerName){
26
+        this.payerName = payerName;
27
+    }
28
+
29
+    public String getPayerName() {
30
+        return this.payerName;
31
+    }
32
+
33
+    public void setEmail(String email){
34
+        this.email = email;
35
+    }
36
+
37
+    public String getEmail(){
38
+        return this.email;
39
+    }
40
+
41
+
42
+    public String getShortDescription() {
43
+        StringBuilder sb = new StringBuilder();
44
+        sb.append("PayPal ");
45
+        sb.append(this.payerName + " ");
46
+        sb.append(this.email);
47
+        return sb.toString();
48
+    }
49
+
10 50
 
11 51
 }

+ 107
- 0
src/test/java/com/zipcoder/payment/PaypalTest.java Ver arquivo

@@ -0,0 +1,107 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+
6
+import static org.junit.Assert.assertEquals;
7
+
8
+class PaypalTest {
9
+
10
+    @Test
11
+    void setId() {
12
+        //When
13
+        Paypal pp = new Paypal();
14
+        pp.setId(75);
15
+
16
+        //Expect
17
+        long expect = 75;
18
+
19
+        //Actual
20
+        long actual = pp.getId();
21
+        assertEquals(expect, actual);
22
+    }
23
+
24
+    @Test
25
+    void getId() {
26
+        //When
27
+        Paypal pp = new Paypal();
28
+        pp.setId(75);
29
+
30
+        //Expect
31
+        long expect = 75;
32
+
33
+        //Actual
34
+        long actual = pp.getId();
35
+        assertEquals(expect, actual);
36
+    }
37
+
38
+    @Test
39
+    void setPayerName() {
40
+        //When
41
+        Paypal pp =  new Paypal();
42
+        pp.setPayerName("Nicholas Maidanos");
43
+
44
+        //Expect
45
+        String expect = "Nicholas Maidanos";
46
+
47
+        //Actual
48
+        String actual = pp.getPayerName();
49
+        assertEquals(expect, actual);
50
+    }
51
+
52
+    @Test
53
+    void getPayerName() {
54
+        //When
55
+        Paypal pp =  new Paypal();
56
+        pp.setPayerName("Nicholas Maidanos");
57
+
58
+        //Expect
59
+        String expect = "Nicholas Maidanos";
60
+
61
+        //Actual
62
+        String actual = pp.getPayerName();
63
+        assertEquals(expect, actual);
64
+    }
65
+
66
+    @Test
67
+    void setEmail() {
68
+        //When
69
+        Paypal pp = new Paypal();
70
+        pp.setEmail("example@email.com");
71
+
72
+        //Expect
73
+        String expect = "example@email.com";
74
+
75
+        //Actual
76
+        String actual = pp.getEmail();
77
+        assertEquals(expect, actual);
78
+    }
79
+
80
+    @Test
81
+    void getEmail() {
82
+        //When
83
+        Paypal pp = new Paypal();
84
+        pp.setEmail("example@email.com");
85
+
86
+        //Expect
87
+        String expect = "example@email.com";
88
+
89
+        //Actual
90
+        String actual = pp.getEmail();
91
+        assertEquals(expect, actual);
92
+    }
93
+
94
+    @Test
95
+    void getShortDescription() {
96
+        //When
97
+        Paypal pp = new Paypal(78, "Nicholas Madianos", "nmaidanos@gmail.com");
98
+
99
+        //Expect
100
+        String expect = "PayPal Nicholas Madianos nmaidanos@gmail.com";
101
+
102
+        //Actual
103
+        String actual = pp.getShortDescription();
104
+
105
+        assertEquals(expect,actual);
106
+    }
107
+}