AssertionJSPolicyConverter implements PolicyConverter { @Override public boolean canConvert(String policyName, Element policy) { return getScriptString(policyName, policy).isPresent(); }  @Override String getPolicyTypeExtension(); @Override String getPolicyXML(Policy policy, String policyString); @Override boolean canConvert(String policyName, Element policy); @Override InputStream convertFromPolicyElement(Element policy);  }
@Test void canConvertTest() { Element policyElement = createPolicy(createJSAssertion("myPolicy", "", false, "my-javascript")); assertTrue(assertionJSPolicyConverter.canConvert("myPolicy", policyElement)); assertFalse(assertionJSPolicyConverter.canConvert("someOtherPolicyName", policyElement)); policyElement = createPolicy(createJSAssertion("myPolicy", "123", false, "my-javascript")); assertFalse(assertionJSPolicyConverter.canConvert("myPolicy", policyElement)); policyElement = createPolicy(createJSAssertion("myPolicy", "", true, "my-javascript")); assertFalse(assertionJSPolicyConverter.canConvert("myPolicy", policyElement)); policyElement = createPolicy(createJSAssertion("myPolicy", "", false, "my-javascript"), document.createElement("L7p:SomeOtherAssertion")); assertFalse(assertionJSPolicyConverter.canConvert("myPolicy", policyElement)); policyElement = createPolicy(); assertFalse(assertionJSPolicyConverter.canConvert("myPolicy", policyElement)); policyElement = createPolicy(document.createElement("L7p:SomeOtherAssertion")); assertFalse(assertionJSPolicyConverter.canConvert("myPolicy", policyElement)); }