@Before public void setUp() { Lm.verifyLicense("Brockmann Consult", "BEAM", "lCzfhklpZ9ryjomwWxfdupxIcuIoCxg2"); variableFilter = new VariableFilter(new JCheckBox(), new CatalogTree(null, new DefaultAppContext(""), null)); variableFilter.getUI(); leaf = new OpendapLeaf("leafName", new InvDataset(null, "") { }); DArrayDimension[] dArrayDimensions = {new DArrayDimension(10, "dimName")}; dapVariable = new DAPVariable("vName", "vType", "vDataType", dArrayDimensions); leaf.addDAPVariable(dapVariable); }
@Test public void testGetVariables() { DAPVariable variable = new DAPVariable("vname", "vtype", "vdatatype", new DArrayDimension[]{new DArrayDimension(10, "dname")}); opendapLeaf.addDAPVariable(variable); assertEquals(1, opendapLeaf.getDAPVariables().length); assertSame(variable, opendapLeaf.getDAPVariables()[0]); }
@Test public void testAccept_AcceptAllIfNoVariableIsSelected() throws Exception { OpendapLeaf leaf2 = new OpendapLeaf("leafName2", new InvDataset(null, "") { }); DAPVariable dapVariable2 = createDAPVariable("vName2"); leaf2.addDAPVariable(dapVariable2); variableFilter.addVariable(dapVariable); variableFilter.addVariable(dapVariable2); variableFilter.setVariableSelected(dapVariable, false); variableFilter.setVariableSelected(dapVariable2, false); assertTrue(variableFilter.accept(leaf)); assertTrue(variableFilter.accept(leaf2)); }
@Test public void testAccept_AcceptIfFilterSet() throws Exception { OpendapLeaf leaf2 = new OpendapLeaf("leafName2", new InvDataset(null, "") { }); DAPVariable dapVariable2 = createDAPVariable("vName2"); leaf2.addDAPVariable(dapVariable2); variableFilter.addVariable(dapVariable); variableFilter.addVariable(dapVariable2); variableFilter.setVariableSelected(dapVariable, true); variableFilter.setVariableSelected(dapVariable2, false); assertTrue(variableFilter.accept(leaf)); assertFalse(variableFilter.accept(leaf2)); }
@Test public void testAccept_AcceptNothingIfNoMatchingVariableIsSelected() throws Exception { OpendapLeaf leaf2 = new OpendapLeaf("leafName2", new InvDataset(null, "") { }); DAPVariable dapVariable2 = createDAPVariable("vName2"); leaf2.addDAPVariable(dapVariable2); DAPVariable dapVariable3 = createDAPVariable("vName3"); variableFilter.addVariable(dapVariable); variableFilter.addVariable(dapVariable2); variableFilter.addVariable(dapVariable3); variableFilter.setVariableSelected(dapVariable, false); variableFilter.setVariableSelected(dapVariable2, false); variableFilter.setVariableSelected(dapVariable3, true); assertFalse(variableFilter.accept(leaf)); assertFalse(variableFilter.accept(leaf2)); }