Ejemplo n.º 1
0
  private Order createValidTestOrder() {
    Truck truck = new Truck();
    truck.setDriverCount(1);
    truck.setDriversInTruck(new HashSet<>(Arrays.asList(new Driver())));

    Order order = new Order();
    order.setOrderLines(new HashSet<>(Arrays.asList(new Freight())));
    order.setOrderStatus(OrderStatus.CREATED);
    order.setAssignedTruckFK(truck);

    return order;
  }
Ejemplo n.º 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);
  }