@Test public void displayWithCustomTemplate() throws Exception { Template fakeTemplate = mock(Template.class); when(templateManager.getTemplate(any(String.class))).thenReturn(fakeTemplate); NotificationFilter filter = mock(NotificationFilter.class); when(filter.getName()).thenReturn("filterName"); mocker.getComponentUnderTest() .display(filter, mock(NotificationFilterPreference.class)); verify(templateManager, times(1)).execute(eq(fakeTemplate)); }
@Override public Block display(NotificationFilter filter, NotificationFilterPreference preference) throws NotificationException { try { setUpContext(scriptContextManager, filter, preference); String templateName = String.format("notification/filters/%s.vm", filter.getName().replaceAll("\\/", ".")); Template template = templateManager.getTemplate(templateName); return (template != null) ? templateManager.execute(template) : templateManager.execute("notification/filters/default.vm"); } catch (Exception e) { throw new NotificationException( String.format("Failed to display the notification filter [%s] with the filter preference [%s].", filter, preference), e); } finally { cleanUpContext(); } }
DefaultNotificationFilterDisplayer extends AbstractNotificationFilterDisplayer { @Override public Block display(NotificationFilter filter, NotificationFilterPreference preference) throws NotificationException { try { setUpContext(scriptContextManager, filter, preference); String templateName = String.format("notification/filters/%s.vm", filter.getName().replaceAll("\\/", ".")); Template template = templateManager.getTemplate(templateName); return (template != null) ? templateManager.execute(template) : templateManager.execute("notification/filters/default.vm"); } catch (Exception e) { throw new NotificationException( String.format("Failed to display the notification filter [%s] with the filter preference [%s].", filter, preference), e); } finally { cleanUpContext(); } } }
DefaultNotificationFilterDisplayer extends AbstractNotificationFilterDisplayer { @Override public Block display(NotificationFilter filter, NotificationFilterPreference preference) throws NotificationException { try { setUpContext(scriptContextManager, filter, preference); String templateName = String.format("notification/filters/%s.vm", filter.getName().replaceAll("\\/", ".")); Template template = templateManager.getTemplate(templateName); return (template != null) ? templateManager.execute(template) : templateManager.execute("notification/filters/default.vm"); } catch (Exception e) { throw new NotificationException( String.format("Failed to display the notification filter [%s] with the filter preference [%s].", filter, preference), e); } finally { cleanUpContext(); } }  }
DefaultNotificationFilterDisplayer extends AbstractNotificationFilterDisplayer { @Override public Block display(NotificationFilter filter, NotificationFilterPreference preference) throws NotificationException { try { setUpContext(scriptContextManager, filter, preference); String templateName = String.format("notification/filters/%s.vm", filter.getName().replaceAll("\\/", ".")); Template template = templateManager.getTemplate(templateName); return (template != null) ? templateManager.execute(template) : templateManager.execute("notification/filters/default.vm"); } catch (Exception e) { throw new NotificationException( String.format("Failed to display the notification filter [%s] with the filter preference [%s].", filter, preference), e); } finally { cleanUpContext(); } }  @Override Block display(NotificationFilter filter, NotificationFilterPreference preference); @Override Set<String> getSupportedFilters(); }
DefaultNotificationFilterDisplayer extends AbstractNotificationFilterDisplayer { @Override public Block display(NotificationFilter filter, NotificationFilterPreference preference) throws NotificationException { try { setUpContext(scriptContextManager, filter, preference); String templateName = String.format("notification/filters/%s.vm", filter.getName().replaceAll("\\/", ".")); Template template = templateManager.getTemplate(templateName); return (template != null) ? templateManager.execute(template) : templateManager.execute("notification/filters/default.vm"); } catch (Exception e) { throw new NotificationException( String.format("Failed to display the notification filter [%s] with the filter preference [%s].", filter, preference), e); } finally { cleanUpContext(); } }  @Override Block display(NotificationFilter filter, NotificationFilterPreference preference); @Override Set<String> getSupportedFilters();  }