### Question:
WmsMapElementHtmlHandler implements GenericElementHtmlHandler { @Override public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element) { Map<String, Object> contextMap = new HashMap<String, Object>(); contextMap.put("mapCanvasId", "map_canvas_" + element.hashCode()); if (context.getExporter() instanceof JRXhtmlExporter) { contextMap.put("xhtml", "xhtml"); JRXhtmlExporter xhtmlExporter = (JRXhtmlExporter) context.getExporter(); contextMap.put("elementX", xhtmlExporter.toSizeUnit(element.getX())); contextMap.put("elementY", xhtmlExporter.toSizeUnit(element.getY())); } else { JRHtmlExporter htmlExporter = (JRHtmlExporter) context.getExporter(); contextMap.put("elementX", htmlExporter.toSizeUnit(element.getX())); contextMap.put("elementY", htmlExporter.toSizeUnit(element.getY())); } contextMap.put("elementId", element.getKey()); contextMap.put("elementWidth", element.getWidth()); contextMap.put("elementHeight", element.getHeight()); if (element.getModeValue() == ModeEnum.OPAQUE) { contextMap.put("backgroundColor", JRColorUtil.getColorHexa(element.getBackcolor())); } WmsRequestBuilder requestBuilder = WmsMapElementImageProvider.mapRequestBuilder(element); try { contextMap.put("wmsMapUrl", requestBuilder.toMapUrl()); } catch (MalformedURLException e) { throw new RuntimeException("Unable to build WMS map service url", e); } return VelocityUtil.processTemplate(MAP_ELEMENT_HTML_TEMPLATE, contextMap); }  static WmsMapElementHtmlHandler getInstance(); @Override String getHtmlFragment(JRHtmlExporterContext context,
      JRGenericPrintElement element); @Override boolean toExport(JRGenericPrintElement element);  }### Answer:
@Ignore("Moved test from generic element") @Test public void testGetHtmlFragment() { JRGenericPrintElement element = mock(JRGenericPrintElement.class); when(element.getParameterNames()).thenReturn(parameters.keySet()); when(element.getParameterValue(WmsRequestParameter.WMS_URL.name())) .thenReturn(BASE_URL); when(element.getParameterValue(WmsRequestParameter.LAYERS.name())) .thenReturn("Hintergrund"); when(element.getParameterValue(WmsRequestParameter.BBOX.name())) .thenReturn("1,1,1,1"); when(element.getParameterValue(WmsRequestParameter.SRS_CRS.name())) .thenReturn("EPSG:21781"); when(element.getWidth()).thenReturn(100); when(element.getHeight()).thenReturn(100); String htmlFragment = handler.getHtmlFragment( mock(JRHtmlExporterContext.class), element); assertThat(htmlFragment, startsWith("<img ")); assertThat(htmlFragment, containsString(BASE_URL)); assertThat(htmlFragment, containsString("WIDTH=100")); assertThat(htmlFragment, containsString("HEIGHT=100")); }