WmsRootNode extends FolderNode { public WmsLayerNode addWmsLayer(WMSLayerInfo layer) { if (layer == null) { return null; } WmsServerNode serverNode = findServerNodeForLayer(layer); if (serverNode == null) { serverNode = new WmsServerNode(layer.getCaps()); addChild(serverNode); } WmsLayerNode wmsLayerNode = new WmsLayerNode(layer, true, 1.0); serverNode.addChild(wmsLayerNode); return wmsLayerNode; } WmsRootNode();  WmsRootNode(String name, URL iconURL, boolean expanded); WmsLayerNode addWmsLayer(WMSLayerInfo layer);  }
@Test public void testCreationOfLayerNodesFromRootNode() throws Exception { WmsRootNode classUnderTest = new WmsRootNode(); WMSLayerInfo layer = createWmsLayerInfo(); WmsLayerNode layerNode = classUnderTest.addWmsLayer(layer); assertEquals("http: assertEquals("http: }
@Test public void testAddWmsWithNoServerNodes() throws Exception { WmsRootNode classUnderTest = new WmsRootNode(); WMSLayerInfo layer = createWmsLayerInfo(); WmsLayerNode layerNode = classUnderTest.addWmsLayer(layer); assertEquals(1, classUnderTest.getChildCount()); assertTrue(classUnderTest.getChild(0) instanceof WmsServerNode); WmsServerNode serverNode = (WmsServerNode)classUnderTest.getChild(0); assertEquals("NASA Earth Observations (NEO) WMS", serverNode.getName()); assertEquals("http: assertEquals(1, serverNode.getChildCount()); assertEquals(layerNode, serverNode.getChild(0)); }
@Test public void testAddWmsWithExistingServerNode() throws Exception { WmsRootNode classUnderTest = new WmsRootNode(); WmsServerNode serverNode = new WmsServerNode("dummyServer", null, true, URLUtil.fromString("http: classUnderTest.addChild(serverNode); WMSLayerInfo layer = createWmsLayerInfo(); WmsLayerNode layerNode = classUnderTest.addWmsLayer(layer); assertEquals(1, classUnderTest.getChildCount()); assertEquals(serverNode, classUnderTest.getChild(0)); assertEquals(1, serverNode.getChildCount()); assertEquals(layerNode, serverNode.getChild(0)); }
@Test public void testAddWmsWithExistingServerNodeUnderFolders() throws Exception { WmsRootNode classUnderTest = new WmsRootNode(); FolderNode folder1 = new FolderNode("folder1", null, null, true); classUnderTest.addChild(folder1); FolderNode folder2 = new FolderNode("folder2", null, null, true); classUnderTest.addChild(folder2); FolderNode folder3 = new FolderNode("folder2", null, null, true); folder2.addChild(folder3); WmsServerNode serverNode = new WmsServerNode("dummyServer", null, true, URLUtil.fromString("http: folder3.addChild(serverNode); WMSLayerInfo layer = createWmsLayerInfo(); WmsLayerNode layerNode = classUnderTest.addWmsLayer(layer); assertEquals(2, classUnderTest.getChildCount()); assertEquals(folder1, classUnderTest.getChild(0)); assertEquals(0, folder1.getChildCount()); assertEquals(folder2, classUnderTest.getChild(1)); assertEquals(1, folder2.getChildCount()); assertEquals(folder3, folder2.getChild(0)); assertEquals(1, folder3.getChildCount()); assertEquals(serverNode, folder3.getChild(0)); assertEquals(1, serverNode.getChildCount()); assertEquals(layerNode, serverNode.getChild(0)); }