Exemplo n.º 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);
  }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
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);
  }