Package com.expositds.ars.domain.order

Examples of com.expositds.ars.domain.order.Order


    return result;
  }

  @Override
  public Order updateOrder(Order order) {
    Order result = null;

    OrderEntity orderEntity = DozerHelper.map(order, OrderEntity.class);
    orderEntity = orderRepository.merge(orderEntity);
    result = DozerHelper.map(orderEntity, Order.class);
View Full Code Here


    orderRepository.delete(id);
  }

  @Override
  public Order getOrderById(Long id) {
    Order result = null;

    OrderEntity orderEntity = orderRepository.findById(id);
    result = DozerHelper.map(orderEntity, Order.class);

    return result;
View Full Code Here

  // ============================ //

  @Override
  public Order getOrderByOrderRegNo(String orderRegNo)
      throws WrongOrderRegNoException {
    Order result = null;

    OrderEntity orderEntity = orderRepository.findByOrderRegNo(orderRegNo);
    result = DozerHelper.map(orderEntity, Order.class);

    return result;
View Full Code Here

    subsidiaryEntity = subsidiaryRepository.findByName("ARS Grodno");
    Subsidiary subsidiary = DozerHelper.map(subsidiaryEntity,
        Subsidiary.class);

    log.info("Creating new order and setting NEW status for it.");
    Order order = new Order("Do something", car, customer, subsidiary);
    try {
      order.changeStatus(EOrderStatus.NEW);
    } catch (InvalidOrderStatusSequenceException e) {
      e.printStackTrace();
    } catch (UnknownOrderStatusException e) {
      e.printStackTrace();
    } catch (NoneActivitiesException e) {
      e.printStackTrace();
    } catch (NonePaymentException e) {
      e.printStackTrace();
    } catch (PaymentNotCompletedException e) {
      e.printStackTrace();
    }
    log.info("Selecting mechanic for order.");

    log.info("Mapping to order entity and mergin it to database.");
    OrderEntity orderEntity = DozerHelper.map(order, OrderEntity.class);
    orderEntity = orderRepository.merge(orderEntity);
    orderEntity
        .setOrderRegNo(order.generateOrderRegNo(orderEntity.getId()));

    // Check
    List<OrderEntity> result = orderRepository.findByCustomer(
        customerEntity, null, null, null);

    Assert.assertEquals(1, result.size());
    log.info("Result: " + result.iterator().next());

    log.info("Changing status to IN_PROGRESS.");
    order = DozerHelper.map(orderEntity, Order.class);
    try {
      order.changeStatus(EOrderStatus.IN_PROGRESS);
    } catch (InvalidOrderStatusSequenceException e) {
      e.printStackTrace();
    } catch (UnknownOrderStatusException e) {
      e.printStackTrace();
    } catch (NoneActivitiesException e) {
      e.printStackTrace();
    } catch (NonePaymentException e) {
      e.printStackTrace();
    } catch (PaymentNotCompletedException e) {
      e.printStackTrace();
    }
    log.info("Adding activities to the order.");
    Service testService = new Service("Test service.");
    testService.setElapsedTime((short) 2);
    testService.setNote("Test note");
    testService.setTotal(50);
    try {
      order.addActivity(testService);
    } catch (ActivityAlreadyExistsException e1) {
      e1.printStackTrace();
    } catch (OrderNotInProgressException e) {
      e.printStackTrace();
    }

    orderEntity = DozerHelper.map(order, OrderEntity.class);
    orderEntity = orderRepository.merge(orderEntity);

    // Check
    result = orderRepository.findByCustomer(customerEntity, null, null,
        null);

    Assert.assertEquals(1, result.size());
    Assert.assertEquals(EOrderStatus.IN_PROGRESS, result.iterator().next()
        .getStatus());
    log.info("Result: " + result);

    log.info("Changing status to AWAITING_PAYMENT.");
    order = DozerHelper.map(orderEntity, Order.class);
    try {
      order.changeStatus(EOrderStatus.AWAITING_PAYMENT);
    } catch (InvalidOrderStatusSequenceException e) {
      e.printStackTrace();
    } catch (UnknownOrderStatusException e) {
      e.printStackTrace();
    } catch (NoneActivitiesException e) {
      e.printStackTrace();
    } catch (NonePaymentException e) {
      e.printStackTrace();
    } catch (PaymentNotCompletedException e) {
      e.printStackTrace();
    }

    orderEntity = DozerHelper.map(order, OrderEntity.class);
    orderEntity = orderRepository.merge(orderEntity);

    // Check
    result = orderRepository.findByCustomer(customerEntity, null, null,
        null);

    Assert.assertEquals(1, result.size());
    Assert.assertEquals(EOrderStatus.AWAITING_PAYMENT, result.iterator()
        .next().getStatus());
    log.info("Result: " + result);

    log.info("Changing status to COMPLETED.");
    order = DozerHelper.map(orderEntity, Order.class);
    order.getPayment().makePayment(new TestPaymentSystem());
    try {
      order.changeStatus(EOrderStatus.COMPLETED);
    } catch (InvalidOrderStatusSequenceException e) {
      e.printStackTrace();
    } catch (UnknownOrderStatusException e) {
      e.printStackTrace();
    } catch (NoneActivitiesException e) {
View Full Code Here

  @Autowired
  private IMechanicService mechanicService;

  @Test
  public void getOrderByIdTest() {
    Order order = orderService.getOrderById(new Long(2));
   
    log.info(order);
  }
View Full Code Here

  @Test
  public void addOrderTest() {
    Car car = carServise.getCarById(new Long(1));
    Customer customer = customerService.getCustomerById(new Long(7));
    Subsidiary subsidiary = subsidiaryService.getSubsidiaryById(new Long(1));
    Order order = new Order("��������", car, customer, subsidiary);
    order.setCreationDate(new Date());
    order.setStatus(EOrderStatus.NEW);
   
    Long id = orderService.addOrder(order);
    order = orderService.getOrderById(id);
    log.info(order);
  }
View Full Code Here

    log.info(order);
  }

  @Test
  public void deleteOrderTest() {
    Order order = orderService.getOrderById(new Long(2));
    orderService.deleteOrder(order);
  }
View Full Code Here

    log.info(order);
  }

  @Test
  public void getOrderByOrderRegNoTest() {
    Order order;
    try {
      order = orderService.getOrderByOrderRegNo("0106000013");
      log.info(order);
    } catch (WrongOrderRegNoException e) {
      e.printStackTrace();
View Full Code Here

    log.info(order);
  }

  @Test
  public void updateOrder() {
    Order order = orderService.getOrderById(new Long(2));
    order.setDescription("test");
    order.setEndingDate(new Date());
   
    log.info(order);
  }
View Full Code Here

    activityService.deleteActivity(activity);
  }
 
  @Test
  public void getActivitiesByOrderTest () {
    Order order = orderService.getOrderById(new Long(2));
   
    List<Activity> activity = activityService.getActivitiesByOrder(order, 1);
    log.info(activity);
  }
View Full Code Here

TOP

Related Classes of com.expositds.ars.domain.order.Order

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.