BBCodeServiceImpl implements Startable, BBCodeService, ManagementAware { public List<BBCode> getAll() throws Exception { SessionProvider sProvider = SessionProvider.createSystemProvider(); List<BBCode> bbcodes = new ArrayList<BBCode>(); try { Node bbCodeHome = getBBcodeHome(sProvider); NodeIterator iter = bbCodeHome.getNodes(); while (iter.hasNext()) { try { Node bbcNode = iter.nextNode(); bbcodes.add(nodeToBBCode(bbcNode)); } catch (Exception e) { log.error("Error loading BBCodes", e); } } } finally { sProvider.close(); } return bbcodes; } BBCodeServiceImpl();  BBCodeServiceImpl(KSDataLocation dataLocator); void registerBBCodePlugin(BBCodePlugin plugin); void initDefaultBBCodes(); void save(List<BBCode> bbcodes); List<BBCode> getAll(); List<String> getActive(); BBCode findById(String id); void delete(String bbcodeId); void start(); void stop(); void setContext(ManagementContext context); KSDataLocation getDataLocator(); void setDataLocator(KSDataLocation dataLocator); List<BBCodePlugin> getPlugins(); void setPlugins(List<BBCodePlugin> plugins); final static String BBCODE_NODE_TYPE; final static String BBCODE_HOME_NODE_TYPE; }
@Test public void testGetAll() throws Exception { List<BBCode> bbcodes = new ArrayList<BBCode>(); bbcodes.add(createBBCode("foo", "replacement", "description", "example", false, true)); bbcodes.add(createBBCode("foo", "replacement", "description", "example", true, false)); bbcodes.add(createBBCode("foo2", "replacement", "description", "example", false, true)); bbcodes.add(createBBCode("foo3", "replacement", "description", "example", false, true)); bbcodes.add(createBBCode("foo4", "replacement", "description", "example", false, true)); bbcodeService.save(bbcodes); List<BBCode> actual = bbcodeService.getAll(); assertEquals(bbcodes.size(), actual.size()); }