Package de.forsthaus.backend.model

Examples of de.forsthaus.backend.model.Customer


    final int countRecords = newRecords;

    final RandomDataEngine randomDataEngine = new RandomDataEngine();

    for (int j = 0; j < countRecords; j++) {
      final Customer customer = getCustomerService().getNewCustomer();

      customer.setKunName1(randomDataEngine.getRandomManFirstname());
      customer.setKunName2(randomDataEngine.getRandomLastname());
      customer.setKunMatchcode(customer.getKunName2().toUpperCase());
      customer.setKunOrt(randomDataEngine.getRandomCity());
      customer.setBranche(branche);
      customer.setKunMahnsperre(false);

      // if no customer no. is set by user than take
      // the max PrimaryKey + 1
      if (customer.getKunNr().isEmpty()) {
        customer.setKunNr(String.valueOf(getCustomerService().getMaxCustomerId() + 1));
      }

      getCustomerService().saveOrUpdate(customer);
    }
View Full Code Here


    getCustomerDAO().delete(kunde);
  }

  @Override
  public Customer getCustomerById(Long id) {
    Customer customer = getCustomerDAO().getCustomerByID(id);
    return customer;
  }
View Full Code Here

    return getCustomerDAO().getCustomersByBranche(branche);
  }

  @Override
  public Customer getCustomerByKunNr(String kun_nr) {
    Customer customer = getCustomerDAO().getCustomerByKunNr(kun_nr);
    return customer;
  }
View Full Code Here

    final ArrayList<Customer> customerList = new ArrayList<Customer>();
    final Set<Orderposition> orderpositionsSet = new HashSet<Orderposition>();
    final Set<Order> orderSet = new HashSet<Order>();

    // get the customer for this order
    final Customer customer = getCustomerService().getCustomerByOrder(anOrder);

    /* fill the orderPositionList */
    orderpositionsSet.addAll(getOrderService().getOrderpositionsByOrder(anOrder));

    // plug all together
    anOrder.setOrderpositions(orderpositionsSet);
    /* fill the orderList */
    orderSet.add(anOrder);

    customer.setOrders(orderSet);
    customerList.add(customer);

    return new JRBeanCollectionDataSource(customerList);
  }
View Full Code Here

  // ############################## Tests ##################################

  @Test
  @Transactional
  public void getNewCustomer() {
    Customer obj = getCustomerDAO().getNewCustomer();
    Assert.assertEquals("Not the expected result", Long.MIN_VALUE+1, obj.getId());
  }
View Full Code Here

  }

  @Test
  @Transactional
  public void getCustomerByID() {
    Customer obj = getCustomerDAO().getCustomerByID(new Long(20));
    Assert.assertEquals("Not the expected result", "MUELLER", obj.getKunMatchcode());
  }
View Full Code Here

  }

  @Test
  @Transactional
  public void getCustomerByKunNr() {
    Customer obj = getCustomerDAO().getCustomerByKunNr("20");
    Assert.assertEquals("Not the expected result", "MUELLER", obj.getKunMatchcode());
  }
View Full Code Here

  @Test
  @Transactional
  public void getCustomerByOrder() {
    Order anOrder = getOrderDAO().getOrderById(new Long(40));
    Customer result = getCustomerDAO().getCustomerByOrder(anOrder);
    Assert.assertEquals("Not the expected result", "MUELLER", result.getKunMatchcode());
  }
View Full Code Here

  }

  @Test
  @Transactional
  public void saveCustomer() {
    Customer entity = getCustomerDAO().getNewCustomer();
    entity.setOffice(getOfficeDAO().getOfficeById(new Long(1)));
    entity.setKunMatchcode("TEST-CUSTOMER");
    entity.setKunNr("TEST-123456");

    getCustomerDAO().save(entity);

    List<Customer> list = getCustomerDAO().getAllCustomers();
    for (Customer obj : list) {
      System.out.println(obj.getId() + " / " + obj.getKunMatchcode());
    }

    Customer obj2 = getCustomerDAO().getCustomerByKunNr("TEST-123456");
    Assert.assertEquals("Not the expected result", "TEST-CUSTOMER", obj2.getKunMatchcode());
  }
View Full Code Here

  }

  @Test
  @Transactional
  public void deleteCustomer() {
    Customer entity = getCustomerDAO().getNewCustomer();
    entity.setOffice(getOfficeDAO().getOfficeById(new Long(1)));
    entity.setKunMatchcode("TEST-CUSTOMER");
    entity.setKunNr("TEST-123456");

    getCustomerDAO().save(entity);

    long id = entity.getId();

    List<Customer> list = getCustomerDAO().getAllCustomers();
    for (Customer obj : list) {
      System.out.println(obj.getId() + " / " + obj.getKunMatchcode());
    }

    Customer obj2 = getCustomerDAO().getCustomerByKunNr("TEST-123456");
    Assert.assertEquals("Not the expected result", "TEST-CUSTOMER", obj2.getKunMatchcode());

    getCustomerDAO().delete(obj2);
  }
View Full Code Here

TOP

Related Classes of de.forsthaus.backend.model.Customer

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.