Package org.company.recordshop.domain

Examples of org.company.recordshop.domain.Customer


    orderDto.setOrderNumber("1");
    orderDto.setCustomer(simpleCust);

    simpleCust.addToOrders(orderDto);

    Customer newCust = simpleCustomerDtoTranslator.fromDto(simpleCust);
    assertEquals("Vincent", newCust.getFirstName());
    assertEquals(1234, newCust.getCustomerNr().intValue());
    assertEquals(1, newCust.getOrders().size());

  }
View Full Code Here


  }

  @Test
  public void testToDtoBiderectionalSucceed() {

    Customer cust = new Customer("Herman", "Bread", new DateTime(
        "2009-11-06"), 4321);
    Order order = new Order("1111");
    cust.addToOrders(order);

    SimpleCustomerDto customerDto = simpleCustomerDtoTranslator.toDto(cust);

    assertEquals(Integer.valueOf(4321), customerDto.getCustomerNr());
    assertFalse(customerDto.getOrders().isEmpty());
View Full Code Here

        "Vincent", "van Gogh", 1, new String[] { "1", "2" });

    /**
     * Translate it to a DO and check.
     */
    Customer customer = simpleCustomerDtoTranslator.fromDto(customerDto);
    checkCustomer(customer, new String[] { "1", "2" });

    /**
     * "Save" the customer and retrieve. Id's will be added to all domain
     * objects. Then transform to a DTO again.
View Full Code Here

      }
      return customerId;
    }

    public Customer get(Long id) throws Exception {
      Customer customer = customers.get(id);
      Customer result = new Customer(customer.getFirstName(), customer
          .getLastName(), customer.getBirthDate(), customer
          .getCustomerNr());
      setId(result, customer.getId());
      for (Order order : customer.getOrders()) {
        Order newOrder = new Order(order.getOrderNumber());
        setId(newOrder, order.getId());
        result.addToOrders(newOrder);
      }
      return result;
    }
View Full Code Here

    fullCustDto.setLastName("Van Gogh");
    fullCustDto.setCustomerNr(1234);
    fullCustDto.setBirthDate(new DateTime(2008, 1, 1, 1, 1, 0, 0));
    fullCustDto.setSexe(SexeEnumDto.MALE);

    Customer newCust = scTranslator.fromDto(fullCustDto);
    assertTrue("Firstname of Customer should be Vincent.", newCust
        .getFirstName().equals("Vincent"));
    assertTrue("CustomerNr should be 1234", newCust.getCustomerNr() == 1234);
    assertTrue(
        "Associations dto's in dto's are not translated so Orders should be empty.",
        newCust.getOrders().isEmpty());

  }
View Full Code Here

         */
        CustomerWithOrdersAndOrderLines dto = createCustomerDto(new String[] { "1", "2" }, new String[] { "3", "4" });
        /**
         * Translate it to a DO and check.
         */
        Customer created = customerWithOrdersAndOrderLinesTranslator.fromDto(dto);
        checkCustomer(created, new String[] { "1", "2" }, new String[] { "3", "4" });
        /**
         * "Save" the customer and retrieve. Id's will be added to all domain objects. Then transform to a DTO again.
         */
        Customer saved = repository.get(repository.save(created));
        dto = customerWithOrdersAndOrderLinesTranslator.toDto(saved);
        customerWithOrdersAndOrderLinesTranslator.fromDto(dto, saved);
        checkCustomer(saved, new String[] { "1", "2" }, new String[] { "3", "4" });

        /**
 
View Full Code Here

            }
            return customerId;
        }

        public Customer get(Long id) throws Exception {
            Customer customer = customers.get(id);
            Customer result = new Customer(customer.getFirstName(), customer.getLastName(), customer.getBirthDate(),
                    customer.getCustomerNr());
            setId(result, customer.getId());
            for (Order order : customer.getOrders()) {
                Order newOrder = new Order(order.getOrderNumber());
                setId(newOrder, order.getId());
                result.addToOrders(newOrder);
                for (OrderLine line : order.getOrderLines()) {
                    OrderLine newLine = new OrderLine(line.getLineNumber(), line.getDescription());
                    newLine.setProduct(line.getProduct());
                    setId(newLine, line.getId());
                    newOrder.addToOrderLines(newLine);
View Full Code Here

     * Customer with one ear must have a discountPercentage of 50.
     */
    @Test
    public void testOneEarDiscountSucceed() {
       
        Customer johannes = new Customer("Johannes", "Vermeer", date(), 1);
        johannes.setDiscountPercentage(0);
        johannes.setNumberOfEars(2);
        Customer vincent = new Customer("Vincent", "Van Gogh", date(), 1);
        vincent.setDiscountPercentage(50);
        vincent.setNumberOfEars(1);
        assertEquals(0, johannes.getDiscountPercentage().intValue());
        assertEquals(50, vincent.getDiscountPercentage().intValue());
    }
View Full Code Here

    }
   
    @Test
    public void testOneEarDiscountFail() {
       
        Customer customer = new Customer("Vincent", "Van Gogh", date(), 1);
              
        try {
            customer.setDiscountPercentage(0);
            customer.setNumberOfEars(1);
            fail("A discuontPercentage of 0 for a customer with one ear is not allowed.");
        } catch (BusinessRuleException e) {
            assertEquals(true, e.getMessage().contains("discountPercentage for Customers with one ear should be 50, but was 0"));
        }
    }
View Full Code Here

TOP

Related Classes of org.company.recordshop.domain.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.