jpsp91 8 лет назад
Родитель
Сommit
0b337aba27
18 измененных файлов: 581 добавлений и 0 удалений
  1. Двоичные данные
      .DS_Store
  2. 14
    0
      pom.xml
  3. Двоичные данные
      src/.DS_Store
  4. Двоичные данные
      src/main/.DS_Store
  5. Двоичные данные
      src/main/java/.DS_Store
  6. Двоичные данные
      src/main/java/com/.DS_Store
  7. Двоичные данные
      src/main/java/com/zipcoder/.DS_Store
  8. 68
    0
      src/main/java/com/zipcoder/payment/Check.java
  9. 122
    0
      src/main/java/com/zipcoder/payment/CreditCard.java
  10. 47
    0
      src/main/java/com/zipcoder/payment/PayPal.java
  11. 11
    0
      src/main/java/com/zipcoder/payment/Payment.java
  12. Двоичные данные
      src/test/.DS_Store
  13. Двоичные данные
      src/test/java/.DS_Store
  14. Двоичные данные
      src/test/java/com/.DS_Store
  15. Двоичные данные
      src/test/java/com/zipcoder/.DS_Store
  16. 119
    0
      src/test/java/com/zipcoder/payment/CheckTest.java
  17. 115
    0
      src/test/java/com/zipcoder/payment/CreditCardTest.java
  18. 85
    0
      src/test/java/com/zipcoder/payment/PayPalTest.java

Двоичные данные
.DS_Store Просмотреть файл


+ 14
- 0
pom.xml Просмотреть файл

@@ -7,6 +7,20 @@
7 7
     <groupId>com.zipcoder</groupId>
8 8
     <artifactId>payment</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <dependencies>
11
+        <dependency>
12
+            <groupId>org.junit.jupiter</groupId>
13
+            <artifactId>junit-jupiter-api</artifactId>
14
+            <version>RELEASE</version>
15
+            <scope>test</scope>
16
+        </dependency>
17
+        <dependency>
18
+            <groupId>junit</groupId>
19
+            <artifactId>junit</artifactId>
20
+            <version>RELEASE</version>
21
+            <scope>test</scope>
22
+        </dependency>
23
+    </dependencies>
10 24
 
11 25
 
12 26
 </project>

Двоичные данные
src/.DS_Store Просмотреть файл


Двоичные данные
src/main/.DS_Store Просмотреть файл


Двоичные данные
src/main/java/.DS_Store Просмотреть файл


Двоичные данные
src/main/java/com/.DS_Store Просмотреть файл


Двоичные данные
src/main/java/com/zipcoder/.DS_Store Просмотреть файл


+ 68
- 0
src/main/java/com/zipcoder/payment/Check.java Просмотреть файл

@@ -0,0 +1,68 @@
1
+package com.zipcoder.payment;
2
+
3
+public class Check implements Payment {
4
+
5
+
6
+    Long id;
7
+
8
+    String payerName;
9
+
10
+    String shortDescription;
11
+
12
+    public String getRoutingNumber() {
13
+        return routingNumber;
14
+    }
15
+
16
+    public void setRoutingNumber(String routingNumber) {
17
+        this.routingNumber = routingNumber;
18
+    }
19
+
20
+    public String getAccountNumber() {
21
+        return accountNumber;
22
+    }
23
+
24
+    public void setAccountNumber(String accountNumber) {
25
+        this.accountNumber = accountNumber;
26
+    }
27
+
28
+    String routingNumber;
29
+
30
+    String accountNumber;
31
+
32
+
33
+
34
+    public Long getId() {
35
+        return id;
36
+    }
37
+
38
+    public void setId(Long id) {
39
+        this.id = id;
40
+    }
41
+
42
+
43
+
44
+
45
+
46
+    public String getPayerName() {
47
+        return payerName;
48
+    }
49
+
50
+    public void setPayerName(String payerName) {
51
+        this.payerName = payerName;
52
+    }
53
+
54
+
55
+
56
+    public String getShortDescription() {
57
+
58
+        String accountNumb = getAccountNumber();
59
+        String lastFourAcct = accountNumb.substring(accountNumb.length()-4, accountNumb.length());
60
+
61
+        return "Check " + getPayerName() + " ***" + lastFourAcct;
62
+    }
63
+
64
+
65
+    public int compareTo(Payment o) {
66
+        return 0;
67
+    }
68
+}

+ 122
- 0
src/main/java/com/zipcoder/payment/CreditCard.java Просмотреть файл

@@ -0,0 +1,122 @@
1
+package com.zipcoder.payment;
2
+
3
+public class CreditCard implements Payment {
4
+
5
+
6
+    Long id;
7
+
8
+    String payerName;
9
+
10
+    String shortDescription;
11
+
12
+
13
+
14
+    String number;
15
+
16
+    int expiredMonth;
17
+
18
+    int expiredYear;
19
+
20
+
21
+
22
+    public CreditCard(){
23
+
24
+    }
25
+
26
+    public CreditCard(long id, String payerName, String number, int month, int year){
27
+        this.id = id;
28
+        this.payerName = payerName;
29
+        this.number = number;
30
+        this.expiredMonth = expiredMonth;
31
+        this.expiredYear = expiredYear;
32
+    }
33
+
34
+
35
+
36
+
37
+    public Long getId(){
38
+        return id;
39
+    }
40
+
41
+    public void setId(Long id) {
42
+        this.id = id;
43
+    }
44
+
45
+
46
+
47
+
48
+
49
+    public String getPayerName(){
50
+        return payerName;
51
+    }
52
+
53
+    public void setPayerName(String payerName) {
54
+        this.payerName = payerName;
55
+    }
56
+
57
+
58
+
59
+
60
+    public String getNumber (){
61
+        return number;
62
+    }
63
+
64
+    public void setNumber(String number) {
65
+        this.number = number;
66
+    }
67
+
68
+
69
+
70
+
71
+
72
+
73
+    public int getExpiredMonth (){
74
+        return expiredMonth;
75
+    }
76
+
77
+    public void setExpiredMonth(int expiredMonth) {
78
+        this.expiredMonth = expiredMonth;
79
+    }
80
+
81
+
82
+
83
+
84
+
85
+
86
+    public int getExpiredYear (){
87
+        return expiredYear;
88
+    }
89
+
90
+    public void setExpiredYear(int expiredYear) {
91
+        this.expiredYear = expiredYear;
92
+    }
93
+
94
+
95
+
96
+
97
+
98
+    public String getShortDescription(){
99
+
100
+        String numb = getNumber();
101
+        String lastFour = getNumber().substring(numb.length()-4, numb.length());
102
+
103
+        return "CC " + getPayerName() + " " + lastFour + " " + getExpiredMonth() + "/" + getExpiredYear();
104
+    }
105
+
106
+
107
+
108
+
109
+    public int compareTo(Payment o) {
110
+        if(this.getShortDescription().compareTo(o.getShortDescription()) > 0){
111
+            return 1;
112
+        } else if(this.getShortDescription().compareTo(o.getShortDescription()) < 0) {
113
+            return -1;
114
+        } else {
115
+            return 0;
116
+        }
117
+    }
118
+
119
+
120
+
121
+
122
+}

+ 47
- 0
src/main/java/com/zipcoder/payment/PayPal.java Просмотреть файл

@@ -0,0 +1,47 @@
1
+package com.zipcoder.payment;
2
+
3
+public class PayPal implements Payment{
4
+
5
+    Long id;
6
+
7
+    String payerName;
8
+
9
+    String email;
10
+
11
+    String shortDescription;
12
+
13
+    public Long getId() {
14
+        return id;
15
+    }
16
+
17
+    public void setId(Long id) {
18
+        this.id = id;
19
+    }
20
+
21
+    public String getPayerName() {
22
+        return payerName;
23
+    }
24
+
25
+    public void setPayerName(String payerName) {
26
+        this.payerName = payerName;
27
+    }
28
+
29
+    public String getEmail() {
30
+        return email;
31
+    }
32
+
33
+    public void setEmail(String email) {
34
+        this.email = email;
35
+    }
36
+
37
+
38
+
39
+    public String getShortDescription(){
40
+        return "PayPal " + getPayerName() + " " + getEmail();
41
+    }
42
+
43
+
44
+    public int compareTo(Payment o) {
45
+        return 0;
46
+    }
47
+}

