### Question:
VaadinPortletService extends VaadinService { private String getParameter(VaadinRequest request, String name, String defaultValue) { VaadinPortletRequest portletRequest = (VaadinPortletRequest) request; String preference = portletRequest.getPortletPreference(name); if (preference != null) { return preference; } String appOrSystemProperty = getAppOrSystemProperty(name, null); if (appOrSystemProperty != null) { return appOrSystemProperty; } String portalProperty = portletRequest.getPortalProperty(name); if (portalProperty != null) { if (name.equals(Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET)) { return mapDefaultWidgetset(portalProperty); } return portalProperty; } return defaultValue; } VaadinPortletService(VaadinPortlet portlet,
            DeploymentConfiguration deploymentConfiguration); VaadinPortlet getPortlet(); @Override String getConfiguredWidgetset(VaadinRequest request); @Override String getConfiguredTheme(VaadinRequest request); @Override boolean isStandalone(VaadinRequest request); @Override String getStaticFileLocation(VaadinRequest request); @Override String getMimeType(String resourceName); @Override File getBaseDirectory(); static PortletRequest getCurrentPortletRequest(); static VaadinPortletRequest getCurrentRequest(); static VaadinPortletResponse getCurrentResponse(); @Override String getServiceName(); @Override boolean preserveUIOnRefresh(UIProvider provider, UICreateEvent event); @Override InputStream getThemeResourceAsStream(UI uI, String themeName,
            String resource); @Override String getMainDivId(VaadinSession session, VaadinRequest request,
            Class<? extends UI> uiClass);  }### Answer:
@Test public void findUIDoesntThrowNPE() { try { ReentrantLock mockLock = Mockito.mock(ReentrantLock.class); when(mockLock.isHeldByCurrentThread()).thenReturn(true); WrappedSession emptyWrappedSession = Mockito .mock(WrappedPortletSession.class); when(emptyWrappedSession.getAttribute("null.lock")).thenReturn( mockLock); VaadinRequest requestWithUIIDSet = Mockito .mock(VaadinRequest.class); when(requestWithUIIDSet.getParameter(UIConstants.UI_ID_PARAMETER)) .thenReturn("1"); when(requestWithUIIDSet.getWrappedSession()).thenReturn( emptyWrappedSession); UI ui = sut.findUI(requestWithUIIDSet); Assert.assertNull("Unset session did not return null", ui); } catch (NullPointerException e) { Assert.fail("findUI threw a NullPointerException"); } }