@Test public void testReferencesForPurchasedInCategory() { final UserModel user = userService.getUserForUID("dejol"); final CategoryModel category = categoryService.getCategoryForCode("cameras"); List<ProductModel> result = b2bSimpleSuggestionService.getReferencesForPurchasedInCategory( category, user, Collections.EMPTY_LIST, false, null); Assert.assertEquals(4, result.size()); result = b2bSimpleSuggestionService.getReferencesForPurchasedInCategory( category, user, Collections.EMPTY_LIST, false, NumberUtils.INTEGER_ONE); Assert.assertEquals(1, result.size()); result = b2bSimpleSuggestionService.getReferencesForPurchasedInCategory( category, user, Arrays.asList(ProductReferenceTypeEnum.SIMILAR), false, null); Assert.assertEquals(1, result.size()); result = b2bSimpleSuggestionService.getReferencesForPurchasedInCategory( category, user, Arrays.asList(ProductReferenceTypeEnum.ACCESSORIES), false, null); Assert.assertEquals(2, result.size()); result = b2bSimpleSuggestionService.getReferencesForPurchasedInCategory( category, user, Arrays.asList(ProductReferenceTypeEnum.ACCESSORIES), true, null); Assert.assertEquals(1, result.size()); final ProductModel product = result.get(0); Assert.assertEquals("adapterDC", product.getCode()); Assert.assertEquals("adapter", product.getName()); }
@Override public void populate(final ProductModel source, final ProductData target) { Assert.notNull(source, "Parameter source cannot be null."); Assert.notNull(target, "Parameter target cannot be null."); target.setCode(source.getCode()); target.setName(source.getName()); target.setUrl(getProductModelUrlResolver().resolve(source)); }