ClientCartHandler extends BaseHandler { public CartDto retrieveCart(UserDto clientUser) { Preconditions.checkNotNull(clientUser); Preconditions.checkNotNull(clientUser.getApiKey()); Preconditions.checkNotNull(clientUser.getSecretKey()); String path = String.format("/cart"); String hal = HalHmacResourceFactory.INSTANCE .newUserResource(locale, path, clientUser) .get(String.class); ReadableRepresentation rr = unmarshalHal(hal); Map<String, Object> properties = rr.getProperties(); return buildClientCart(rr, properties); } ClientCartHandler(Locale locale); CartDto retrieveCartNoItems(UserDto clientUser); CartDto retrieveCart(UserDto clientUser); CartDto updateCartItems(UserDto clientUser, List<PublicCartItemDto> cartItems); static CartDto buildClientCartNoItems(Map<String, Object> properties);  }
@Test public void retrieveCart() throws Exception { final CartDto expectedCart = new CartDto(); expectedCart.setItemTotal("2"); final UserDto clientUser = new UserDto(); clientUser.setApiKey("apiKey"); clientUser.setSecretKey("secretKey"); URI expectedUri = URI.create("http: when(client.resource(expectedUri)) .thenReturn(webResource); when(webResource.get(String.class)) .thenReturn(FixtureAsserts.jsonFixture("/fixtures/hal/cart/expected-public-retrieve-cart.json")); CartDto actualCart = PublicMerchantClient .newInstance(locale) .cart() .retrieveCart(clientUser); assertEquals("Unexpected item count", "2", actualCart.getItemTotal()); }