@Test public void testGetSerializedUpdateValues() throws Exception { Set<Permission> operations = Sets.newHashSet(Permission.SELECT, Permission.MODIFY); SetSerializer<String> stringSetSerializer = SetSerializer.getInstance(AsciiSerializer.instance); List<ByteBuffer> values = WhitelistDataAccess.getSerializedUpdateValues("Role1", "Resource1", operations); assertThat(values).hasSize(3); ByteBuffer operationsByteBuffer = values.get(0); assertThat(stringSetSerializer.deserialize(operationsByteBuffer)).containsOnly("SELECT", "MODIFY"); ByteBuffer roleByteBuffer = values.get(1); assertThat(ByteBufferUtil.string(roleByteBuffer)).isEqualTo("Role1"); ByteBuffer resourceByteBuffer = values.get(2); assertThat(ByteBufferUtil.string(resourceByteBuffer)).isEqualTo("Resource1"); }
static List<ByteBuffer> getSerializedUpdateValues(String role, String resource, Set<Permission> whitelistOperations) { Set<String> operations = whitelistOperations.stream() .map(Enum::name) .collect(Collectors.toSet()); List<ByteBuffer> values = new ArrayList<>(3); values.add(SET_SERIALIZER.serialize(operations)); values.add(ByteBufferUtil.bytes(role)); values.add(ByteBufferUtil.bytes(resource)); return values; }
WhitelistDataAccess { static List<ByteBuffer> getSerializedUpdateValues(String role, String resource, Set<Permission> whitelistOperations) { Set<String> operations = whitelistOperations.stream() .map(Enum::name) .collect(Collectors.toSet()); List<ByteBuffer> values = new ArrayList<>(3); values.add(SET_SERIALIZER.serialize(operations)); values.add(ByteBufferUtil.bytes(role)); values.add(ByteBufferUtil.bytes(resource)); return values; } }
WhitelistDataAccess { static List<ByteBuffer> getSerializedUpdateValues(String role, String resource, Set<Permission> whitelistOperations) { Set<String> operations = whitelistOperations.stream() .map(Enum::name) .collect(Collectors.toSet()); List<ByteBuffer> values = new ArrayList<>(3); values.add(SET_SERIALIZER.serialize(operations)); values.add(ByteBufferUtil.bytes(role)); values.add(ByteBufferUtil.bytes(resource)); return values; } private  WhitelistDataAccess(); }
WhitelistDataAccess { static List<ByteBuffer> getSerializedUpdateValues(String role, String resource, Set<Permission> whitelistOperations) { Set<String> operations = whitelistOperations.stream() .map(Enum::name) .collect(Collectors.toSet()); List<ByteBuffer> values = new ArrayList<>(3); values.add(SET_SERIALIZER.serialize(operations)); values.add(ByteBufferUtil.bytes(role)); values.add(ByteBufferUtil.bytes(resource)); return values; } private  WhitelistDataAccess(); static WhitelistDataAccess getInstance(); synchronized void setup(); Map<IResource, Set<Permission>> getWhitelist(RoleResource role); }
WhitelistDataAccess { static List<ByteBuffer> getSerializedUpdateValues(String role, String resource, Set<Permission> whitelistOperations) { Set<String> operations = whitelistOperations.stream() .map(Enum::name) .collect(Collectors.toSet()); List<ByteBuffer> values = new ArrayList<>(3); values.add(SET_SERIALIZER.serialize(operations)); values.add(ByteBufferUtil.bytes(role)); values.add(ByteBufferUtil.bytes(resource)); return values; } private  WhitelistDataAccess(); static WhitelistDataAccess getInstance(); synchronized void setup(); Map<IResource, Set<Permission>> getWhitelist(RoleResource role);  }