ModuleController { @RequestMapping(value = "/module/icon", method = RequestMethod.GET) public void getBundleIcon(@RequestParam(required = false) Long bundleId, @RequestParam(required = false) String bundleName, @RequestParam(required = false) String defaultIcon, HttpServletResponse response) throws IOException { BundleIcon bundleIcon; if(bundleId != null) { bundleIcon = bundleIconService.getBundleIconById(bundleId, defaultIcon); } else { bundleIcon = bundleIconService.getBundleIconByName(bundleName, defaultIcon); } response.setStatus(HttpServletResponse.SC_OK); response.setContentLength(bundleIcon.getContentLength()); response.setContentType(bundleIcon.getMime()); response.getOutputStream().write(bundleIcon.getIcon()); }  @RequestMapping(value = "/module/critical/{moduleName}", method = RequestMethod.GET) @ResponseBody String getCriticalMessage(@PathVariable String moduleName); @RequestMapping(value = "/module/menu", method = RequestMethod.GET) @ResponseBody ModuleMenu getMenu(HttpServletRequest request); @RequestMapping(value = "/module/config", method = RequestMethod.GET) @ResponseBody List<ModuleConfig> getConfig(); @RequestMapping(value = "/module/icon", method = RequestMethod.GET) void getBundleIcon(@RequestParam(required = false) Long bundleId,
                              @RequestParam(required = false) String bundleName,
                              @RequestParam(required = false) String defaultIcon,
                              HttpServletResponse response); @RequestMapping(value = "/module/rest-docs/{moduleName}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody String getRestDocsUrl(@PathVariable String moduleName); UserInfo getUser(HttpServletRequest request); @Autowired void setUiFrameworkService(UIFrameworkService uiFrameworkService); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setLocaleService(LocaleService localeService); @Autowired void setBundleIconService(BundleIconService bundleIconService); @Autowired void setMenuBuilder(MenuBuilder menuBuilder);  }
@Test public void shouldGetBundleIcon() throws IOException { BundleIcon bundleIcon = new BundleIcon(new byte[] {1, 2, 3, 4}, ICON_MIME); when(bundleIconService.getBundleIconById(BUNDLE_ID, null)).thenReturn(bundleIcon); when(response.getOutputStream()).thenReturn(outputStream); moduleController.getBundleIcon(BUNDLE_ID, null, null, response); verify(response).setStatus(HttpServletResponse.SC_OK); verify(response).setContentLength(bundleIcon.getContentLength()); verify(response).setContentType(bundleIcon.getMime()); verify(response).getOutputStream(); verify(outputStream).write(bundleIcon.getIcon()); }