package com.zipcoder.payment; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; public class PaymentPresenterTest { @Test public void paymentPresenterNoPaymentTest() { Payment[] payments = new Payment[0]; PaymentPresenter presenter = new PaymentPresenter(); String expected = ""; String actual = presenter.toString(payments); assertEquals(expected, actual); } @Test public void paymentPresenterMultiplePaymentsTest() { Payment[] payments = new Payment[2]; Payment paypal = new PayPal(4L, "Tia Mowry", "tia@mowry.com"); Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551"); payments[0] = paypal; payments[1] = check; PaymentPresenter presenter = new PaymentPresenter(); String expected = "Check Tia Mowry ***4551\nPaypal Tia Mowry tia@mowry.com\n"; String actual = presenter.toString(payments); assertEquals(expected, actual); } @Test public void toStringByPayerNameTest() { Payment[] payments = new Payment[2]; Payment paypal = new PayPal(4L, "Tamara Mowry", "tamara@mowry.com"); Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551"); payments[0] = paypal; payments[1] = check; PaymentPresenter presenter = new PaymentPresenter(); String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n"; String actual = presenter.toStringByPayerName(payments); assertEquals(expected, actual); } @Test public void toStringByIdTest() { Payment[] payments = new Payment[2]; Payment paypal = new PayPal(120L, "Tamara Mowry", "tamara@mowry.com"); Payment check = new Check(81L, "Tia Mowry", "11432543", "134344551"); payments[0] = paypal; payments[1] = check; PaymentPresenter presenter = new PaymentPresenter(); String expected = "Paypal Tamara Mowry tamara@mowry.com\nCheck Tia Mowry ***4551\n"; String actual = presenter.toStringById(payments); assertEquals(expected, actual); } }