AssertionJSPolicyConverter implements PolicyConverter { @Override public InputStream convertFromPolicyElement(Element policy) { Optional<String> jsPolicy = getScriptString(null, policy); return IOUtils.toInputStream(jsPolicy.orElseThrow(() -> new PolicyConverterException("Cannot Convert JS Policy")), StandardCharsets.UTF_8); }  @Override String getPolicyTypeExtension(); @Override String getPolicyXML(Policy policy, String policyString); @Override boolean canConvert(String policyName, Element policy); @Override InputStream convertFromPolicyElement(Element policy);  }
@Test void convertFromPolicyElement() throws IOException { String jsStringOriginal = "my-javascript"; Element policyElement = createPolicy(createJSAssertion("myPolicy", "", false, jsStringOriginal)); InputStream jsStream = assertionJSPolicyConverter.convertFromPolicyElement(policyElement); String jsString = IOUtils.toString(jsStream, StandardCharsets.UTF_8); assertEquals(jsStringOriginal, jsString); }