#20 methods written tests passed

Atvērta
jacob-andersen vēlas sapludināt 1 revīzijas no jacob-andersen/InterfaceComparableLab:master uz master

+ 15
- 0
pom.xml Parādīt failu

@@ -11,5 +11,20 @@
11 11
         <maven.compiler.source>1.8</maven.compiler.source>
12 12
         <maven.compiler.target>1.8</maven.compiler.target>
13 13
     </properties>
14
+    <dependencies>
15
+        <dependency>
16
+            <groupId>junit</groupId>
17
+            <artifactId>junit</artifactId>
18
+            <version>4.12</version>
19
+            <scope>test</scope>
20
+        </dependency>
21
+        <dependency>
22
+            <groupId>junit</groupId>
23
+            <artifactId>junit</artifactId>
24
+            <version>RELEASE</version>
25
+            <scope>compile</scope>
26
+        </dependency>
27
+
28
+    </dependencies>
14 29
 
15 30
 </project>

+ 58
- 0
src/main/java/com/zipcoder/payment/Check.java Parādīt failu

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

+ 11
- 0
src/main/java/com/zipcoder/payment/CheckTest.java Parādīt failu

@@ -0,0 +1,11 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Test;
4
+
5
+public class CheckTest
6
+{
7
+@Test
8
+    public void abc(){
9
+
10
+}
11
+}

+ 68
- 0
src/main/java/com/zipcoder/payment/CreditCard.java Parādīt failu

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

+ 26
- 0
src/main/java/com/zipcoder/payment/CreditCardTest.java Parādīt failu

@@ -0,0 +1,26 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class CreditCardTest {
7
+@Test
8
+    public void getShortDescriptionTest()
9
+    {
10
+        //GIVEN
11
+        CreditCard person = new CreditCard();
12
+        person.setPayerName("Jacob Andersen");
13
+        person.setNumber("134344551");
14
+        person.setExpiredMonth(10);
15
+        person.setExpiredYear(2019);
16
+        //WHEN
17
+        person.getShortDescription();
18
+
19
+        //THEN
20
+        String expected = "CC Jacob Andersen 4551 10/2019";
21
+        String actual = person.getShortDescription();
22
+
23
+        Assert.assertEquals(expected,actual);
24
+
25
+        }
26
+}

+ 49
- 0
src/main/java/com/zipcoder/payment/PayPal.java Parādīt failu

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

+ 27
- 0
src/main/java/com/zipcoder/payment/PayPalTest.java Parādīt failu

@@ -0,0 +1,27 @@
1
+package com.zipcoder.payment;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class PayPalTest {
7
+    @Test
8
+    public void compareToTest()
9
+    {
10
+     //GIVEN
11
+        PayPal person = new PayPal();
12
+        Check other = new Check();
13
+        person.setPayerName("Jacob Andersen");
14
+        person.setEmail("jacobma87@hotmail.com");
15
+        other.setPayerName("Jacob Andersen");
16
+        other.setAccountNumber("1343445511");
17
+
18
+        //WHEN
19
+
20
+        int expected = 0;
21
+        int actual = (person.getShortDescription().compareTo(other.getShortDescription()));
22
+
23
+        //THEN
24
+
25
+        Assert.assertNotEquals(expected,actual);
26
+    }
27
+}

+ 8
- 0
src/main/java/com/zipcoder/payment/Payment.java Parādīt failu

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

+ 4
- 2
src/main/java/com/zipcoder/payment/PaymentPresenter.java Parādīt failu

@@ -1,6 +1,8 @@
1 1
 package com.zipcoder.payment;
2 2
 
3 3
 public class PaymentPresenter {
4
-
5
-
4
+    @Override
5
+    public String toString() {
6
+        return "PaymentPresenter{}";
7
+    }
6 8
 }

+ 11
- 0
src/main/java/com/zipcoder/payment/PaymentSortByPayer.java Parādīt failu

@@ -0,0 +1,11 @@
1
+package com.zipcoder.payment;
2
+
3
+import java.util.Comparator;
4
+
5
+public class PaymentSortByPayer implements Comparator<Payment>
6
+
7
+{ @Override
8
+    public int compare(Payment o1, Payment o2) {
9
+        return 0;
10
+    }
11
+}