| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- 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));
-
-
- }
-
-
- }
|