Seth 7 лет назад
Родитель
Сommit
89f60e2cfc

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

@@ -5,6 +5,6 @@ import java.util.Comparator;
5 5
 public class PaymentSortByPayer implements Comparator<Payment> {
6 6
 
7 7
     public int compare(Payment payment1, Payment payment2) {
8
-        return payment1.compareTo(payment2);
8
+        return payment1.getPayerName().compareTo(payment2.getPayerName());
9 9
     }
10 10
 }

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

@@ -1,4 +1,33 @@
1 1
 package com.zipcoder.payment;
2 2
 
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
3 6
 public class PaymentPresenterTest {
7
+
8
+//    @Test
9
+//    public void toStringEmptyTest() {
10
+//        Payment[] payments = new Payment[0];
11
+//        PaymentPresenter presenter = new PaymentPresenter();
12
+//        String expected = "";
13
+//
14
+//        String actual = presenter.toString(payments);
15
+//
16
+//        Assert.assertEquals(expected, actual);
17
+//    }
18
+//    @Test
19
+//    public void toStringTest() {
20
+//        Payment[] payments = new Payment[2];
21
+//        Payment paypal = new PayPal(4L, "Tia Mowry", "tia@mowry.com");
22
+//        Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551")
23
+//
24
+//        payments[0] = paypal;
25
+//        payments[1] = check;
26
+//
27
+//        PaymentPresenter presenter = new PaymentPresenter();
28
+//        String expected = "Check Tia Mowry ***4551\nPaypal Tia Mowry tia@mowry.com\n";
29
+//
30
+//        String actual = presenter.toString(payments);
31
+//        Assert.assertEquals(expected, actual);
32
+//    }
4 33
 }

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

@@ -19,17 +19,17 @@ public class PaymentSortByPayerTest {
19 19
 
20 20
         int actual = test.compare(payment1, payment2);
21 21
 
22
-        Assert.assertTrue(actual > 0);
22
+        Assert.assertTrue(actual < 0);
23 23
     }
24 24
 
25 25
     @Test
26 26
     public void compareTest02() {
27
-        Check payment1 = new Check(300,"Zaron Aaronson", "1234567", "764321");
27
+        Check payment1 = new Check(300,"Zach Aaronson", "1234567", "764321");
28 28
         PayPal payment2 = new PayPal(15,"Momo Hashimoto", "kawaii54@line.com");
29 29
 
30 30
         int actual = test.compare(payment1, payment2);
31 31
 
32
-        Assert.assertTrue(actual < 0);
32
+        Assert.assertTrue(actual > 0);
33 33
     }
34 34
 
35 35
     @Test