@Test public void testThatUserObjectWhichIsNoStringIsResolvedToFalse() { final Integer userObject = 4; final DefaultMutableTreeNode notADapNode = new DefaultMutableTreeNode(userObject); assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(notADapNode)); }
@Test public void testThatNullIsResolvedToFalse() { final Object notADapNode = null; assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(notADapNode)); }
@Test public void testThatOpendapLeafWhichIsNoCatalogRefIsResolvedToFalse() { final Object userObject = new OpendapLeaf("any", new InvDataset(null, "") { }); final DefaultMutableTreeNode noDapNode = new DefaultMutableTreeNode(userObject); assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(noDapNode)); }
@Test public void testThatOpendapLeafWhichIsCatalogRefIsResolvedToTrue() { final CatalogNode opendapLeaf = new CatalogNode("any", null); final DefaultMutableTreeNode notDapNode = new DefaultMutableTreeNode(opendapLeaf); assertEquals(true, CatalogTreeUtils.isCatalogReferenceNode(notDapNode)); } }
@Test public void testThatOneCatalogReferenceNodeHasBeenAdded() throws URISyntaxException, IOException { //preparation final URI catalogBaseUri = new URI("http://sonst.wo.hin/catalog.xml"); InputStream catalogIS = null; try { catalogIS = getThreddsCatalogInputStreamWithOneChildCatalogReference(); //execution catalogTree.insertCatalogElements(catalogIS, catalogBaseUri, parentNode, false); //verification assertEquals(1, parentNode.getChildCount()); final DefaultMutableTreeNode catalogNameNode = (DefaultMutableTreeNode) parentNode.getChildAt(0); assertEquals("CatalogName", catalogNameNode.getUserObject()); final TreeNode catalogReferenceNode = catalogNameNode.getChildAt(0); assertEquals(true, CatalogTreeUtils.isCatalogReferenceNode(catalogReferenceNode)); } finally { if (catalogIS != null) { catalogIS.close(); } } }
@Test public void testAppendingVariousDatasets() { //preparation datasets.add(createDataset(catalog, "dapName", "OPENDAP")); datasets.add(createDataset(catalog, "fileName", "FILE")); datasets.add(createCatalogRefDataset()); //execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); //verification assertEquals(3, parentNode.getChildCount()); assertEquals(true, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(1))); assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(1))); assertEquals(true, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(2).getChildAt(0))); }
@Test public void testAppendCatalogNode() throws URISyntaxException { //preparation datasets.add(createCatalogRefDataset()); //execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); //verification assertEquals(1, parentNode.getChildCount()); assertEquals(1, parentNode.getChildAt(0).getChildCount()); assertEquals(true, parentNode.getChildAt(0).getChildAt(0).isLeaf()); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(0))); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0).getChildAt(0))); assertEquals(true, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(0).getChildAt(0))); }