DefaultResult extends AbstractResult { public Result include(String key, Object value) { if (logger.isDebugEnabled()) { logger.debug("including attribute {}: {}", key, value); } includedAttributes.put(key, value); request.setAttribute(key, value); return this; } DefaultResult(); @Inject  DefaultResult(HttpServletRequest request, Container container, ExceptionMapper exceptions, TypeNameExtractor extractor); T use(Class<T> view); Result on(Class<? extends Exception> exception); Result include(String key, Object value); boolean used(); Map<String, Object> included(); Result include(Object value);  }
@Test public void shouldSetRequestAttribute() { result.include("my_key", "my_value"); verify(request).setAttribute("my_key", "my_value"); }
@Test public void shouldIncludeExtractedNameWhenSimplyIncluding() throws Exception { Account account = new Account(); when(extractor.nameFor(Account.class)).thenReturn("account"); result.include(account); verify(request).setAttribute("account", account); }
@Test public void shouldNotIncludeTheAttributeWhenTheValueIsNull() throws Exception { result.include(null); verify(request, never()).setAttribute(anyString(), anyObject()); }