예제 #1
0
  @Test
  public void testSetReadyStatusForOrderWhenEverythingOk() throws LogiwebValidationException {
    Order testOrder = createValidTestOrder();
    when(orderDAOMock.findById(testOrder.getOrderId())).thenReturn(testOrder);

    orderServiceImpl.setReadyStatusForOrder(testOrder.getOrderId());
    verify(orderDAOMock, times(1)).update(testOrder);
  }
예제 #2
0
  @Test(expected = LogiwebValidationException.class)
  public void testAssignTruckToOrderWhenTruckIsNotOk() throws LogiwebValidationException {
    Truck testTruck = new Truck();
    testTruck.setTruckId(1);
    testTruck.setTruckStatus(TruckStatus.FAULTY);
    Order testOrder = new Order();
    testOrder.setOrderLines(new HashSet<>(Arrays.asList(new Freight())));
    testTruck.setOrderForThisTruck(testOrder);

    when(truckDAOMock.findById(1)).thenReturn(testTruck);
    when(orderDAOMock.findById(1)).thenReturn(testOrder);

    orderServiceImpl.assignTruck(1, 1);
  }
예제 #3
0
 @Test
 public void testAddNewOrder() {
   orderServiceImpl.addNewOrder();
   verify(orderDAOMock, times(1)).create(any(Order.class));
 }
예제 #4
0
 // If method return "null"
 @Test
 public void testFindOrderByIdWhenReturnNull() {
   when(orderDAOMock.findById(1)).thenReturn(null);
   OrderDTO result = orderServiceImpl.findOrderById(1);
   assertNull(result);
 }