+ 11
- 0
src/main/java/com/zipcoder/payment/Payment.java Просмотреть файл

@@ -0,0 +1,11 @@
1
+package com.zipcoder.payment;
2
+
3
+public interface Payment extends Comparable<Payment>{
4
+
5
+    public Long getId();
6
+
7
+    public String getPayerName();
8
+
9
+    public String getShortDescription();
10
+
11
+}

Двоичные данные
src/test/.DS_Store Просмотреть файл


Двоичные данные
src/test/java/.DS_Store Просмотреть файл


Двоичные данные
src/test/java/com/.DS_Store Просмотреть файл


Двоичные данные
src/test/java/com/zipcoder/.DS_Store Просмотреть файл


+ 119
- 0
src/test/java/com/zipcoder/payment/CheckTest.java Просмотреть файл

@@ -0,0 +1,119 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Assert;
4
+import org.junit.jupiter.api.Test;
5
+
6
+public class CheckTest {
7
+
8
+    Check check = new Check();
9
+
10
+
11
+    @Test
12
+    public void getIdTest(){
13
+
14
+        //when
15
+        check.setId(555L);
16
+
17
+        //expected
18
+        Long expected = 555L;
19
+
20
+        //actual
21
+        Long actual = check.getId();
22
+
23
+        Assert.assertEquals(expected, actual);
24
+    }
25
+
26
+
27
+    @Test
28
+    public void getPayerNameTest(){
29
+        //when
30
+        check.setPayerName("Troy");
31
+
32
+        //expected
33
+        String expected = "Troy";
34
+
35
+        //actual
36
+        String actual = check.getPayerName();
37
+
38
+        Assert.assertEquals(expected, actual);
39
+    }
40
+
41
+
42
+    @Test
43
+    public void getRoutingNumberTest() {
44
+        //when
45
+        check.setRoutingNumber("90001");
46
+
47
+        //expected
48
+        String expected = "90001";
49
+
50
+        //actual
51
+        String actual = check.getRoutingNumber();
52
+
53
+        Assert.assertEquals(expected, actual);
54
+    }
55
+
56
+
57
+
58
+    @Test
59
+    public void getAccountNumberTest(){
60
+        //when
61
+        check.setAccountNumber("56789");
62
+
63
+        //expected
64
+        String expected = "56789";
65
+
66
+        //actual
67
+        String actual = check.getAccountNumber();
68
+
69
+        Assert.assertEquals(expected, actual);
70
+    }
71
+
72
+
73
+    //*********************************************************
74
+    @Test
75
+    public void getShortDescriptionTest(){
76
+        //when
77
+        check.setPayerName("Bob");
78
+        check.setAccountNumber("0001234");
79
+
80
+        //expected
81
+        String expected = "Check Bob ***1234";
82
+
83
+        //actual
84
+        String actual = check.getShortDescription();
85
+
86
+        Assert.assertEquals(expected, actual);
87
+    //*********************************************************
88
+    }
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+}

+ 115
- 0
src/test/java/com/zipcoder/payment/CreditCardTest.java Просмотреть файл

