@Test public void testGetShopSupportedCustomerTypesI18n() throws Exception { final Shop shop = context.mock(Shop.class); final AttrValueShop av = context.mock(AttrValueShop.class); context.checking(new Expectations() {{ oneOf(shop).getAttributeByCode(AttributeNamesKeys.Shop.SHOP_CUSTOMER_TYPES); will(returnValue(av)); allowing(av).getVal(); will(returnValue("B2B,B2C")); allowing(av).getDisplayVal(); will(returnValue(new StringI18NModel("en#~#Private#~#de#~#Private DE,Company DE"))); }}); final List<Pair<String, I18NModel>> types = new ShopCustomerCustomisationSupportImpl(null, null).getSupportedCustomerTypes(shop); assertNotNull(types); assertEquals(2, types.size()); assertEquals("B2B", types.get(0).getFirst()); assertEquals("Private", types.get(0).getSecond().getValue("en")); assertEquals("Private DE", types.get(0).getSecond().getValue("de")); assertEquals("B2C", types.get(1).getFirst()); assertEquals("B2C", types.get(1).getSecond().getValue("en")); assertEquals("Company DE", types.get(1).getSecond().getValue("de")); context.assertIsSatisfied(); }
@Override public List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop) { final AttrValue av = getShopCustomerTypes(shop); if (av != null && StringUtils.isNotBlank(av.getVal())) { final String[] types = StringUtils.split(av.getVal(), ','); final I18NModel model = new StringI18NModel(av.getDisplayVal()); final Map<String, String[]> values = new HashMap<>(); for (final Map.Entry<String, String> displayValues : model.getAllValues().entrySet()) { values.put(displayValues.getKey(), StringUtils.split(displayValues.getValue(), ',')); } final List<Pair<String, I18NModel>> out = new ArrayList<>(types.length); for (int i = 0; i < types.length; i++) { final String type = types[i].trim(); final Map<String, String> names = new HashMap<>(); for (final Map.Entry<String, String[]> entry : values.entrySet()) { if (entry.getValue().length > i) { names.put(entry.getKey(), entry.getValue()[i]); } } out.add(new Pair<>(type, new FailoverStringI18NModel(names, type))); } return out; } return Collections.emptyList(); }
ShopCustomerCustomisationSupportImpl implements CustomerCustomisationSupport { @Override public List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop) { final AttrValue av = getShopCustomerTypes(shop); if (av != null && StringUtils.isNotBlank(av.getVal())) { final String[] types = StringUtils.split(av.getVal(), ','); final I18NModel model = new StringI18NModel(av.getDisplayVal()); final Map<String, String[]> values = new HashMap<>(); for (final Map.Entry<String, String> displayValues : model.getAllValues().entrySet()) { values.put(displayValues.getKey(), StringUtils.split(displayValues.getValue(), ',')); } final List<Pair<String, I18NModel>> out = new ArrayList<>(types.length); for (int i = 0; i < types.length; i++) { final String type = types[i].trim(); final Map<String, String> names = new HashMap<>(); for (final Map.Entry<String, String[]> entry : values.entrySet()) { if (entry.getValue().length > i) { names.put(entry.getKey(), entry.getValue()[i]); } } out.add(new Pair<>(type, new FailoverStringI18NModel(names, type))); } return out; } return Collections.emptyList(); } }
ShopCustomerCustomisationSupportImpl implements CustomerCustomisationSupport { @Override public List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop) { final AttrValue av = getShopCustomerTypes(shop); if (av != null && StringUtils.isNotBlank(av.getVal())) { final String[] types = StringUtils.split(av.getVal(), ','); final I18NModel model = new StringI18NModel(av.getDisplayVal()); final Map<String, String[]> values = new HashMap<>(); for (final Map.Entry<String, String> displayValues : model.getAllValues().entrySet()) { values.put(displayValues.getKey(), StringUtils.split(displayValues.getValue(), ',')); } final List<Pair<String, I18NModel>> out = new ArrayList<>(types.length); for (int i = 0; i < types.length; i++) { final String type = types[i].trim(); final Map<String, String> names = new HashMap<>(); for (final Map.Entry<String, String[]> entry : values.entrySet()) { if (entry.getValue().length > i) { names.put(entry.getKey(), entry.getValue()[i]); } } out.add(new Pair<>(type, new FailoverStringI18NModel(names, type))); } return out; } return Collections.emptyList(); } ShopCustomerCustomisationSupportImpl(final CustomerService customerService,
                                                final AttributeService attributeService); }
