Package org.multibit.mbm.client.domain.model.model

Examples of org.multibit.mbm.client.domain.model.model.Cart


    Customer customer = publicUser.getCustomer();
    customer.setId(1L);

    // Configure the Cart with Items
    Cart customerCart = customer.getCart();
    customerCart.setId(1L);

    Item book1 = DatabaseLoader.buildBookItemCryptonomicon();
    book1.setId(1L);
    Item book2 = DatabaseLoader.buildBookItemQuantumThief();
    book2.setId(2L);
    Item book3 = DatabaseLoader.buildBookItemCompleteWorks();
    book3.setId(3L);
    Item book4 = DatabaseLoader.buildBookItemPlumbing();
    book4.setId(4L);

    // Include some books into the Customer Cart
    customerCart.setItemQuantity(book1,1);
    customerCart.setItemQuantity(book2,2);

    // Configure Cart DAO
    when(cartDao.saveOrUpdate(customerCart)).thenReturn(customerCart);

    // Configure Item DAO
View Full Code Here


    bobUser.setId(2L);
    bobUser.getCustomer().setId(2L);
    bobUser.getCustomer().getCart().setId(2L);

    // Configure Alice's Cart with Items
    Cart aliceCart = aliceUser.getCustomer().getCart();

    Item book1 = DatabaseLoader.buildBookItemCryptonomicon();
    book1.setId(1L);
    Item book2 = DatabaseLoader.buildBookItemQuantumThief();
    book2.setId(2L);

    aliceCart.setItemQuantity(book1, 1);
    aliceCart.setItemQuantity(book2, 2);

    // Configure Bob's Cart with Items
    Cart bobCart = bobUser.getCustomer().getCart();

    Item book3 = DatabaseLoader.buildBookItemCompleteWorks();
    book3.setId(3L);
    Item book4 = DatabaseLoader.buildBookItemPlumbing();
    book4.setId(4L);

    bobCart.setItemQuantity(book3, 3);
    bobCart.setItemQuantity(book4, 4);

    // Create some mock results
    List<Cart> cartList1 = Lists.newArrayList(aliceCart);
    List<Cart> cartList2 = Lists.newArrayList(bobCart);

    PaginatedList<Cart> page1 = PaginatedLists.newPaginatedArrayList(1, 2, 1, cartList1);
    PaginatedList<Cart> page2 = PaginatedLists.newPaginatedArrayList(2, 2, 1, cartList2);

    // Configure Cart DAO

    when(cartDao.getById(aliceCart.getId())).thenReturn(Optional.of(aliceCart));
    when(cartDao.getById(bobCart.getId())).thenReturn(Optional.of(bobCart));
    when(cartDao.getPaginatedList(1, 1)).thenReturn(page1);
    when(cartDao.getPaginatedList(1, 2)).thenReturn(page2);
    when(cartDao.saveOrUpdate(aliceCart)).thenReturn(aliceCart);
    when(cartDao.saveOrUpdate(bobCart)).thenReturn(bobCart);
View Full Code Here

  @Override
  public Optional<Cart> getInitialisedCartByCustomer(Customer customer) {
    Preconditions.checkNotNull(customer, "customer cannot be null");

    Cart cart = customer.getCart();
    if (cart == null) {
      // Create a suitable cart
      cart = CartBuilder.newInstance()
        .build();
      customer.setCart(cart);
View Full Code Here

    User publicUser) {

    // Validation
    Preconditions.checkNotNull(publicUser.getCustomer(), "customer");

    Cart cart = publicUser.getCustomer().getCart();

    Representation representation = new PublicCartRepresentation().get(cart);

    return ok(representation);
View Full Code Here

    @RestrictedTo({Authority.ROLE_PUBLIC})
    User publicUser,
    UpdateCartDto updateCartRequest) {

    // Retrieve the cart
    Cart cart = publicUser.getCustomer().getCart();

    // Verify and apply any changes to the Cart
    apply(updateCartRequest,cart);

    // Persist the updated cart
View Full Code Here

    // Retrieve the cart
    Optional<Cart> cartOptional = cartDao.getById(cartId);
    ResourceAsserts.assertPresent(cartOptional,"cart");

    // Verify and apply any changes to the Cart
    Cart cart = cartOptional.get();
    apply(updateCartRequest,cart);

    // Persist the updated cart
    cart = cartDao.saveOrUpdate(cart);
View Full Code Here

TOP

Related Classes of org.multibit.mbm.client.domain.model.model.Cart

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.