use of org.geotools.filter.capability.FunctionNameImpl in project sldeditor by robward-scisys.
the class CheckBoxRendererTest method testCheckBoxRenderer.
/**
* Test method for {@link
* com.sldeditor.rendertransformation.CheckBoxRenderer#CheckBoxRenderer(com.sldeditor.rendertransformation.FunctionTableModel)}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void testCheckBoxRenderer() {
JTable table = new JTable();
FunctionTableModel model = new FunctionTableModel();
assertNull(new CheckBoxRenderer(null).getTableCellRendererComponent(null, null, false, false, 0, 0));
assertNull(new CheckBoxRenderer(null).getTableCellRendererComponent(table, null, false, false, 0, 0));
assertNull(new CheckBoxRenderer(model).getTableCellRendererComponent(null, null, false, false, 0, 0));
model.addNewValue(0);
ProcessFunction processFunction = createProcessFunction();
FunctionName name = new FunctionNameImpl("Test", parameter("cellSize", Double.class), new Parameter("outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class));
assertFalse(name.getArguments().get(0).isRequired());
assertTrue(name.getArguments().get(1).isRequired());
model.populate(name, processFunction);
CheckBoxRenderer obj = new CheckBoxRenderer(model);
// Row - optional and not selected
assertEquals(obj, obj.getTableCellRendererComponent(table, null, false, false, 0, 0));
assertEquals(obj, obj.getTableCellRendererComponent(table, true, false, false, 0, 0));
assertTrue(obj.isSelected());
assertEquals(obj, obj.getTableCellRendererComponent(table, false, false, false, 0, 0));
assertFalse(obj.isSelected());
// Row - optional and selected
assertEquals(obj, obj.getTableCellRendererComponent(table, null, true, false, 0, 0));
assertEquals(obj, obj.getTableCellRendererComponent(table, true, true, false, 0, 0));
assertTrue(obj.isSelected());
assertEquals(obj, obj.getTableCellRendererComponent(table, false, true, false, 0, 0));
assertFalse(obj.isSelected());
// Row - required and not selected
assertEquals(JLabel.class, obj.getTableCellRendererComponent(table, null, false, false, 1, 0).getClass());
// Row - required and selected
assertEquals(JLabel.class, obj.getTableCellRendererComponent(table, null, true, false, 1, 0).getClass());
}
use of org.geotools.filter.capability.FunctionNameImpl in project sldeditor by robward-scisys.
the class OptionalValueEditorTest method testGetCellEditorValue.
/**
* Test method for {@link
* com.sldeditor.rendertransformation.OptionalValueEditor#getCellEditorValue()}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void testGetCellEditorValue() {
FunctionTableModel model = new FunctionTableModel();
model.addNewValue(0);
ProcessFunction processFunction = createProcessFunction();
FunctionName name = new FunctionNameImpl("Test", parameter("cellSize", Double.class), new Parameter("outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class));
assertFalse(name.getArguments().get(0).isRequired());
assertTrue(name.getArguments().get(1).isRequired());
model.populate(name, processFunction);
TestOptionalValueEditor obj = new TestOptionalValueEditor(model);
assertNotNull(obj.getTableCellEditorComponent(null, null, false, 0, 0));
assertNotNull(obj.getCellEditorValue());
obj.setValue();
assertNull(obj.getTableCellEditorComponent(null, null, false, 1, 0));
}
use of org.geotools.filter.capability.FunctionNameImpl in project sldeditor by robward-scisys.
the class FunctionTableModelTest method testProcessBriefType.
/**
* Test all the methods using a ProcessBriefType.
*
* <p>Not tested because it needs to interact with GeoServer to create a receive a remote custom
* WPS function.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Disabled
@Test
void testProcessBriefType() {
FunctionTableModel model = new FunctionTableModel();
assertEquals(0, model.getRowCount());
model.addNewValue(0);
ProcessBriefType customFunction = createCustomFunction();
FunctionName name = new FunctionNameImpl(new NameImpl("vec", "PointStacker"), parameter("cellSize", Double.class), new Parameter("outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class));
assertFalse(name.getArguments().get(0).isRequired());
assertTrue(name.getArguments().get(1).isRequired());
model.populate(customFunction);
assertEquals(3, model.getRowCount());
assertEquals(4, model.getColumnCount());
// Get value
assertEquals("outputBBOX", model.getValueAt(0, 0));
assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1));
assertEquals(true, model.getValueAt(0, 2));
assertEquals("env([wms_bbox])", model.getValueAt(0, 3));
assertNull(model.getValueAt(0, 4));
// Is editable
assertFalse(model.isCellEditable(0, 0));
assertFalse(model.isCellEditable(0, 1));
assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn()));
assertFalse(model.isCellEditable(0, 3));
assertFalse(model.isCellEditable(0, 4));
// Set value
model.setValueAt(true, 0, 2);
assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
model.setValueAt(false, 0, 2);
assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
// Get row
assertNull(model.getValue(-1));
assertNull(model.getValue(10));
// Add a new value
assertEquals(0, model.getNoOfOccurences(null));
ProcessFunctionParameterValue value = model.getValue(0);
assertEquals(1, model.getNoOfOccurences(value));
model.addNewValue(0);
assertEquals(4, model.getRowCount());
assertEquals(2, model.getNoOfOccurences(value));
// Remove value
model.removeValue(3);
assertEquals(3, model.getRowCount());
// Get expression
ProcessFunction actualFunction = model.getExpression(null);
assertNull(actualFunction);
model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn());
ProcessFunctionFactory factory = new ProcessFunctionFactory();
actualFunction = model.getExpression(factory);
assertNotNull(actualFunction);
// Update expression
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Expression expression = ff.literal(4.2);
model.update(expression, 0);
model.update(null, 1);
}
use of org.geotools.filter.capability.FunctionNameImpl in project sldeditor by robward-scisys.
the class FunctionTableModelTest method testProcessFunction.
/**
* Test all the methods using a ProcessFunction
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void testProcessFunction() {
FunctionTableModel model = new FunctionTableModel();
assertEquals(0, model.getRowCount());
model.addNewValue(0);
ProcessFunction processFunction = createProcessFunction();
FunctionName name = new FunctionNameImpl(new NameImpl("vec", "PointStacker"), parameter("cellSize", Double.class), new Parameter("outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class));
assertFalse(name.getArguments().get(0).isRequired());
assertTrue(name.getArguments().get(1).isRequired());
model.populate(name, processFunction);
assertEquals(3, model.getRowCount());
assertEquals(4, model.getColumnCount());
// Get value
assertEquals("outputBBOX", model.getValueAt(0, 0));
assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1));
assertEquals(true, model.getValueAt(0, 2));
assertEquals("env([wms_bbox])", model.getValueAt(0, 3));
assertNull(model.getValueAt(0, 4));
// Is editable
assertFalse(model.isCellEditable(0, 0));
assertFalse(model.isCellEditable(0, 1));
assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn()));
assertFalse(model.isCellEditable(0, 3));
assertFalse(model.isCellEditable(0, 4));
// Set value
model.setValueAt(true, 0, 2);
assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
model.setValueAt(false, 0, 2);
assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
// Get row
assertNull(model.getValue(-1));
assertNull(model.getValue(10));
// Add a new value
assertEquals(0, model.getNoOfOccurences(null));
ProcessFunctionParameterValue value = model.getValue(0);
assertEquals(1, model.getNoOfOccurences(value));
model.addNewValue(0);
assertEquals(4, model.getRowCount());
assertEquals(2, model.getNoOfOccurences(value));
// Remove value
model.removeValue(3);
assertEquals(3, model.getRowCount());
// Get expression
ProcessFunction actualFunction = model.getExpression(null);
assertNull(actualFunction);
model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn());
ProcessFunctionFactory factory = new ProcessFunctionFactory();
actualFunction = model.getExpression(factory);
assertNotNull(actualFunction);
// Update expression
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Expression expression = ff.literal(4.2);
model.update(expression, 0);
model.update(null, 1);
}
Aggregations