@Test public void testCreateVelocityContextInjectsStoreInfo() { // Given emailProperties.setStoreCode(store.getCode()); store.setUrl("/snap-it-up/"); // When Map<String, Object> context = contextFactory.createVelocityContext(store, emailProperties); // Then assertSame("Context should include store", store, context.get("store")); assertEquals("Context should include store url", store.getUrl(), context.get("baseImgUrl")); assertEquals( "Context should include trimmed store url", "/snap-it-up", context.get("storeUrl")); }
@Before public void setUp() throws Exception { context.setImposteriser(ClassImposteriser.INSTANCE); beanFactory = context.mock(BeanFactory.class); BeanFactoryExpectationsFactory bfef = new BeanFactoryExpectationsFactory(context, beanFactory); bfef.allowingBeanFactoryGetBean(ContextIdNames.SEO_URL_BUILDER, SeoUrlBuilderImpl.class); geography = context.mock(Geography.class); moneyFormatter = context.mock(MoneyFormatter.class); storeThemeMessageSource = context.mock(StoreThemeMessageSource.class); contextFactory = new EmailContextFactoryImpl(); contextFactory.setGeography(geography); contextFactory.setMoneyFormatter(moneyFormatter); contextFactory.setStoreThemeMessageSource(storeThemeMessageSource); store = new StoreImpl(); store.setCode("store"); emailProperties = new EmailPropertiesImpl(); }