NodeLocatorServiceImpl implements NodeLocatorService { @Override public NodeRef getNode(String locatorName, NodeRef source, Map<String, Serializable> params) { NodeLocator locator = locators.get(locatorName); if (locator == null) { String msg = "No NodeLocator is registered with name: " + locatorName; throw new IllegalArgumentException(msg); } NodeRef node = locator.getNode(source, params); if (logger.isDebugEnabled()) { logger.debug("Node locator named '" + locatorName + "' found node: " + node); } return node; }  @Override NodeRef getNode(String locatorName, NodeRef source, Map<String, Serializable> params); @Override void register(String locatorName, NodeLocator locator);  }
@Test public void testUnknownNodeLocator() throws Exception { try { nodeLocatorService.getNode(null, null, null); fail("An exception should have been thrown!"); } catch(IllegalArgumentException e) { } try { nodeLocatorService.getNode("some unknown name", null, null); fail("An exception should have been thrown!"); } catch(IllegalArgumentException e) { } }
@Test public void testCompanyHomeNodeLocator() throws Exception { NodeRef result = nodeLocatorService.getNode(CompanyHomeNodeLocator.NAME, null, null); assertEquals(companyHome, result); }
@Test public void testSitesHomeNodeLocator() throws Exception { NodeRef result = nodeLocatorService.getNode(SitesHomeNodeLocator.NAME, null, null); assertEquals(sitesHome, result); }