@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); for (ProductItemCategory productItemCategory : productItem.getCategories()) { if (category.equals(productItemCategory.getCategoryCode())) return true; } return false; }
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); for (ProductItemCategory productItemCategory : productItem.getCategories()) { if (category.matcher(productItemCategory.getCategoryCode()).matches()) return true; } return false; }
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); for (ProductItemCategory productItemCategory : productItem.getCategories()) { if (category.equals(productItemCategory.getCategoryCode())) return true; } return false; }
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); for (ProductItemCategory productItemCategory : productItem.getCategories()) { if (category.matcher(productItemCategory.getCategoryCode()).matches()) return true; } return false; }
@Override public ProductItem apply(ProductItemPrice productItemPrice) { Set<ProductItemCategory> categories = productItemPrice.getCategories(); ProductItem item = productItemPrice.getItem(); ProductItem.Builder builder = productItemPrice.getItem().toBuilder(); if (item.getCategories().size() == 0 && categories.size() != 0) { builder.categories(categories); } return builder.build(); } };
@Override public ProductItem apply(ProductItemPrice productItemPrice) { Set<ProductItemCategory> categories = productItemPrice.getCategories(); ProductItem item = productItemPrice.getItem(); ProductItem.Builder builder = productItemPrice.getItem().toBuilder(); if (item.getCategories().size() == 0 && categories.size() != 0) { builder.categories(categories); } return builder.build(); } };
@Test public void testItemCallGetsCategory() { ProductItemPrice price = ProductItemPrice.builder().id(1) .categories(category) .item(item) .build(); ProductItem newItem = item().apply(price); assertEquals(newItem.getCategories(), ImmutableSet.of(category)); }
@Test public void testItemCallNoCategoryOnPrice() { ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category)).build(); ProductItemPrice price = ProductItemPrice.builder().id(1) .item(item1) .build(); ProductItem newItem = item().apply(price); assertEquals(newItem.getCategories(), ImmutableSet.of(category)); }
private void checkProductItem(ProductItem item) { assert item.getId() > 0 : item; assert item.getDescription() != null : item; checkCategories(item.getCategories()); // units and capacity may be null assertTrue(item.getPrices().size() >= 0); for (ProductItemPrice price : item.getPrices()) { // ProductItemPrice newDetails = // client.getProductItemPrice(prices.getId()); // assertEquals(item.getId(), newDetails.getId()); checkPrice(price); } }
@Test public void testItemCallCategoryExists() { ProductItemCategory category2 = ProductItemCategory.builder() .id(12) .categoryCode("new category") .build(); ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category2)).build(); ProductItemPrice price = ProductItemPrice.builder().id(1) .categories(category) .item(item1) .build(); ProductItem newItem = item().apply(price); assertEquals(newItem.getCategories(), ImmutableSet.of(category2)); }
public T fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .units(in.getUnits()) .capacity(in.getCapacity()) .prices(in.getPrices()) .categories(in.getCategories()); } }
public T fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .units(in.getUnits()) .capacity(in.getCapacity()) .prices(in.getPrices()) .categories(in.getCategories()); } }