VisibilityEvaluator { public boolean evaluate(final ElementVisibility visibility) throws VisibilityParseException { return this.evaluate(visibility.getExpression(), visibility.getParseTree()); } VisibilityEvaluator(final Authorisations auths); boolean evaluate(final ElementVisibility visibility); static byte[] escape(final byte[] auth, final boolean quote);  }
@Test public void testQuotedExpressions() throws VisibilityParseException { final Authorisations auths = new Authorisations("A#C", "A\"C", "A\\C", "AC"); final VisibilityEvaluator ve = new VisibilityEvaluator(auths); assertTrue(ve.evaluate(new ElementVisibility(quote("A#C") + "|" + quote("A?C")))); assertFalse(ve.evaluate(new ElementVisibility(quote("A#C") + "&B"))); assertTrue(ve.evaluate(new ElementVisibility(quote("A#C")))); assertTrue(ve.evaluate(new ElementVisibility("(" + quote("A#C") + ")"))); }
@Test public void testNonAscii() throws VisibilityParseException { final VisibilityEvaluator ve = new VisibilityEvaluator(new Authorisations("五", "六", "八", "九", "五十")); assertTrue(ve.evaluate(new ElementVisibility(quote("五") + "|" + quote("四")))); assertFalse(ve.evaluate(new ElementVisibility(quote("五") + "&" + quote("四")))); assertTrue(ve.evaluate(new ElementVisibility(quote("五") + "&(" + quote("四") + "|" + quote("九") + ")"))); assertTrue(ve.evaluate(new ElementVisibility("\"五\"&(\"四\"|\"五十\")"))); assertFalse(ve.evaluate(new ElementVisibility(quote("五") + "&(" + quote("四") + "|" + quote("三") + ")"))); assertFalse(ve.evaluate(new ElementVisibility("\"五\"&(\"四\"|\"三\")"))); }