PaymentPresenterTest.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.zipcoder.payment;
  2. import org.junit.jupiter.api.Test;
  3. import static org.junit.jupiter.api.Assertions.assertEquals;
  4. public class PaymentPresenterTest {
  5. @Test
  6. public void toStringTest() {
  7. Payment[] payments = new Payment[0];
  8. PaymentPresenter pp = new PaymentPresenter();
  9. String expected = "";
  10. String actual = pp.toString(payments);
  11. assertEquals(expected, actual);
  12. }
  13. @Test
  14. public void toStringMultipleTest() {
  15. Payment[] payments = new Payment[2];
  16. Payment paypal = new Paypal("Tia Mowry", "tia@mowry.com");
  17. Payment check = new Check("Lewis Dominguez", "11432543", "134344551");
  18. payments[0] = paypal;
  19. payments[1] = check;
  20. PaymentPresenter presenter = new PaymentPresenter();
  21. String expected = "Check Lewis Dominguez ***4551\nPaypal Tia Mowry tia@mowry.com\n";
  22. String actual = presenter.toString(payments);
  23. assertEquals(expected, actual);
  24. }
  25. @Test
  26. public void toStringPaymentByPayer() {
  27. Payment[] payments = new Payment[2];
  28. Payment paypal = new Paypal("Tia Mowry", "tia@mowry.com");
  29. Payment check = new Check("Lewis Dominguez", "11432543", "134344551");
  30. payments[0] = paypal;
  31. payments[1] = check;
  32. PaymentPresenter presenter = new PaymentPresenter();
  33. String expected = "Check Lewis Dominguez ***4551\nPaypal Tia Mowry tia@mowry.com\n";
  34. String actual = presenter.toStringByPayerName(payments);
  35. assertEquals(expected, actual);
  36. }
  37. @Test
  38. public void toStringBySetIdTest() {
  39. Payment[] payments = new Payment[2];
  40. Paypal paypal = new Paypal("Tia Mowry", "tia@mowry.com");
  41. Check check = new Check("Lewis Dominguez", "11432543", "134344551");
  42. paypal.setId(2L);
  43. check.setId(1L);
  44. payments[0] = paypal;
  45. payments[1] = check;
  46. PaymentPresenter presenter = new PaymentPresenter();
  47. String expected = "Check Lewis Dominguez ***4551\nPaypal Tia Mowry tia@mowry.com\n";
  48. String actual = presenter.toStringBySetId(payments);
  49. assertEquals(expected, actual);
  50. }
  51. }