Example usage for com.liferay.portal.model.impl UserImpl UserImpl

List of usage examples for com.liferay.portal.model.impl UserImpl UserImpl

Introduction

In this page you can find the example usage for com.liferay.portal.model.impl UserImpl UserImpl.

Prototype

UserImpl

Source Link

Usage

From source file:com.liferay.portlet.salesportlet.ShoppingCartInMemoryImplTest.java

License:Open Source License

@Test
public void testWhenCheckoutSucceeds_updateUser() throws Exception {
    long userId = 456;

    mockStatic(UserLocalServiceUtil.class);
    when(UserLocalServiceUtil.getUser(userId)).thenReturn(new UserImpl());

    Item one = new Item("item1", 20.00);
    Item two = new Item("item2", 35.00);

    ShoppingCartInMemoryImpl cart = new ShoppingCartInMemoryImpl(userId);
    cart.addItem(one);//from w  ww . j a  v  a 2  s  .co  m
    cart.addItem(two);

    cart.checkout();
    //Note: should validate sales receipt as well

    User user = UserLocalServiceUtil.getUser(userId);
    Assert.assertEquals(PortletConstants.PREMIUM_CUSTOMER, user.getComments());

    verifyStatic();
}

From source file:com.liferay.portlet.salesportlet.ShoppingCartInMemoryImplTest.java

License:Open Source License

@Test(expected = PortalException.class)
public void testCheckoutFailsForEmptyCart() throws Exception {

    long userId = 456;

    mockStatic(UserLocalServiceUtil.class);
    when(UserLocalServiceUtil.getUser(userId)).thenReturn(new UserImpl());

    ShoppingCartInMemoryImpl cart = new ShoppingCartInMemoryImpl(userId);

    //Intentionally don't add any items

    cart.checkout();//from www . j av a 2 s . c  o  m

    verifyStatic();
}