Advertisement
xickoh

addContainer

Nov 29th, 2020
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1.  
  2. import base.Address;
  3. import base.Customer;
  4. import base.Person;
  5. import order.base.OrderStatus;
  6. import order.exceptions.ContainerException;
  7. import order.exceptions.OrderException;
  8. import order.exceptions.PositionException;
  9. import order.shippingorder.ShippingOrder;
  10. import org.junit.jupiter.api.Test;
  11. import packing.Container;
  12.  
  13. import static order.base.OrderStatus.IN_TREATMENT;
  14. import static org.junit.jupiter.api.Assertions.*;
  15.  
  16. public class testMain {
  17.  
  18.     @Test
  19.     void testSO001(){
  20.         Address a = new Address("street", 1, "city", "state", "country");
  21.         Person p = new Person("Name", a);
  22.         Person p2 = new Person("Name2", a);
  23.         Customer c = new Customer("Name", a, a);
  24.  
  25.         ShippingOrder so = new ShippingOrder(c,p2);
  26.         Container c1 = null;
  27.         assertThrows(ContainerException.class,
  28.                 () ->so.addContainer(c1),
  29.                 "Didn't throw ContainerException as supposed");
  30.     }
  31.  
  32.     @Test
  33.     void testSO002() throws ContainerException, PositionException, OrderException {
  34.         Address a = new Address("street", 1, "city", "state", "country");
  35.         Person p = new Person("Name", a);
  36.         Person p2 = new Person("Name2", a);
  37.         Customer c = new Customer("Name", a, a);
  38.  
  39.         ShippingOrder so = new ShippingOrder(c,p2);
  40.         Container c1 = new Container("001", 10, 10, 10, 10);
  41.         assertThrows(OrderException.class,
  42.                 () ->so.addContainer(c1),
  43.                 "Didn't throw OrderException as supposed");
  44.     }
  45.  
  46.     @Test
  47.     void testSO003() throws ContainerException, PositionException, OrderException{
  48.         Address a = new Address("street", 1, "city", "state", "country");
  49.         Person p = new Person("Name", a);
  50.         Person p2 = new Person("Name2", a);
  51.         Customer c = new Customer("Name", a, a);
  52.  
  53.         ShippingOrder so = new ShippingOrder(c,p2);
  54.  
  55.         Container c1 = new Container("001", 10, 10, 10, 10);
  56.         c1.close();
  57.         boolean result = so.addContainer(c1);
  58.         assertTrue(result);
  59.     }
  60.  
  61.     @Test
  62.     void testSO004() throws ContainerException, PositionException, OrderException{
  63.         Address a = new Address("street", 1, "city", "state", "country");
  64.         Person p = new Person("Name", a);
  65.         Person p2 = new Person("Name2", a);
  66.         Customer c = new Customer("Name", a, a);
  67.  
  68.         ShippingOrder so = new ShippingOrder(c,p2);
  69.  
  70.         Container c1 = new Container("001", 10, 10, 10, 10);
  71.         c1.close();
  72.         so.addContainer(c1);
  73.         boolean result = so.addContainer(c1);
  74.         assertFalse(result);
  75.     }
  76.  
  77.  
  78.  
  79.  
  80. }
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement