@Test public void testChannelTemplate() throws Exception { Template template = cfg.getTemplate(getTemplatePath("channel.html")); Map<String, Object> params = new HashMap<String, Object>(); Site site = new Site(); site.setId(2L); params.put(GlobalVariable.SITE.toString(), site); Channel channel = new Channel(); channel.setId(1L); params.put(GlobalVariable.CHANNEL.getVariable(), channel); params.put(GlobalVariable.TASK_ID.getVariable(), "1111-2222-3333-4444"); String value = process(template, params); value = StringUtils.deleteWhitespace(value); Assert.assertEquals("test-channel-includetest-channel-includetest-channel-include", value); }
@SuppressWarnings("unchecked") @Test public void testCacheTemplate() throws Exception { Template template = cfg.getTemplate(getTemplatePath("cache.html")); Map<String, Object> params = new HashMap<String, Object>(); Site site = new Site(); site.setId(2L); params.put(GlobalVariable.SITE.toString(), site); Channel channel = new Channel(); channel.setId(1L); params.put(GlobalVariable.CHANNEL.getVariable(), channel); params.put(GlobalVariable.TASK_ID.getVariable(), "1111-2222-3333-4444"); includeCache = Mockito.mock(Cacheable.class); Mockito.when(includeCache.get(Mockito.anyString())).thenReturn("hello-cache"); params.put(GlobalVariable.INCLUDE_CACHE.getVariable(), includeCache); String value = process(template, params); value = StringUtils.deleteWhitespace(value); Assert.assertEquals("hello-cache", value); }