ソースを参照

interim update

donnaj 6 年 前
コミット
580bc96e46

+ 8
- 0
pom.xml ファイルの表示

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

+ 54
- 0
src/main/java/com/zipcoder/payment/Check.java ファイルの表示

@@ -0,0 +1,54 @@
1
+package com.zipcoder.payment;
2
+
3
+public class Check implements Payment {
4
+    Long id;
5
+    String payerName;
6
+    String routingNumber;
7
+    String number;
8
+
9
+    public Check(Long id, String payerName, String routingNumber, String number) {
10
+        this.id = id;
11
+        this.payerName = payerName;
12
+        this.routingNumber = routingNumber;
13
+        this.number = number;
14
+
15
+    }
16
+    public Long getId() {
17
+        return id;
18
+    }
19
+
20
+    public void setId(Long id) {
21
+        this.id = id;
22
+    }
23
+
24
+    public String getPayerName() {
25
+        return payerName;
26
+    }
27
+
28
+    public String getShortDescription() {
29
+        return "Check" + " " + payerName + " " + "***" + number.substring(number.length()-4, number.length());
30
+    }
31
+
32
+    public void setPayerName(String payerName) {
33
+        this.payerName = payerName;
34
+    }
35
+
36
+    public String getRoutingNumber() {
37
+        return routingNumber;
38
+    }
39
+
40
+    public void setRoutingNumber(String routingNumber) {
41
+        this.routingNumber = routingNumber;
42
+    }
43
+
44
+    public String getNumber() {
45
+        return number;
46
+    }
47
+
48
+    public void setNumber(String number) {
49
+        this.number = number;
50
+    }
51
+
52
+
53
+
54
+}

+ 65
- 0
src/main/java/com/zipcoder/payment/CreditCard.java ファイルの表示

@@ -0,0 +1,65 @@
1
+package com.zipcoder.payment;
2
+
3
+public class CreditCard implements Payment {
4
+    Long id;
5
+    String payerName;
6
+    String number;
7
+    int expiredMonth;
8
+    int expiredYear;
9
+
10
+    public CreditCard(Long id, String payerName, String number, int expiredMonth, int expiredYear) {
11
+        this.id = id;
12
+        this.payerName = payerName;
13
+        this.number = number;
14
+        this.expiredMonth = expiredMonth;
15
+        this.expiredYear = expiredYear;
16
+    }
17
+
18
+    public void setId(Long id) {
19
+        this.id = id;
20
+    }
21
+
22
+    public void setPayerName(String payerName) {
23
+        this.payerName = payerName;
24
+    }
25
+
26
+    public String getNumber() {
27
+        return number;
28
+    }
29
+
30
+    public void setNumber(String number) {
31
+        this.number = number;
32
+    }
33
+
34
+    public int getExpiredMonth() {
35
+        return expiredMonth;
36
+    }
37
+
38
+    public void setExpiredMonth(int expireMonth) {
39
+        this.expiredMonth = expireMonth;
40
+    }
41
+
42
+    public int getExpiredYear() {
43
+        return expiredYear;
44
+    }
45
+
46
+    public void setExpiredYear(int expireYear) {
47
+        this.expiredYear = expireYear;
48
+    }
49
+
50
+    public CreditCard(Long id) {
51
+        this.id = id;
52
+    }
53
+
54
+    public Long getId() {
55
+        return id;
56
+    }
57
+
58
+    public String getPayerName() {
59
+        return payerName;
60
+    }
61
+
62
+    public String getShortDescription() {
63
+        return "CC" + " " + payerName + " " + number.substring(number.length()-4, number.length()) + " " + expiredMonth + "/" + expiredYear;
64
+    }
65
+}

+ 41
- 0
src/main/java/com/zipcoder/payment/PayPal.java ファイルの表示

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

+ 7
- 0
src/main/java/com/zipcoder/payment/Payment.java ファイルの表示

@@ -0,0 +1,7 @@
1
+package com.zipcoder.payment;
2
+
3
+public interface Payment {
4
+    public Long getId();
5
+    public String getPayerName();
6
+    public String getShortDescription();
7
+}

