package org.esa.snap.opendap.ui; import org.esa.snap.opendap.datamodel.CatalogNode; import org.esa.snap.opendap.datamodel.OpendapLeaf; import org.junit.Test; import thredds.catalog.InvDataset; import javax.swing.tree.DefaultMutableTreeNode; import static org.junit.Assert.*; public class CatalogTree_isCatalogReferenceNodeTest { @Test public void testThatNullIsResolvedToFalse() { final Object notADapNode = null; assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(notADapNode)); } @Test public void testThatUserObjectWhichIsNoStringIsResolvedToFalse() { final Integer userObject = 4; final DefaultMutableTreeNode notADapNode = new DefaultMutableTreeNode(userObject); 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)); } }