@Test public void testRevision() throws Exception { PdpPolicy parent = new PdpPolicy(); PdpPolicy revision = PdpPolicy.revision("new policy", parent, "xml", "uid", "John Doe", true); assertFalse(parent.isLatestRevision()); assertEquals(1, parent.getRevisions().size()); assertEquals(revision, parent.getRevisions().iterator().next()); assertEquals(0, parent.getRevisionNbr()); assertTrue(revision.isLatestRevision()); assertEquals(1, revision.getRevisionNbr()); }
public static PdpPolicy revision(String newName, PdpPolicy parent, String newPolicyXml, String userIdentifier, String userDisplayName, boolean isActive) { parent.getRevisions().forEach(p -> p.setLatestRevision(false)); parent.setLatestRevision(false); PdpPolicy clone = new PdpPolicy(); clone.setPolicyXml(newPolicyXml); clone.setName(newName); clone.setLatestRevision(true); clone.setUserIdentifier(userIdentifier); clone.setAuthenticatingAuthority(parent.getAuthenticatingAuthority()); clone.setUserDisplayName(userDisplayName); clone.setActive(isActive); clone.setRevisionNbr(parent.getRevisions().size() + 1); clone.setPolicyId(PolicyTemplateEngine.getPolicyId(newName)); clone.setType(parent.getType()); parent.addRevision(clone); return clone; }
PdpPolicy { public static PdpPolicy revision(String newName, PdpPolicy parent, String newPolicyXml, String userIdentifier, String userDisplayName, boolean isActive) { parent.getRevisions().forEach(p -> p.setLatestRevision(false)); parent.setLatestRevision(false); PdpPolicy clone = new PdpPolicy(); clone.setPolicyXml(newPolicyXml); clone.setName(newName); clone.setLatestRevision(true); clone.setUserIdentifier(userIdentifier); clone.setAuthenticatingAuthority(parent.getAuthenticatingAuthority()); clone.setUserDisplayName(userDisplayName); clone.setActive(isActive); clone.setRevisionNbr(parent.getRevisions().size() + 1); clone.setPolicyId(PolicyTemplateEngine.getPolicyId(newName)); clone.setType(parent.getType()); parent.addRevision(clone); return clone; } }
PdpPolicy { public static PdpPolicy revision(String newName, PdpPolicy parent, String newPolicyXml, String userIdentifier, String userDisplayName, boolean isActive) { parent.getRevisions().forEach(p -> p.setLatestRevision(false)); parent.setLatestRevision(false); PdpPolicy clone = new PdpPolicy(); clone.setPolicyXml(newPolicyXml); clone.setName(newName); clone.setLatestRevision(true); clone.setUserIdentifier(userIdentifier); clone.setAuthenticatingAuthority(parent.getAuthenticatingAuthority()); clone.setUserDisplayName(userDisplayName); clone.setActive(isActive); clone.setRevisionNbr(parent.getRevisions().size() + 1); clone.setPolicyId(PolicyTemplateEngine.getPolicyId(newName)); clone.setType(parent.getType()); parent.addRevision(clone); return clone; } PdpPolicy();  PdpPolicy(String policyXml, String name, boolean latestRevision, String userIdentifier, String authenticatingAuthority, String userDisplayName, boolean active, String type); }
PdpPolicy { public static PdpPolicy revision(String newName, PdpPolicy parent, String newPolicyXml, String userIdentifier, String userDisplayName, boolean isActive) { parent.getRevisions().forEach(p -> p.setLatestRevision(false)); parent.setLatestRevision(false); PdpPolicy clone = new PdpPolicy(); clone.setPolicyXml(newPolicyXml); clone.setName(newName); clone.setLatestRevision(true); clone.setUserIdentifier(userIdentifier); clone.setAuthenticatingAuthority(parent.getAuthenticatingAuthority()); clone.setUserDisplayName(userDisplayName); clone.setActive(isActive); clone.setRevisionNbr(parent.getRevisions().size() + 1); clone.setPolicyId(PolicyTemplateEngine.getPolicyId(newName)); clone.setType(parent.getType()); parent.addRevision(clone); return clone; } PdpPolicy();  PdpPolicy(String policyXml, String name, boolean latestRevision, String userIdentifier, String authenticatingAuthority, String userDisplayName, boolean active, String type); Long getId(); void setId(Long id); String getPolicyId(); void setPolicyId(String policyId); String getPolicyXml(); void setPolicyXml(String policyXml); String getName(); void setName(String name); String getAuthenticatingAuthority(); void setAuthenticatingAuthority(String authenticatingAuthority); String getUserIdentifier(); void setUserIdentifier(String userIdentifier); String getUserDisplayName(); void setUserDisplayName(String userDisplayName); Set<PdpPolicy> getRevisions(); void setRevisions(Set<PdpPolicy> revisions); void addRevision(PdpPolicy revision); Set<PdpPolicyViolation> getViolations(); void setViolations(Set<PdpPolicyViolation> violations); void addPdpPolicyViolation(PdpPolicyViolation violation); Date getCreated(); void setCreated(Date created); int getRevisionNbr(); void setRevisionNbr(int revisionNbr); boolean isLatestRevision(); void setLatestRevision(boolean latestRevision); boolean isActive(); void setActive(boolean active); PdpPolicy getParentPolicy(); void setParentPolicy(PdpPolicy parentPolicy); String getType(); void setType(String type); static PdpPolicy revision(String newName, PdpPolicy parent, String newPolicyXml, String userIdentifier, String userDisplayName, boolean isActive); }
PdpPolicy { public static PdpPolicy revision(String newName, PdpPolicy parent, String newPolicyXml, String userIdentifier, String userDisplayName, boolean isActive) { parent.getRevisions().forEach(p -> p.setLatestRevision(false)); parent.setLatestRevision(false); PdpPolicy clone = new PdpPolicy(); clone.setPolicyXml(newPolicyXml); clone.setName(newName); clone.setLatestRevision(true); clone.setUserIdentifier(userIdentifier); clone.setAuthenticatingAuthority(parent.getAuthenticatingAuthority()); clone.setUserDisplayName(userDisplayName); clone.setActive(isActive); clone.setRevisionNbr(parent.getRevisions().size() + 1); clone.setPolicyId(PolicyTemplateEngine.getPolicyId(newName)); clone.setType(parent.getType()); parent.addRevision(clone); return clone; } PdpPolicy();  PdpPolicy(String policyXml, String name, boolean latestRevision, String userIdentifier, String authenticatingAuthority, String userDisplayName, boolean active, String type); Long getId(); void setId(Long id); String getPolicyId(); void setPolicyId(String policyId); String getPolicyXml(); void setPolicyXml(String policyXml); String getName(); void setName(String name); String getAuthenticatingAuthority(); void setAuthenticatingAuthority(String authenticatingAuthority); String getUserIdentifier(); void setUserIdentifier(String userIdentifier); String getUserDisplayName(); void setUserDisplayName(String userDisplayName); Set<PdpPolicy> getRevisions(); void setRevisions(Set<PdpPolicy> revisions); void addRevision(PdpPolicy revision); Set<PdpPolicyViolation> getViolations(); void setViolations(Set<PdpPolicyViolation> violations); void addPdpPolicyViolation(PdpPolicyViolation violation); Date getCreated(); void setCreated(Date created); int getRevisionNbr(); void setRevisionNbr(int revisionNbr); boolean isLatestRevision(); void setLatestRevision(boolean latestRevision); boolean isActive(); void setActive(boolean active); PdpPolicy getParentPolicy(); void setParentPolicy(PdpPolicy parentPolicy); String getType(); void setType(String type); static PdpPolicy revision(String newName, PdpPolicy parent, String newPolicyXml, String userIdentifier, String userDisplayName, boolean isActive);  }