+ 45
- 0
src/test/java/com/zipcoder/payment/CheckTest.java ファイルの表示

@@ -0,0 +1,45 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class CheckTest {
7
+    Check test = new Check(2L, "donna", "987654321", "1234567890");
8
+
9
+
10
+    @Test
11
+    public void getIdTest() {
12
+        Long expected = 2L;
13
+        Long actual = test.getId();
14
+        Assert.assertEquals(expected, actual);
15
+
16
+    }
17
+    @Test
18
+    public void getPayerNameTest() {
19
+        String expected = "donna";
20
+        String actual = test.getPayerName();
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+    @Test
24
+    public void getRoutingNumberTest() {
25
+        String expected = "987654321";
26
+        String actual = test.getRoutingNumber();
27
+        Assert.assertEquals(expected, actual);
28
+
29
+    }
30
+    @Test
31
+    public void getNumberTest() {
32
+        String expected = "1234567890";
33
+        String actual = test.getNumber();
34
+        Assert.assertEquals(expected, actual);
35
+
36
+    }
37
+
38
+    @Test
39
+    public void getShortDescriptionTest() {
40
+        String expected = "Check donna ***7890";
41
+        String actual = test.getShortDescription();
42
+        Assert.assertEquals(expected, actual);
43
+
44
+    }
45
+}

+ 53
- 0
src/test/java/com/zipcoder/payment/CreditCardTest.java ファイルの表示

@@ -0,0 +1,53 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class CreditCardTest {
7
+    CreditCard test = new CreditCard(1L, "donna", "1234567890", 10, 2020);
8
+
9
+
10
+    @Test
11
+    public void getIdTest() {
12
+        Long expected = 1L;
13
+        Long actual = test.getId();
14
+        Assert.assertEquals(expected, actual);
15
+
16
+    }
17
+    @Test
18
+    public void getPayerNameTest() {
19
+        String expected = "donna";
20
+        String actual = test.getPayerName();
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+    @Test
24
+    public void getNumberTest() {
25
+        String expected = "1234567890";
26
+        String actual = test.getNumber();
27
+        Assert.assertEquals(expected, actual);
28
+
29
+    }
30
+    @Test
31
+    public void getExpiredMonthTest() {
32
+        int expected = 10;
33
+        int actual = test.getExpiredMonth();
34
+        Assert.assertEquals(expected, actual);
35
+    }
36
+    @Test
37
+    public void getExpiredYearTest() {
38
+        int expected = 2020;
39
+        int actual = test.getExpiredYear();
40
+        Assert.assertEquals(expected, actual);
41
+    }
42
+
43
+    @Test
44
+    public void getShortDescriptionTest() {
45
+        String expected = "CC donna 7890 10/2020";
46
+        String actual = test.getShortDescription();
47
+        Assert.assertEquals(expected, actual);
48
+
49
+    }
50
+
51
+}
52
+
53
+

+ 39
- 0
src/test/java/com/zipcoder/payment/PayPalTest.java ファイルの表示

@@ -0,0 +1,39 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class PayPalTest {
7
+    PayPal test = new PayPal(3L, "donna", "donna@jacobs.com");
8
+
9
+
10
+    @Test
11
+    public void getIdTest() {
12
+        Long expected = 3L;
13
+        Long actual = test.getId();
14
+        Assert.assertEquals(expected, actual);
15
+
16
+    }
17
+    @Test
18
+    public void getPayerNameTest() {
19
+        String expected = "donna";
20
+        String actual = test.getPayerName();
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+
24
+    @Test
25
+    public void getEmailTest() {
26
+        String expected = "donna@jacobs.com";
27
+        String actual = test.getEmail();
28
+        Assert.assertEquals(expected, actual);
29
+
30
+    }
31
+
32
+    @Test
33
+    public void getShortDescriptionTest() {
34
+        String expected = "PayPal donna donna@jacobs.com";
35
+        String actual = test.getShortDescription();
36
+        Assert.assertEquals(expected, actual);
37
+
38
+    }
39
+}