Bladeren bron

done section2

Mexi 8 jaren geleden
bovenliggende
commit
b000cccad6

+ 2
- 1
src/main/java/com/zipcoder/payment/PayPal.java Bestand weergeven

38
     }
38
     }
39
 
39
 
40
     public int compareTo(Payment o) {
40
     public int compareTo(Payment o) {
41
-        return 0;
41
+        int n = this.getShortDescription().compareTo(o.getShortDescription());
42
+        return n;
42
     }
43
     }
43
 }
44
 }

+ 2
- 0
src/test/java/com/zipcoder/payment/CheckTest.java Bestand weergeven

80
 
80
 
81
     @Test
81
     @Test
82
     public void compareTo() {
82
     public void compareTo() {
83
+        Check check1 = new Check();
84
+
83
     }
85
     }
84
 }
86
 }
85
 
87
 

+ 38
- 1
src/test/java/com/zipcoder/payment/PayPalTest.java Bestand weergeven

64
     }
64
     }
65
 
65
 
66
     @Test
66
     @Test
67
-    public void compareTo() {
67
+    public void compareToWhenEquals() {
68
+        PayPal payPal = new PayPal();
69
+        PayPal payPal1 = new PayPal();
70
+        payPal.setId(123);
71
+        payPal.setPayerName("Jo");
72
+        payPal.setEmail("jojo@gmail.com");
73
+        payPal1.setId(123);
74
+        payPal1.setPayerName("Jo");
75
+        payPal1.setEmail("jojo@gmail.com");
76
+        Assert.assertTrue(payPal.getShortDescription().compareTo(payPal1.getShortDescription())==0);
77
+    }
78
+
79
+    @Test
80
+    public void compareToWhenPayment1ComesBeforePayment2(){
81
+        PayPal payPal = new PayPal();
82
+        PayPal payPal1 = new PayPal();
83
+        payPal.setId(123);
84
+        payPal.setPayerName("Bo");
85
+        payPal.setEmail("bobo@gmail.com");
86
+        payPal1.setId(124);
87
+        payPal1.setPayerName("Jo");
88
+        payPal1.setEmail("jojo@gmail.com");
89
+        Assert.assertTrue(payPal.getShortDescription().compareTo(payPal1.getShortDescription())<0);
90
+
91
+    }
92
+
93
+    @Test
94
+    public void compareToWhenPayment1ComesAfterPayment2(){
95
+        PayPal payPal = new PayPal();
96
+        PayPal payPal1 = new PayPal();
97
+        payPal.setId(124);
98
+        payPal.setPayerName("Jo");
99
+        payPal.setEmail("jojo@gmail.com");
100
+        payPal1.setId(123);
101
+        payPal1.setPayerName("Bo");
102
+        payPal1.setEmail("bobo@gmail.com");
103
+        Assert.assertTrue(payPal.getShortDescription().compareTo(payPal1.getShortDescription())>0);
104
+
68
     }
105
     }
69
 }
106
 }