PayPalTest.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package com.zipcoder.payment;
  2. import org.junit.Test;
  3. import static org.junit.Assert.*;
  4. public class PayPalTest {
  5. @Test
  6. public void getIdTest() {
  7. PayPal payPal = new PayPal(500L, "Roy", "Roy@gmail.com");
  8. Long expected = 500L;
  9. payPal.setId(500L);
  10. Long actual = payPal.getId();
  11. assertEquals(expected, actual);
  12. }
  13. @Test
  14. public void setIdTest() {
  15. PayPal payPal = new PayPal(500L, "Roy", "Roy@gmail.com");
  16. Long expected = 500L;
  17. payPal.setId(500L);
  18. Long actual = payPal.getId();
  19. assertEquals(expected, actual);
  20. }
  21. @Test
  22. public void getPayerNameTest() {
  23. PayPal payPal = new PayPal(500L, "Roy", "Roy@gmail.com");
  24. String expected = "John Jones";
  25. payPal.setPayerName("John Jones");
  26. String actual = payPal.getPayerName();
  27. assertEquals(expected, actual);
  28. }
  29. @Test
  30. public void setPayerNameTest() {
  31. PayPal payPal = new PayPal(500L, "Roy", "Roy@gmail.com");
  32. String expected = "John Jones";
  33. payPal.setPayerName("John Jones");
  34. String actual = payPal.getPayerName();
  35. assertEquals(expected, actual);
  36. }
  37. @Test
  38. public void getEmailTest() {
  39. PayPal payPal = new PayPal(500L, "Roy", "Roy@gmail.com");
  40. String expected = "JJones@yahoo.com";
  41. payPal.setEmail("JJones@yahoo.com");
  42. String actual = payPal.getEmail();
  43. assertEquals(expected, actual);
  44. }
  45. @Test
  46. public void setEmailTest() {
  47. PayPal payPal = new PayPal(500L, "Roy", "Roy@gmail.com");
  48. String expected = "JJones@yahoo.com";
  49. payPal.setEmail("JJones@yahoo.com");
  50. String actual = payPal.getEmail();
  51. assertEquals(expected, actual);
  52. }
  53. @Test
  54. public void getShortDescriptionTest() {
  55. PayPal payPal = new PayPal(500L, "Roy", "Roy@gmail.com");
  56. payPal.setPayerName("John Jones");
  57. payPal.setEmail("JJones@yahoo.com");
  58. String expected = "Paypal " + payPal.getPayerName() + " " + payPal.getEmail();
  59. String actual = payPal.getShortDescription();
  60. assertEquals(expected, actual);
  61. }
  62. @Test
  63. public void compareToTest() {
  64. Payment c = new PayPal(500L, "John Jones", "3567280");
  65. Payment second = new PayPal(700L, "Tom Ryan", "3884625");
  66. int expected = -1;
  67. int actual = c.compareTo(second);
  68. assertEquals(expected, actual);
  69. }
  70. }