/** * Create new role combining other roles (sub-roles) in the "any N of" principle ({@link Mode#QUORUM}). * * @param name is role name * @param quorumSize is N in "any N of" principle * @param roles is collection of sub-roles */ public ListRole(String name, int quorumSize, @NonNull Collection<Role> roles) { super(name); this.mode = Mode.QUORUM; this.quorumSize = quorumSize; addAll(roles); }
/** * Create new role combining other roles (sub-roles) * * @param name is role name * @param mode is mode of sub-roles combining: "and", "or" and "any N of" principle * @param roles is collection of sub-roles */ public ListRole(String name, Mode mode, @NonNull Collection<Role> roles) { super(name); setMode(mode); addAll(roles); }
@Test public void shouldNotPerformRoleWithQuorumMode() { Contract c = new Contract(); SimpleRole s1 = new SimpleRole("owner"); SimpleRole s2 = new SimpleRole("owner2"); s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey())); s2.addKeyRecord(new KeyRecord(keys.get(1).getPublicKey())); c.registerRole(s1); c.registerRole(s2); ListRole roleList = new ListRole("listQuorumMode"); roleList.setQuorum(2); roleList.addAll(Do.listOf(s1, s2)); c.registerRole(roleList); HashSet<AbstractKey> keys = new HashSet<>(Do.listOf( ListRoleTest.keys.get(1).getPublicKey())); assertFalse(roleList.isAllowedForKeys(keys)); }