Examples of ProductWithCustomersDto


Examples of org.company.recordshop.service.dto.ProductWithCustomersDto

      final Map<Object, Object> translated) {
    if (translated.containsKey((source))) {
      return (ProductWithCustomersDto) translated.get(source);
    }
    Assert.notNull(source, "argument [source] may not be null");
    ProductWithCustomersDto result = new ProductWithCustomersDto(source
        .getId(), source.getVersion());
    result.setProductNumber(source.getProductNumber());
    result.setOrderable(source.isOrderable());
    result.setPrice(source.getPrice());

    translated.put(source, result);

    for (Customer element : source.getBuyers()) {
      result.addToBuyers(simpleCustomerDtoTranslator.toDto(element,
          translated));
    }

    return result;
  }
View Full Code Here

Examples of org.company.recordshop.service.dto.ProductWithCustomersDto

     * but this is for multiplicity ONE
     *
     */
    @Test
    public final void testAddExistingProduct() {
        ProductWithCustomersDto p001 = new ProductWithCustomersDto();
        p001.setProductNumber("p001");
        p001.setPrice(new Float(8));
        p001.setOrderable(true);
        ProductWithCustomersDto createdP001 = customerService
                .readProductAsProductWithCustomersDto(customerService.createProduct(p001));

        createdP001.addToBuyers(createdCustomer);
        customerService.updateProduct(createdP001);

        // JOS: The above is incorrect (just not to break the build)
        // The below should be run as a test and shows the error.
        FullProductDto fullProduct = customerService.readProductAsFullProductDto(createdP001
                .getId());
        OrderLineDto orderLine = new OrderLineDto();
        orderLine.setProduct(fullProduct);
        orderLine.setLineNumber(1);
        orderLine.setDescription("an orderline");
View Full Code Here

Examples of org.company.recordshop.service.dto.ProductWithCustomersDto

     * tries to add an existing Customer to a Product. Currently goes wrong !
     *
     */
    @Test
    public final void testAddExistingCustomer() {
        ProductWithCustomersDto p001 = new ProductWithCustomersDto();
        p001.setProductNumber("p001");
        p001.setPrice(new Float(8));
        p001.setOrderable(true);
        ProductWithCustomersDto createdP001 = customerService
                .readProductAsProductWithCustomersDto(customerService.createProduct(p001));

        // Comment the try below and uncomment the ones below that to get the
        // real test.
        // try {
        // createdP001.addToBuyers(createdCustomer);
        // ProductWithCustomersDto createdP002 =
        // customerServiceModelService.updateProduct(createdP001);
        // Assert.fail("Expecting Service Exception");
        // } catch (TranslatorException e) {
        // System.err.println("Expected exception: " + e.getMessage());
        // }

        // JOS: The above is incorrect (just not to break the build)
        // The below should be run as a test and shows the error.
        createdP001.addToBuyers(createdCustomer);
        customerService.updateProduct(createdP001);

        ProductWithCustomersDto stored = customerService
                .readProductAsProductWithCustomersDto(createdP001.getId());
        Assert.assertTrue("Number of customers should be one", stored.getBuyers().size() == 1);
        SimpleCustomerDto storedCustomer = stored.getFromBuyers(createdCustomer.getId());
        Assert.assertTrue("Customer should be there", storedCustomer != null);

        storedCustomer.setCustomerNr(9101);
        stored.addToBuyers(storedCustomer);
        customerService.updateProduct(stored);

        stored = customerService.readProductAsProductWithCustomersDto(createdP001.getId());
        Assert.assertTrue("Number of customers should be one", stored.getBuyers().size() == 1);
        storedCustomer = stored.getFromBuyers(createdCustomer.getId());
        Assert.assertTrue("Customer should be there", storedCustomer != null);
        Assert.assertTrue("Customer number inciiorrect", storedCustomer.getCustomerNr() == 9101);

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.