TimeSeriesValidator implements TimeSeriesGraphForm.ValidatorUI, TimeSeriesGraphModel.Validation { boolean setExpression(String qualifiedSourceName, String expression) { final Symbol symbol = namespace.resolveSymbol(qualifiedSourceName); if (symbol == null) { return false; } if (isExpressionValid(expression, qualifiedSourceName)) { currentExpressionMap.put(qualifiedSourceName, expression); fireExpressionChanged(); return true; } return false; }  @Override JComponent createUI(); @Override void adaptTo(Object timeSeriesKey, AxisMapping axisMapping); @Override TimeSeries validate(TimeSeries timeSeries, String sourceName, TimeSeriesType type); @Override void addValidationListener(TimeSeriesGraphModel.ValidationListener listener);  }
@Test() public void testTryToSetInvalidExpression() throws Exception { assertFalse(validator.setExpression("r.raster1", "raster1 groesserAls 5")); }
@Test public void testThatValidatorIsCorrectlyInitialized() throws Exception { assertTrue(validator.setExpression("r.raster1", "r.raster1 > 5")); assertFalse(validator.setExpression("r.raster4", "r.raster4 > 5")); }
@Test public void testThatOnlyBooleanExpressionsCanBeSet() throws Exception { assertTrue(validator.setExpression("r.raster1", "r.raster1 > 5")); assertFalse(validator.setExpression("r.raster1", "r.raster1 + r.raster1")); }
@Test public void testInvalidIfExpressionEqualsSourceName() throws Exception { assertFalse(validator.setExpression("r.raster1", "r.raster1")); }