### Question:
SimplePDP { public boolean isAuthorized(final String ip, final String referer) { final String toEvaluate = replaceVariablesInRule(ip, referer); boolean result = false; try { result = (Boolean)SCRIPT_ENGINE.eval(toEvaluate); } catch (ScriptException ex) { LOGGER.log(Level.INFO, "Error trying to evaluate the expression :"+ result, ex); } return result; } SimplePDP(final String rule); boolean isAuthorized(final String ip, final String referer);  }### Answer:
@Test public void isAuthorizedRule1Test() { final SimplePDP pdp = new SimplePDP(RULE1); assertTrue(pdp.isAuthorized("127.0.0.1", "")); }
@Test public void isNotAuthorizedRule1Test() { final SimplePDP pdp = new SimplePDP(RULE1); assertFalse(pdp.isAuthorized("17.15.25.3", "test")); }
@Test public void isAuthorizedRule2Test() { final SimplePDP pdp = new SimplePDP(RULE2); assertTrue(pdp.isAuthorized("127.0.0.1", "http: }
@Test public void isNotAuthorizedRule2Test() { final SimplePDP pdp = new SimplePDP(RULE2); assertFalse(pdp.isAuthorized("127.0.0.1", "http: }
@Test public void isAuthorizedRule3Test() { final SimplePDP pdp = new SimplePDP(RULE3); assertTrue(pdp.isAuthorized("17.15.25.3", "http: }
@Test public void isNotAuthorizedRule3Test() { final SimplePDP pdp = new SimplePDP(RULE3); assertFalse(pdp.isAuthorized("17.15.25.3", "http: }