@Test public void test() { final FhCategoryData categoryData = new FhCategoryData(); categoryPopulator.populate(source2, categoryData); assertEquals("cat2", categoryData.getCategoryId()); assertEquals("cat1", categoryData.getParentId()); for (final Locale loc : localesEnDe) { assertEquals("name2" + loc.toString(), categoryData.getNames().get(loc)); } }
@Override public void populate(final ItemToConvert<CategoryModel> source, final FhCategoryData target) throws ConversionException { Preconditions.checkArgument(source != null); Preconditions.checkArgument(target != null); final CategoryModel category = source.getItem(); final Set<Locale> locales = source.getIndexConfig().getLocales(); target.setCategoryId(getSanitizeIdStrategy().sanitizeId(category.getCode())); target.setNames(mapNames(category, locales)); final Optional<CategoryModel> parent = parentCategoryResolver.resolve(category); if (parent.isPresent()) { target.setParentId(getSanitizeIdStrategy().sanitizeId(parent.get().getCode())); } }
CategoryPopulator implements Populator<ItemToConvert<CategoryModel>, FhCategoryData> { @Override public void populate(final ItemToConvert<CategoryModel> source, final FhCategoryData target) throws ConversionException { Preconditions.checkArgument(source != null); Preconditions.checkArgument(target != null); final CategoryModel category = source.getItem(); final Set<Locale> locales = source.getIndexConfig().getLocales(); target.setCategoryId(getSanitizeIdStrategy().sanitizeId(category.getCode())); target.setNames(mapNames(category, locales)); final Optional<CategoryModel> parent = parentCategoryResolver.resolve(category); if (parent.isPresent()) { target.setParentId(getSanitizeIdStrategy().sanitizeId(parent.get().getCode())); } } }
CategoryPopulator implements Populator<ItemToConvert<CategoryModel>, FhCategoryData> { @Override public void populate(final ItemToConvert<CategoryModel> source, final FhCategoryData target) throws ConversionException { Preconditions.checkArgument(source != null); Preconditions.checkArgument(target != null); final CategoryModel category = source.getItem(); final Set<Locale> locales = source.getIndexConfig().getLocales(); target.setCategoryId(getSanitizeIdStrategy().sanitizeId(category.getCode())); target.setNames(mapNames(category, locales)); final Optional<CategoryModel> parent = parentCategoryResolver.resolve(category); if (parent.isPresent()) { target.setParentId(getSanitizeIdStrategy().sanitizeId(parent.get().getCode())); } }  }
CategoryPopulator implements Populator<ItemToConvert<CategoryModel>, FhCategoryData> { @Override public void populate(final ItemToConvert<CategoryModel> source, final FhCategoryData target) throws ConversionException { Preconditions.checkArgument(source != null); Preconditions.checkArgument(target != null); final CategoryModel category = source.getItem(); final Set<Locale> locales = source.getIndexConfig().getLocales(); target.setCategoryId(getSanitizeIdStrategy().sanitizeId(category.getCode())); target.setNames(mapNames(category, locales)); final Optional<CategoryModel> parent = parentCategoryResolver.resolve(category); if (parent.isPresent()) { target.setParentId(getSanitizeIdStrategy().sanitizeId(parent.get().getCode())); } }  @Override void populate(final ItemToConvert<CategoryModel> source, final FhCategoryData target); ParentCategoryResolver getParentCategoryResolver(); @Required void setParentCategoryResolver(final ParentCategoryResolver parentCategoryResolver); SanitizeIdStrategy getSanitizeIdStrategy(); @Required void setSanitizeIdStrategy(final SanitizeIdStrategy sanitizeIdStrategy); }
CategoryPopulator implements Populator<ItemToConvert<CategoryModel>, FhCategoryData> { @Override public void populate(final ItemToConvert<CategoryModel> source, final FhCategoryData target) throws ConversionException { Preconditions.checkArgument(source != null); Preconditions.checkArgument(target != null); final CategoryModel category = source.getItem(); final Set<Locale> locales = source.getIndexConfig().getLocales(); target.setCategoryId(getSanitizeIdStrategy().sanitizeId(category.getCode())); target.setNames(mapNames(category, locales)); final Optional<CategoryModel> parent = parentCategoryResolver.resolve(category); if (parent.isPresent()) { target.setParentId(getSanitizeIdStrategy().sanitizeId(parent.get().getCode())); } }  @Override void populate(final ItemToConvert<CategoryModel> source, final FhCategoryData target); ParentCategoryResolver getParentCategoryResolver(); @Required void setParentCategoryResolver(final ParentCategoryResolver parentCategoryResolver); SanitizeIdStrategy getSanitizeIdStrategy(); @Required void setSanitizeIdStrategy(final SanitizeIdStrategy sanitizeIdStrategy);  }