@Test
public void testInvalidVisibilityExpressions() {

  // No matching right paren
  final String EXPRESSION1 = "(a&b|c";
  // No matching left paren
  final String EXPRESSION2 = "a&b)|c";
  // Multiple sequential oeprators
  final String EXPRESSION3 = "a&|b";
  // Multiple sequential operands
  final String EXPRESSION4 = "(a)(b)";
  // No left operand
  final String EXPRESSION5 = "&b";
  // No right operand
  final String EXPRESSION6 = "a&";
  try {
    VisibilityExpression.evaluate(EXPRESSION1, Sets.newHashSet("a"));
    fail();
  } catch (final Exception e) {
    // Expected
    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) {
    // Expected
    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) {
    // Expected
    assertTrue(e.getCause() instanceof ParseException);
    assertEquals("Multiple sequential operators.", e.getCause().getMessage());
  }
  try {
    VisibilityExpression.evaluate(EXPRESSION4, Sets.newHashSet("a"));
    fail();
  } catch (final Exception e) {
    // Expected
    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) {
    // Expected
    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) {
    // Expected
    assertTrue(e.getCause() instanceof ParseException);
    assertEquals("Operator found with no right operand.", e.getCause().getMessage());
  }
}