### Question:
VaadinPortletRequest extends PortletRequestWrapper implements
        VaadinRequest { public String getPortletPreference(String name) { PortletRequest request = getRequest(); PortletPreferences preferences = request.getPreferences(); return preferences.getValue(name, null); } VaadinPortletRequest(PortletRequest request,
            VaadinPortletService vaadinService); @Override int getContentLength(); @Override InputStream getInputStream(); @Override BufferedReader getReader(); @Override String getPathInfo(); @Override WrappedSession getWrappedSession(); @Override WrappedSession getWrappedSession(boolean allowSessionCreation); PortletRequest getPortletRequest(); @Override String getContentType(); @Override String getCharacterEncoding(); @Override String getMethod(); @Override String getRemoteAddr(); @Override String getRemoteHost(); @Override int getRemotePort(); @Override String getHeader(String string); String getPortalProperty(String name); String getPortletPreference(String name); @Override VaadinPortletService getService(); @Override long getDateHeader(String name); @Override Enumeration<String> getHeaderNames(); @Override Enumeration<String> getHeaders(String name); static PortletRequest getCurrentPortletRequest(); static VaadinPortletRequest getCurrent();  }### Answer:
@Test public void portletPreferenceIsFetched() { when(preferences.getValue(eq("foo"), anyString())).thenReturn("bar"); String value = sut.getPortletPreference("foo"); assertThat(value, is("bar")); }
@Test public void defaultValueForPortletPreferenceIsNull() { when(preferences.getValue(anyString(), isNull(String.class))) .thenReturn(null); String value = sut.getPortletPreference("foo"); assertNull(value); }