public static void parseResourcePerms(PlainAccessResource plainAccessResource, Boolean isTopic,
        List<String> resources) {
        if (resources == null || resources.isEmpty()) {
            return;
        }
        for (String resource : resources) {
            String[] items = StringUtils.split(resource, "=");
            if (items.length == 2) {
                plainAccessResource.addResourceAndPerm(isTopic ? items[0].trim() : PlainAccessResource.getRetryTopic(items[0].trim()), parsePermFromString(items[1].trim()));
            } else {
                throw new AclException(String.format("Parse resource permission failed for %s:%s", isTopic ? "topic" : "group", resource));
            }
        }
    }
@Test(expected = AclException.class)
    public void setTopicPermTest() {
        PlainAccessResource plainAccessResource = new PlainAccessResource();
        Map<String, Byte> resourcePermMap = plainAccessResource.getResourcePermMap();

        Permission.parseResourcePerms(plainAccessResource, false, null);
        Assert.assertNull(resourcePermMap);

        List<String> groups = new ArrayList<>();
        Permission.parseResourcePerms(plainAccessResource, false, groups);
        Assert.assertNull(resourcePermMap);

        groups.add("groupA=DENY");
        groups.add("groupB=PUB|SUB");
        groups.add("groupC=PUB");
        Permission.parseResourcePerms(plainAccessResource, false, groups);
        resourcePermMap = plainAccessResource.getResourcePermMap();

        byte perm = resourcePermMap.get(PlainAccessResource.getRetryTopic("groupA"));
        Assert.assertEquals(perm, Permission.DENY);

        perm = resourcePermMap.get(PlainAccessResource.getRetryTopic("groupB"));
        Assert.assertEquals(perm,Permission.PUB | Permission.SUB);

        perm = resourcePermMap.get(PlainAccessResource.getRetryTopic("groupC"));
        Assert.assertEquals(perm, Permission.PUB);

        List<String> topics = new ArrayList<>();
        topics.add("topicA=DENY");
        topics.add("topicB=PUB|SUB");
        topics.add("topicC=PUB");

        Permission.parseResourcePerms(plainAccessResource, true, topics);

        perm = resourcePermMap.get("topicA");
        Assert.assertEquals(perm, Permission.DENY);

        perm = resourcePermMap.get("topicB");
        Assert.assertEquals(perm, Permission.PUB | Permission.SUB);

        perm = resourcePermMap.get("topicC");
        Assert.assertEquals(perm, Permission.PUB);

        List<String> erron = new ArrayList<>();
        erron.add("");
        Permission.parseResourcePerms(plainAccessResource, false, erron);
    }