PaymentPresenterTest.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package com.zipcoder.payment;
  2. import java.util.Arrays;
  3. import org.junit.Assert;
  4. import org.junit.Before;
  5. import org.junit.Test;
  6. import static org.junit.Assert.assertEquals;
  7. import static org.junit.Assert.assertTrue;
  8. public class PaymentPresenterTest {
  9. Check check;
  10. Paypal paypal;
  11. PaymentPresenter presenter;
  12. @Before
  13. public void setup() {
  14. StringBuilder sb = new StringBuilder();
  15. }
  16. @Test
  17. public void toStringNoPayment() {
  18. Payments[] payments = new Payments[0];
  19. PaymentPresenter presenter = new PaymentPresenter();
  20. String expected = "";
  21. String actual = presenter.toString(payments);
  22. assertEquals(expected, actual);
  23. }
  24. @Test
  25. public void toStringByPayerName() {
  26. Payments[] payments = new Payments[2];
  27. Payments paypal = new Paypal(4L, "Tia Mowry", "tia@mowry.com");
  28. Payments check = new Check(81L, "Tia Mowry", "11432543", "134344551");
  29. payments[0] = paypal;
  30. payments[1] = check;
  31. PaymentPresenter presenter = new PaymentPresenter();
  32. String expected = "Check Tia Mowry ***4551\nPaypal Tia Mowry tia@mowry.com\n";
  33. String actual = presenter.toString(payments);
  34. assertEquals(expected, actual);
  35. }
  36. @Test
  37. public void toStringByPayer() {
  38. Payments[] payments = new Payments[2];
  39. Payments paypal = new Paypal(4L, "Tamara Mowry", "tamara@mowry.com");
  40. Payments check = new Check(81L, "Tia Mowry", "11432543", "134344551");
  41. payments[0] = paypal;
  42. payments[1] = check;
  43. PaymentPresenter presenter = new PaymentPresenter();
  44. String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n";
  45. String actual = presenter.toStringByPayerName(payments);
  46. assertEquals(expected, actual);
  47. }
  48. @Test
  49. public void toStringById(){
  50. Payments[] payments = new Payments[2];
  51. Payments paypal = new Paypal(81L, "Tamara Mowry", "tamara@mowry.com");
  52. Payments check = new Check(120L, "Tia Mowry", "11432543", "134344551");
  53. payments[0] = paypal;
  54. payments[1] = check;
  55. PaymentPresenter presenter = new PaymentPresenter();
  56. String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n";
  57. String actual = presenter.toStringById(payments);
  58. assertEquals(expected, actual);
  59. }
  60. }