package com.zipcoder.payment; import org.junit.Assert; import org.junit.Test; public class CompareToTest { PayPal pal = new PayPal(001L,"Tia Mowry","tia@moury.com"); Check check = new Check(002L,"Tia Mowry","987-9999-9999","333444" ); CreditCard cc = new CreditCard(003L,"Tia Mowry","890-8700-9999", 12,1999); @Test public void testCompareTo2Paypal(){ //given PayPal pal1 = new PayPal(); pal1.setPayerName("Evangelina H"); pal1.setEmail("evangelila@h.com"); int expected=-15; //when pal1.getShortDescription(); pal.getShortDescription(); //then Assert.assertEquals(expected, pal1.compareTo(pal)); } @Test public void testCompareTo2PaypalReverse(){ //given PayPal pal1 = new PayPal(); pal1.setPayerName("Evangelina H"); pal1.setEmail("evangelila@h.com"); int expected=15; //when pal1.getShortDescription(); pal.getShortDescription(); //then Assert.assertEquals(expected, pal.compareTo(pal1)); } @Test public void testCompareToPayPal1() { //given int expected = 0; //when pal.getShortDescription(); Assert.assertEquals(expected, pal.compareTo(pal)); } @Test public void testCompareToPaypa2() { //given int expected = 13; //when pal.getShortDescription(); check.getShortDescription(); Assert.assertEquals(expected, pal.compareTo(check)); } @Test public void testCompareToPaypal3() { //given int expected = 13; //when pal.getShortDescription(); cc.getShortDescription(); Assert.assertEquals(expected, pal.compareTo(cc)); } @Test public void testCompareTo2Check() { //given Check check1 = new Check(001L,"Kevin Hart", "123-4567-8909", "777888"); int expected = 9; //when check.getShortDescription(); check1.getShortDescription(); Assert.assertEquals(expected, check.compareTo(check1)); } @Test public void testCompareTo2CheckReverse() { //given Check check1 = new Check(002L,"Kevin Hart", "123-4567-8909","998899"); int expected = -9; //when check.getShortDescription(); check1.getShortDescription(); Assert.assertEquals(expected, check1.compareTo(check)); } @Test public void testCompareToCheck1() { //given int expected = 0; //when check.getShortDescription(); Assert.assertEquals(expected, check.compareTo(check)); } @Test public void testCompareToCheck2() { //given int expected = -13; //when pal.getShortDescription(); check.getShortDescription(); Assert.assertEquals(expected, check.compareTo(pal)); } @Test public void testCompareToCheck3() { //given int expected = -10; //when check.getShortDescription(); cc.getShortDescription(); Assert.assertEquals(expected, check.compareTo(cc)); } @Test public void testCompareTo2Card() { //given CreditCard cc1= new CreditCard(002L,"Dina r", "999-9890-8898", 04, 1999); int expected = 16; //when cc.getShortDescription(); cc1.getShortDescription(); Assert.assertEquals(expected, cc.compareTo(cc1)); } @Test public void testCompareTo2CardReverse() { //given CreditCard cc1= new CreditCard(004L,"Dina r", "999-9890-8898", 04, 1999); int expected = -16; //when cc.getShortDescription(); cc1.getShortDescription(); Assert.assertEquals(expected, cc1.compareTo(cc)); } @Test public void testCompareToCard1() { //given int expected = 0; //when cc.getShortDescription(); Assert.assertEquals(expected, cc.compareTo(cc)); } @Test public void testCompareToCard2() { //given int expected = -13; //when cc.getShortDescription(); pal.getShortDescription(); Assert.assertEquals(expected, cc.compareTo(pal)); } @Test public void testCompareToCard3() { //given int expected = 10; //when cc.getShortDescription(); check.getShortDescription(); Assert.assertEquals(expected, cc.compareTo(check)); } }