@Test public void testInvalidVisibilityExpressions() { final String EXPRESSION1 = "(a&b|c"; final String EXPRESSION2 = "a&b)|c"; final String EXPRESSION3 = "a&|b"; final String EXPRESSION4 = "(a)(b)"; final String EXPRESSION5 = "&b"; final String EXPRESSION6 = "a&"; try { VisibilityExpression.evaluate(EXPRESSION1, Sets.newHashSet("a")); fail(); } catch (final Exception e) { assertTrue(e.getCause() instanceof ParseException); assertEquals( "Left parenthesis found with no matching right parenthesis.", e.getCause().getMessage()); } try { VisibilityExpression.evaluate(EXPRESSION2, Sets.newHashSet("a")); fail(); } catch (final Exception e) { assertTrue(e.getCause() instanceof ParseException); assertEquals( "Right parenthesis found with no matching left parenthesis.", e.getCause().getMessage()); } try { VisibilityExpression.evaluate(EXPRESSION3, Sets.newHashSet("a")); fail(); } catch (final Exception e) { assertTrue(e.getCause() instanceof ParseException); assertEquals("Multiple sequential operators.", e.getCause().getMessage()); } try { VisibilityExpression.evaluate(EXPRESSION4, Sets.newHashSet("a")); fail(); } catch (final Exception e) { assertTrue(e.getCause() instanceof ParseException); assertEquals("Multiple sequential operands with no operator.", e.getCause().getMessage()); } try { VisibilityExpression.evaluate(EXPRESSION5, Sets.newHashSet("a")); fail(); } catch (final Exception e) { assertTrue(e.getCause() instanceof ParseException); assertEquals("Operator found with no left operand.", e.getCause().getMessage()); } try { VisibilityExpression.evaluate(EXPRESSION6, Sets.newHashSet("a")); fail(); } catch (final Exception e) { assertTrue(e.getCause() instanceof ParseException); assertEquals("Operator found with no right operand.", e.getCause().getMessage()); } }
public static boolean evaluate(final String expression, final Set<String> auths) { final String trimmed = expression.replaceAll("\\s+", ""); try { return expressionCache.get(trimmed).evaluate(auths); } catch (final ExecutionException e) { throw new RuntimeException(e.getCause()); } }
VisibilityExpression { public static boolean evaluate(final String expression, final Set<String> auths) { final String trimmed = expression.replaceAll("\\s+", ""); try { return expressionCache.get(trimmed).evaluate(auths); } catch (final ExecutionException e) { throw new RuntimeException(e.getCause()); } } }
VisibilityExpression { public static boolean evaluate(final String expression, final Set<String> auths) { final String trimmed = expression.replaceAll("\\s+", ""); try { return expressionCache.get(trimmed).evaluate(auths); } catch (final ExecutionException e) { throw new RuntimeException(e.getCause()); } }  }
VisibilityExpression { public static boolean evaluate(final String expression, final Set<String> auths) { final String trimmed = expression.replaceAll("\\s+", ""); try { return expressionCache.get(trimmed).evaluate(auths); } catch (final ExecutionException e) { throw new RuntimeException(e.getCause()); } }  static boolean evaluate(final String expression, final Set<String> auths); }
VisibilityExpression { public static boolean evaluate(final String expression, final Set<String> auths) { final String trimmed = expression.replaceAll("\\s+", ""); try { return expressionCache.get(trimmed).evaluate(auths); } catch (final ExecutionException e) { throw new RuntimeException(e.getCause()); } }  static boolean evaluate(final String expression, final Set<String> auths);  }