public static List<Permission> convertToJavaPermissions(Set<org.onosproject.security.Permission> permissions) {
        List<Permission> result = Lists.newArrayList();
        for (org.onosproject.security.Permission perm : permissions) {
            Permission javaPerm = getPermission(perm);
            if (javaPerm != null) {
                if (javaPerm instanceof AppPermission) {
                    if (((AppPermission) javaPerm).getType() != null) {
                        AppPermission ap = (AppPermission) javaPerm;
                        result.add(ap);
                        if (serviceDirectory.containsKey(ap.getType())) {
                            for (String service : serviceDirectory.get(ap.getType())) {
                                result.add(new ServicePermission(service, ServicePermission.GET));
                            }
                        }
                    }
                } else if (javaPerm instanceof ServicePermission) {
                    if (!javaPerm.getName().contains(SecurityAdminService.class.getName())) {
                        result.add(javaPerm);
                    }
                } else {
                    result.add(javaPerm);
                }

            }
        }
        return result;
    }
@Test
    public void testConvertToJavaPermissions() {
        List<Permission> result = Lists.newArrayList();
        for (org.onosproject.security.Permission perm : testPermissions) {
            Permission javaPerm = new AppPermission(perm.getName());
            if (javaPerm != null) {
                if (javaPerm instanceof AppPermission) {
                    if (((AppPermission) javaPerm).getType() != null) {
                        AppPermission ap = (AppPermission) javaPerm;
                        result.add(ap);
                    }
                } else if (javaPerm instanceof ServicePermission) {
                    if (!javaPerm.getName().contains(SecurityAdminService.class.getName())) {
                        result.add(javaPerm);
                    }
                } else {
                    result.add(javaPerm);
                }

            }
        }
        assertTrue(!result.isEmpty());
        assertEquals("APP_READ", result.get(0).getName());
    }