PrintServiceImpl implements PrintService { public List<PrintTemplate> getAllTemplates() throws PrintingException { List<PrintTemplate> allTemplates = new ArrayList<PrintTemplate>(); if (printTemplateDao != null) { try { allTemplates = printTemplateDao.findAll(); } catch (IOException e) { log.warn("could not access templates in dao", e); } } allTemplates.addAll(getDefaults()); List<PrintTemplate> badTemplates = new ArrayList<PrintTemplate>(); for (PrintTemplate printTemplate : allTemplates) { if (printTemplate.getPage() == null) { try { Object o = unMarshaller.unmarshal(new StreamSource(new StringReader(printTemplate.getPageXml()))); printTemplate.setPage((PageComponentImpl) o); } catch (Exception e) { badTemplates.add(printTemplate); } } } allTemplates.removeAll(badTemplates); Collections.sort(allTemplates, new Comparator<PrintTemplate>() { public int compare(PrintTemplate p1, PrintTemplate p2) { return p1.getName().compareTo(p2.getName()); } }); return allTemplates; }  List<PrintTemplate> getAllTemplates(); PrintTemplate createDefaultTemplate(String pageSize, boolean landscape); void saveOrUpdateTemplate(PrintTemplate template); String putDocument(Document document); Document removeDocument(String key); PrintTemplate createTemplate(String pageSize, boolean landscape); int getJaiTileCacheInMb(); @Api @Deprecated void setJaiTileCacheInMB(int jaiTileCacheInMb); @Api void setJaiTileCacheInMb(int jaiTileCacheInMb);  }
@Test public void testGetAllTemplates() throws Exception { List<PrintTemplate> templates = printService.getAllTemplates(); Assert.assertEquals(11, templates.size()); }