package com.zipcoder.payment; import java.util.Arrays; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class PaymentPresenterTest { Check check; Paypal paypal; PaymentPresenter presenter; @Before public void setup() { StringBuilder sb = new StringBuilder(); } @Test public void toStringNoPayment() { Payments[] payments = new Payments[0]; PaymentPresenter presenter = new PaymentPresenter(); String expected = ""; String actual = presenter.toString(payments); assertEquals(expected, actual); } @Test public void toStringByPayerName() { Payments[] payments = new Payments[2]; Payments paypal = new Paypal(4L, "Tia Mowry", "tia@mowry.com"); Payments 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 toStringByPayer() { Payments[] payments = new Payments[2]; Payments paypal = new Paypal(4L, "Tamara Mowry", "tamara@mowry.com"); Payments 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 toStringById(){ Payments[] payments = new Payments[2]; Payments paypal = new Paypal(81L, "Tamara Mowry", "tamara@mowry.com"); Payments check = new Check(120L, "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); } }