@@ -0,0 +1,115 @@
1
+
2
+
3
+package com.zipcoder.payment;
4
+
5
+
6
+import org.junit.Assert;
7
+import org.junit.jupiter.api.Test;
8
+
9
+
10
+import static org.junit.jupiter.api.Assertions.assertEquals;
11
+
12
+public class CreditCardTest {
13
+
14
+
15
+    CreditCard cc = new CreditCard();
16
+
17
+
18
+
19
+    @Test
20
+    public void getIdTest(){
21
+        //When
22
+        cc.setId(13L);
23
+
24
+        //Expected
25
+        long expected = 13L;
26
+
27
+        //Actual
28
+        long actual = cc.getId();
29
+
30
+        Assert.assertEquals(expected,actual);
31
+
32
+    }
33
+
34
+
35
+    @Test
36
+    public void getPayerNameTest(){
37
+        //when
38
+        cc.setPayerName("Abed");
39
+
40
+        //Expected
41
+        String expected = "Abed";
42
+
43
+        //Actual
44
+        String actual = cc.getPayerName();
45
+
46
+        assertEquals(expected,actual);
47
+    }
48
+
49
+    @Test
50
+    public void getNumberTest(){
51
+        //when
52
+        cc.setNumber("112233");
53
+
54
+        //Expected
55
+        String expected = "112233";
56
+
57
+        //Actual
58
+        String actual = cc.getNumber();
59
+
60
+        assertEquals(expected,actual);
61
+    }
62
+
63
+
64
+    @Test
65
+    public void getExpiredMonthTest(){
66
+        //when
67
+        cc.setExpiredMonth(12);
68
+
69
+        //Expected
70
+        int expected = 12;
71
+
72
+        //Actual
73
+        int actual = cc.getExpiredMonth();
74
+
75
+        assertEquals(expected, actual);
76
+    }
77
+
78
+
79
+    @Test
80
+    public void getExpiredYearTest(){
81
+        //when
82
+        cc.setExpiredYear(2019);
83
+
84
+        //Expected
85
+        int expected = 2019;
86
+
87
+        //Actual
88
+        int actual = cc.getExpiredYear();
89
+
90
+        assertEquals(expected, actual);
91
+    }
92
+
93
+
94
+
95
+    @Test
96
+    public void getShortDescriptionTest(){
97
+        //when
98
+        cc.setPayerName("Bobby");
99
+        cc.setNumber("1110000");
100
+        cc.setExpiredMonth(12);
101
+        cc.setExpiredYear(2020);
102
+
103
+        //expected
104
+        String expected = "CC Bobby 0000 12/2020";
105
+
106
+        //actual
107
+        String actual = cc.getShortDescription();
108
+
109
+        Assert.assertEquals(expected, actual);
110
+    }
111
+
112
+
113
+
114
+
115
+}

+ 85
- 0
src/test/java/com/zipcoder/payment/PayPalTest.java Просмотреть файл

@@ -0,0 +1,85 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Assert;
4
+import org.junit.jupiter.api.Test;
5
+
6
+public class PayPalTest {
7
+
8
+    PayPal pp = new PayPal();
9
+
10
+    @Test
11
+    public void getIdTest() {
12
+
13
+    //when
14
+    pp.setId(5000L);
15
+
16
+    //expected
17
+    Long expected = 5000L;
18
+
19
+    //actual
20
+    Long actual = pp.getId();
21
+
22
+    Assert.assertEquals(expected, actual);
23
+    }
24
+
25
+
26
+
27
+    @Test
28
+    public void getPayerName(){
29
+        //when
30
+        pp.setPayerName("Tia Mowry");
31
+
32
+        //expected
33
+        String expected = "Tia Mowry";
34
+
35
+        //actual
36
+        String actual = pp.getPayerName();
37
+
38
+        Assert.assertEquals(expected, actual);
39
+    }
40
+
41
+
42
+    @Test
43
+    public void getEmailTest(){
44
+        //when
45
+        pp.setEmail("tia@mowry.com");
46
+
47
+        //expected
48
+        String expected = "tia@mowry.com";
49
+
50
+        //actual
51
+        String actual = pp.getEmail();
52
+
53
+        Assert.assertEquals(expected, actual);
54
+    }
55
+
56
+
57
+    @Test
58
+    public void getShortDescriptionTest(){
59
+        //when
60
+        pp.setPayerName("Tia Mowry");
61
+        pp.setEmail("tia@mowry.com");
62
+
63
+        //expected
64
+        String expected = "PayPal Tia Mowry tia@mowry.com";
65
+
66
+        //actual
67
+        String actual = pp.getShortDescription();
68
+    }
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+}