@Test
void testWriteServicePolicy(final TemporaryFolder temporaryFolder) throws DocumentParseException {

    PolicyWriter writer = new PolicyWriter(policyConverterRegistry, DocumentFileUtils.INSTANCE, JsonFileUtils.INSTANCE, new EntityLinkerRegistry(new HashSet<>()));
    Bundle bundle = new Bundle();
    bundle.addEntity(ROOT_FOLDER);
    bundle.setFolderTree(new FolderTree(bundle.getEntities(Folder.class).values()));
    Service service = new Service();
    service.setPath("assertionPolicy");
    service.setParentFolder(ROOT_FOLDER);
    service.setName("assertionPolicy");
    service.setId("asd");
    DocumentTools documentTools = DocumentTools.INSTANCE;
    Document document = documentTools.parse("<wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" xmlns:L7p=\"http://www.layer7tech.com/ws/policy\">\n" +
            "    <wsp:All wsp:Usage=\"Required\"><L7p:JavaScript>\n" +
            "            <L7p:ExecutionTimeout stringValue=\"\"/>\n" +
            "            <L7p:Name stringValue=\"assertionPolicy\"/>\n" +
            "            <L7p:Script stringValueReference=\"inline\"><![CDATA[var js = {};]]></L7p:Script>\n" +
            "        </L7p:JavaScript></wsp:All>\n" +
            "</wsp:Policy>");
    service.setPolicyXML(document.getDocumentElement());
    bundle.getServices().put("assertionPolicy", service);
    writer.write(bundle, temporaryFolder.getRoot(), bundle);
    File policyFolder = new File(temporaryFolder.getRoot(), "policy");
    assertTrue(policyFolder.exists());
    File policyFile = new File(policyFolder, "assertionPolicy.assertion.js");
    assertTrue(policyFile.exists());
    File configFolder = new File(temporaryFolder.getRoot(), "config");
    assertTrue(configFolder.exists());
    File policyMetadataFile = new File(configFolder, "policies.yml");
    assertTrue(policyMetadataFile.exists());
}