ShopCustomerCustomisationSupportImpl implements CustomerCustomisationSupport { @Override public List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop) { final AttrValue av = getShopCustomerTypes(shop); if (av != null && StringUtils.isNotBlank(av.getVal())) { final String[] types = StringUtils.split(av.getVal(), ','); final I18NModel model = new StringI18NModel(av.getDisplayVal()); final Map<String, String[]> values = new HashMap<>(); for (final Map.Entry<String, String> displayValues : model.getAllValues().entrySet()) { values.put(displayValues.getKey(), StringUtils.split(displayValues.getValue(), ',')); } final List<Pair<String, I18NModel>> out = new ArrayList<>(types.length); for (int i = 0; i < types.length; i++) { final String type = types[i].trim(); final Map<String, String> names = new HashMap<>(); for (final Map.Entry<String, String[]> entry : values.entrySet()) { if (entry.getValue().length > i) { names.put(entry.getKey(), entry.getValue()[i]); } } out.add(new Pair<>(type, new FailoverStringI18NModel(names, type))); } return out; } return Collections.emptyList(); } ShopCustomerCustomisationSupportImpl(final CustomerService customerService,
                                                final AttributeService attributeService); @Override String getGuestCustomerType(final Shop shop); @Override Set<String> getCustomerTypes(final Shop shop, final boolean includeGuest); @Override List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop); @Override boolean isGuestCheckoutSupported(final Shop shop); @Override boolean isCustomerTypeSupported(final Shop shop, final String customerType); @Override List<String> getSupportedRegistrationFormAttributesAsList(final Shop shop, final String customerType); @Override List<AttrValueWithAttribute> getRegistrationAttributes(final Shop shop, final String customerType); @Override List<AttrValueWithAttribute> getRegistrationAttributes(final Shop shop, final String customerType, final boolean force); @Override List<String> getSupportedProfileFormAttributesAsList(final Shop shop, final String customerType); @Override List<String> getSupportedProfileFormReadOnlyAttributesAsList(final Shop shop, final String customerType); @Override List<Pair<AttrValueWithAttribute, Boolean>> getProfileAttributes(final Shop shop, final Customer customer); }
ShopCustomerCustomisationSupportImpl implements CustomerCustomisationSupport { @Override public List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop) { final AttrValue av = getShopCustomerTypes(shop); if (av != null && StringUtils.isNotBlank(av.getVal())) { final String[] types = StringUtils.split(av.getVal(), ','); final I18NModel model = new StringI18NModel(av.getDisplayVal()); final Map<String, String[]> values = new HashMap<>(); for (final Map.Entry<String, String> displayValues : model.getAllValues().entrySet()) { values.put(displayValues.getKey(), StringUtils.split(displayValues.getValue(), ',')); } final List<Pair<String, I18NModel>> out = new ArrayList<>(types.length); for (int i = 0; i < types.length; i++) { final String type = types[i].trim(); final Map<String, String> names = new HashMap<>(); for (final Map.Entry<String, String[]> entry : values.entrySet()) { if (entry.getValue().length > i) { names.put(entry.getKey(), entry.getValue()[i]); } } out.add(new Pair<>(type, new FailoverStringI18NModel(names, type))); } return out; } return Collections.emptyList(); } ShopCustomerCustomisationSupportImpl(final CustomerService customerService,
                                                final AttributeService attributeService); @Override String getGuestCustomerType(final Shop shop); @Override Set<String> getCustomerTypes(final Shop shop, final boolean includeGuest); @Override List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop); @Override boolean isGuestCheckoutSupported(final Shop shop); @Override boolean isCustomerTypeSupported(final Shop shop, final String customerType); @Override List<String> getSupportedRegistrationFormAttributesAsList(final Shop shop, final String customerType); @Override List<AttrValueWithAttribute> getRegistrationAttributes(final Shop shop, final String customerType); @Override List<AttrValueWithAttribute> getRegistrationAttributes(final Shop shop, final String customerType, final boolean force); @Override List<String> getSupportedProfileFormAttributesAsList(final Shop shop, final String customerType); @Override List<String> getSupportedProfileFormReadOnlyAttributesAsList(final Shop shop, final String customerType); @Override List<Pair<AttrValueWithAttribute, Boolean>> getProfileAttributes(final Shop shop, final Customer customer);  }