|
|
@@ -7,54 +7,79 @@ public class PaymentSortByPayerTest {
|
|
7
|
7
|
|
|
8
|
8
|
PaymentSortByPayer paymentSortByPayer1 = new PaymentSortByPayer();
|
|
9
|
9
|
PaymentSortByPayer paymentSortByPayer2 = new PaymentSortByPayer();
|
|
10
|
|
- PaymentSortByPayer paymentSortByPayer3= new PaymentSortByPayer();
|
|
11
|
10
|
|
|
12
|
11
|
|
|
13
|
|
- Payment payment1 = new PayPal();
|
|
14
|
|
- Payment payment2 = new Check();
|
|
|
12
|
+ PayPal payment1 = new PayPal();
|
|
|
13
|
+ Check payment2 = new Check();
|
|
15
|
14
|
|
|
16
|
15
|
@Test
|
|
17
|
|
- public void compare() {
|
|
|
16
|
+ public void test_compare_when_payments_are_equal() {
|
|
18
|
17
|
|
|
19
|
|
- int x = paymentSortByPayer3.compare(paymentSortByPayer1, paymentSortByPayer2);
|
|
|
18
|
+ payment1.setPayerName("Ken");
|
|
|
19
|
+ payment1.setEmail("peace_459@live.com");
|
|
|
20
|
+ payment1.setId(888);
|
|
20
|
21
|
|
|
21
|
|
- Assert.assertEquals(-1, x < 0);
|
|
22
|
|
- Assert.assertEquals(0, x == 0);
|
|
23
|
|
- Assert.assertEquals(1, x > 0);
|
|
|
22
|
+ payment2.setId(459);
|
|
|
23
|
+ payment2.setRoutingNumber("2815");
|
|
|
24
|
+ payment2.setPayerName("Angel");
|
|
|
25
|
+ payment2.setAccountNumber("9532850");
|
|
24
|
26
|
|
|
25
|
27
|
|
|
|
28
|
+ //int actual = paymentSortByPayer1.compare(payment1, payment1);
|
|
26
|
29
|
|
|
|
30
|
+ Assert.assertTrue(paymentSortByPayer1.compare(payment1, payment1)==0);
|
|
|
31
|
+// Assert.assertFalse(actual < 0);
|
|
|
32
|
+// Assert.assertFalse(actual > 0);
|
|
27
|
33
|
|
|
28
|
34
|
|
|
|
35
|
+ }
|
|
29
|
36
|
|
|
30
|
37
|
|
|
|
38
|
+ @Test
|
|
|
39
|
+ public void test_compare_when_payment1_is_before_payment2(){
|
|
|
40
|
+
|
|
|
41
|
+ payment1.setPayerName("Kenn");
|
|
|
42
|
+ payment1.setEmail("peace_459@livee.com");
|
|
|
43
|
+ payment1.setId(8888);
|
|
|
44
|
+
|
|
|
45
|
+ payment2.setId(4559);
|
|
|
46
|
+ payment2.setRoutingNumber("28155");
|
|
|
47
|
+ payment2.setPayerName("Angell");
|
|
|
48
|
+ payment2.setAccountNumber("9532857");
|
|
|
49
|
+
|
|
|
50
|
+ int actual = paymentSortByPayer1.compare(payment1, payment2);
|
|
|
51
|
+
|
|
|
52
|
+ Assert.assertTrue(actual > 0);
|
|
|
53
|
+ Assert.assertFalse(actual < 0);
|
|
|
54
|
+ Assert.assertFalse(actual == 0);
|
|
|
55
|
+ }
|
|
|
56
|
+
|
|
|
57
|
+
|
|
|
58
|
+
|
|
|
59
|
+ @Test
|
|
|
60
|
+ public void test_compare_when_payment2_is_before_payment1(){
|
|
31
|
61
|
|
|
|
62
|
+ PayPal payment5 = new PayPal();
|
|
|
63
|
+ Check payment6 = new Check();
|
|
32
|
64
|
|
|
|
65
|
+ payment5.setPayerName("Kennn");
|
|
|
66
|
+ payment5.setEmail("peace_459@liveee.com");
|
|
|
67
|
+ payment5.setId(88888);
|
|
33
|
68
|
|
|
|
69
|
+ payment6.setId(45559);
|
|
|
70
|
+ payment6.setRoutingNumber("281555");
|
|
|
71
|
+ payment6.setPayerName("Angelll");
|
|
|
72
|
+ payment6.setAccountNumber("9532852");
|
|
34
|
73
|
|
|
35
|
|
- // // boolean answer;
|
|
36
|
|
-// int fuego = 0;
|
|
37
|
|
-//
|
|
38
|
|
-// if(payment1.compareTo(payment2) > 0){
|
|
39
|
|
-// fuego = 88;
|
|
40
|
|
-// } else
|
|
41
|
|
-// if(payment1.compareTo(payment2) == 0){
|
|
42
|
|
-// fuego = 0;
|
|
43
|
|
-// } else
|
|
44
|
|
-// if(payment1.compareTo(payment2) < 0){
|
|
45
|
|
-// fuego = -3849;
|
|
46
|
|
-// }
|
|
47
|
|
-//
|
|
48
|
|
-// Assert.assertTrue("fuego is greater than zero", fuego > 0);
|
|
49
|
|
-// Assert.assertTrue("fuego equals zero", fuego == 0);
|
|
50
|
|
-// Assert.assertTrue("fuego is less than zero", fuego < 0);
|
|
51
|
|
-//
|
|
52
|
|
-// }
|
|
|
74
|
+ int actual = paymentSortByPayer2.compare(payment5, payment6);
|
|
53
|
75
|
|
|
|
76
|
+ Assert.assertTrue(actual > 0);
|
|
|
77
|
+ Assert.assertFalse(actual < 0);
|
|
|
78
|
+ Assert.assertFalse(actual == 0);
|
|
54
|
79
|
|
|
55
|
80
|
}
|
|
56
|
81
|
}
|
|
57
|
82
|
|
|
58
|
83
|
//Leaving test broken so that I remember to come back to it.
|
|
59
|
|
-xyz
|
|
|
84
|
+//xyz
|
|
60
|
85
|
//Leaving test broken so that I remember to come back to it.
|