rjsmall90 8 лет назад
Родитель
Сommit
833078ac46

+ 16
- 0
pom.xml Просмотреть файл

@@ -7,6 +7,22 @@
7 7
     <groupId>com.zipcoder</groupId>
8 8
     <artifactId>payment</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <properties>
11
+        <maven.compiler.source>1.8</maven.compiler.source>
12
+        <maven.compiler.target>1.8</maven.compiler.target>
13
+    </properties>
14
+    <dependencies>
15
+        <dependency>
16
+            <groupId>org.junit.jupiter</groupId>
17
+            <artifactId>junit-jupiter-api</artifactId>
18
+            <version>RELEASE</version>
19
+        </dependency>
20
+        <dependency>
21
+            <groupId>junit</groupId>
22
+            <artifactId>junit</artifactId>
23
+            <version>RELEASE</version>
24
+        </dependency>
25
+    </dependencies>
10 26
 
11 27
 
12 28
 </project>

src/main/java/com/zipcoder/payment/Check.java → src/main/java/com/zipcoder/payment/main/payment/Check.java Просмотреть файл

@@ -1,4 +1,5 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder.payment.main.payment;
2
+
2 3
 
3 4
 public class Check implements Payment{
4 5
     Long id;

src/main/java/com/zipcoder/payment/CreditCard.java → src/main/java/com/zipcoder/payment/main/payment/CreditCard.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder.payment.main.payment;
2 2
 
3 3
 
4 4
 public class CreditCard implements Payment {

src/main/java/com/zipcoder/payment/Payment.java → src/main/java/com/zipcoder/payment/main/payment/Payment.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder.payment.main.payment;
2 2
 
3 3
 public interface Payment extends Comparable<Payment> {
4 4
 

src/main/java/com/zipcoder/payment/PaymentPresenter.java → src/main/java/com/zipcoder/payment/main/payment/PaymentPresenter.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder.payment.main.payment;
2 2
 
3 3
 import java.util.Arrays;
4 4
 
@@ -11,8 +11,7 @@ public class PaymentPresenter {
11 11
         StringBuilder build = new StringBuilder();
12 12
         for(Payment o : payment) build.append(o.getShortDescription()+"\n");
13 13
         return build.toString();
14
-
15
-//             o.getId(); o.getPayerName();
14
+        
16 15
         }
17 16
 
18 17
     public String toStringByPayerName(Payment[] payment) {
@@ -24,7 +23,7 @@ public class PaymentPresenter {
24 23
     }
25 24
 
26 25
     public String toStringById(Payment[] payment) {
27
-        Arrays.sort(payment, new PaymentSortByPayer());
26
+        Arrays.sort(payment, (Payment o1, Payment o2) -> Long.compare(o1.getId(), o2.getId()));
28 27
 
29 28
         StringBuilder build = new StringBuilder();
30 29
         for(Payment o : payment) build.append(o.getShortDescription()+"\n");

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

@@ -1,4 +1,4 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder.payment.main.payment;
2 2
 
3 3
 import java.util.Comparator;
4 4
 

src/main/java/com/zipcoder/payment/Paypal.java → src/main/java/com/zipcoder/payment/main/payment/Paypal.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder.payment.main.payment;
2 2
 
3 3
 public class Paypal implements Payment{
4 4
     Long id;
@@ -12,7 +12,7 @@ public class Paypal implements Payment{
12 12
 
13 13
     }
14 14
 
15
-    @Override
15
+
16 16
     public long getId() {
17 17
         return id;
18 18
     }
@@ -21,7 +21,7 @@ public class Paypal implements Payment{
21 21
         this.id = id;
22 22
     }
23 23
 
24
-    @Override
24
+
25 25
     public String getPayerName() {
26 26
         return this.payerName;
27 27
     }
@@ -30,7 +30,7 @@ public class Paypal implements Payment{
30 30
         this.payerName = payerName;
31 31
     }
32 32
 
33
-    @Override
33
+
34 34
     public String getShortDescription() {
35 35
         return "Paypal " + getPayerName() + " " + getEmail();
36 36
     }

src/main/java/com/zipcoder/payment/CheckTest.java → src/test/java/com/zipcoder/CheckTest.java Просмотреть файл

@@ -1,8 +1,11 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder;
2 2
 
3
+import com.zipcoder.payment.main.payment.Check;
4
+import com.zipcoder.payment.main.payment.CreditCard;
5
+import com.zipcoder.payment.main.payment.Paypal;
3 6
 import org.junit.Test;
4 7
 
5
-import static org.junit.Assert.*;
8
+import static org.junit.Assert.assertEquals;
6 9
 
7 10
 public class CheckTest {
8 11
     Check check = new Check();

src/main/java/com/zipcoder/payment/CreditCardTest.java → src/test/java/com/zipcoder/CreditCardTest.java Просмотреть файл

@@ -1,9 +1,11 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder;
2 2
 
3
-import com.sun.deploy.net.CrossDomainXML;
3
+import com.zipcoder.payment.main.payment.Check;
4
+import com.zipcoder.payment.main.payment.CreditCard;
5
+import com.zipcoder.payment.main.payment.Paypal;
4 6
 import org.junit.Test;
5 7
 
6
-import static org.junit.Assert.*;
8
+import static org.junit.Assert.assertEquals;
7 9
 
8 10
 public class CreditCardTest {
9 11
     Paypal pay = new Paypal();

src/main/java/com/zipcoder/payment/PaymentPresenterTest.java → src/test/java/com/zipcoder/PaymentPresenterTest.java Просмотреть файл

@@ -1,5 +1,9 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder;
2 2
 
3
+import com.zipcoder.payment.main.payment.Check;
4
+import com.zipcoder.payment.main.payment.Payment;
5
+import com.zipcoder.payment.main.payment.PaymentPresenter;
6
+import com.zipcoder.payment.main.payment.Paypal;
3 7
 import org.junit.Test;
4 8
 
5 9
 import static junit.framework.TestCase.assertEquals;
@@ -61,7 +65,7 @@ public class PaymentPresenterTest {
61 65
         payment[1] = check;
62 66
 
63 67
         PaymentPresenter presenter = new PaymentPresenter();
64
-        String expected = "Paypal Tia Mowry tamara@mowry.com\nCheck Tamara Mowry ***4551\n";
68
+        String expected = "Check Tia Mowry ***4551\nPaypal Tamara Mowry tamara@mowry.com\n";
65 69
 
66 70
         String actual = presenter.toStringById(payment);
67 71
         assertEquals(expected, actual);

src/main/java/com/zipcoder/payment/PaypalTest.java → src/test/java/com/zipcoder/PaypalTest.java Просмотреть файл

@@ -1,8 +1,11 @@
1
-package com.zipcoder.payment;
1
+package com.zipcoder;
2 2
 
3
+import com.zipcoder.payment.main.payment.Check;
4
+import com.zipcoder.payment.main.payment.CreditCard;
5
+import com.zipcoder.payment.main.payment.Paypal;
3 6
 import org.junit.Test;
4 7
 
5
-import static org.junit.Assert.*;
8
+import static org.junit.Assert.assertEquals;
6 9
 
7 10
 public class PaypalTest {
8 11