ScopedCSSVariablesTopHeadDynamicInclude extends BaseDynamicInclude { @Override public void include( HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String dynamicIncludeKey) throws IOException { PrintWriter printWriter = httpServletResponse.getWriter(); printWriter.print("<style data-senna-track=\"temporary\" "); printWriter.print("type=\"text/css\">\n"); for (ScopedCSSVariablesProvider scopedCSSVariablesProvider : _scopedCSSVariablesProviders) { _writeCSSVariables( printWriter, scopedCSSVariablesProvider.getScopedCSSVariablesCollection( httpServletRequest)); } printWriter.print("</style>\n"); }  @Override void include(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse, String dynamicIncludeKey); @Override void register(DynamicIncludeRegistry dynamicIncludeRegistry);  }
@Test public void testInclude() throws IOException { ScopedCSSVariablesTopHeadDynamicInclude scopedCSSVariablesTopHeadDynamicInclude = new ScopedCSSVariablesTopHeadDynamicInclude(); ScopedCSSVariablesProvider scopedCSSVariablesProvider = Mockito.mock( ScopedCSSVariablesProvider.class); Collection<ScopedCSSVariables> scopedCSSVariables = Arrays.asList( new ScopedCSSVariables() { @Override public Map<String, String> getCSSVariables() { return Collections.singletonMap("color", "red"); } @Override public String getScope() { return ":root"; } }); Mockito.when( scopedCSSVariablesProvider.getScopedCSSVariablesCollection( Mockito.any(HttpServletRequest.class)) ).thenReturn( scopedCSSVariables ); scopedCSSVariablesTopHeadDynamicInclude.setScopedCSSVariablesProviders( Arrays.asList(scopedCSSVariablesProvider)); HttpServletRequest httpServletRequest = Mockito.mock( HttpServletRequest.class); HttpServletResponse httpServletResponse = Mockito.mock( HttpServletResponse.class); BufferCacheServletResponse bufferCacheServletResponse = new BufferCacheServletResponse(httpServletResponse); scopedCSSVariablesTopHeadDynamicInclude.include( httpServletRequest, bufferCacheServletResponse, "/html/common/themes/top_head.jsp#post"); Assert.assertEquals( _read("liferay_css_variables_1.html", true), bufferCacheServletResponse.getString()); }