PolicyXMLSimplifier { public void simplifyPolicyXML(Element policyElement, String policyName, Bundle bundle, Bundle resultantBundle) { PolicySimplifierContext context = new PolicySimplifierContext(policyName, bundle, resultantBundle); simplifiersByTag.forEach((tag, simplifier) -> findAndSimplifyAssertion(policyElement, tag, simplifier, context)); } @Inject  PolicyXMLSimplifier(final Set<PolicyAssertionSimplifier> simplifiers); void simplifyPolicyXML(Element policyElement, String policyName, Bundle bundle, Bundle resultantBundle); Map<String, PolicyAssertionSimplifier> getSimplifiersByTag();  }
@Test void simplifyPolicy() { String policyID = new IdGenerator().generate(); String testName = "test"; Policy policy = new Policy.Builder() .setGuid(policyID) .setName(testName) .setParentFolderId(ROOT_FOLDER_ID) .build(); Bundle bundle = new Bundle(); bundle.addEntity(policy); bundle.addEntity(ROOT_FOLDER); FolderTree folderTree = new FolderTree(bundle.getEntities(Folder.class).values()); bundle.setFolderTree(folderTree); Document document = DocumentTools.INSTANCE.getDocumentBuilder().newDocument(); Element policyXML = createElementWithChildren( document, "wsp:Policy", createIncludeAssertionElement(document, policyID) ); InjectionRegistry.getInstance(PolicyXMLSimplifier.class).simplifyPolicyXML(policyXML, policy.getName(), bundle, bundle); }