@Test void shouldTreatParsingErrorsAsValidationErrors() { final Either<ValidationResult.Builder.ElementStep, FeelExpression> result = FeelParser.parse("[1.."); final String expectedErrorMessage = "Could not parse '[1..': line 1, column 5:\n" + "INTEGER, DECIMAL, booleanfragment, variablefragment, stringfragment or date and time(\" expected, EOF encountered."; assertTrue(Eithers.getLeft(result).isPresent()); assertEquals(expectedErrorMessage, Eithers.getLeft(result).get().getMessage()); }
public static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence) { try { return Eithers.right(PARSER.parse(charSequence)); } catch (final ParserException e) { return Eithers.left(ValidationResult.init.message("Could not parse '" + charSequence + "': " + e.getMessage())); } }
FeelParser { public static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence) { try { return Eithers.right(PARSER.parse(charSequence)); } catch (final ParserException e) { return Eithers.left(ValidationResult.init.message("Could not parse '" + charSequence + "': " + e.getMessage())); } } }
FeelParser { public static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence) { try { return Eithers.right(PARSER.parse(charSequence)); } catch (final ParserException e) { return Eithers.left(ValidationResult.init.message("Could not parse '" + charSequence + "': " + e.getMessage())); } } private  FeelParser(); }
FeelParser { public static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence) { try { return Eithers.right(PARSER.parse(charSequence)); } catch (final ParserException e) { return Eithers.left(ValidationResult.init.message("Could not parse '" + charSequence + "': " + e.getMessage())); } } private  FeelParser(); static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence); }
FeelParser { public static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence) { try { return Eithers.right(PARSER.parse(charSequence)); } catch (final ParserException e) { return Eithers.left(ValidationResult.init.message("Could not parse '" + charSequence + "': " + e.getMessage())); } } private  FeelParser(); static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence);  }