Policy { protected final Collection<String[]> getGrants(String ... facts) { Collection<String[]> grants = new ArrayList<String[]>(); appendGrants(facts, 0, new String[facts.length], policyRoot, getRootFactMetaData(), grants); return grants; }  abstract String getName(); abstract FactMetaData getRootFactMetaData(); void setPolicyConfig(PolicyConfig policyConfig); void addViolationsToPolicy(); void collapsePolicy(); void parsePolicy(Reader reader); void writePolicy(Writer writer); String[][] getViolations(); String[][] getViolations(long sinceTime);  }
@Test public void testGetGrants() { Policy policy = new SimplePolicy(); policy.logViolation("a", "b", "c"); policy.logViolation("b", "c", "d"); policy.logViolation("b", "d", "c"); policy.logViolation("c", "b", "f"); policy.addViolationsToPolicy(); assertArrayCollectionEquals(policy.getGrants(null, null, "c"), Arrays.asList( new String[]{"a", "b", "c"}, new String[]{"b", "d", "c"})); assertArrayCollectionEquals(policy.getGrants(null, "b", "c"), Arrays.<String[]>asList( new String[]{"a", "b", "c" })); assertArrayCollectionEquals(policy.getGrants("c", null, null), Arrays.<String[]>asList( new String[]{"c", "b", "f"})); assertArrayCollectionEquals(policy.getGrants(null, null, "c", null, null), Arrays.asList( new String[]{"a", "b", "c", null, null}, new String[]{"b", "d", "c", null, null})); assertArrayCollectionEquals(policy.getGrants(null, null, "c", "f", null), Arrays.<String[]>asList()); assertArrayCollectionEquals(policy.getGrants(null, null, "c", null, "f"), Arrays.<String[]>asList()); }