ChmodFilePermissions { public static Set<PosixFilePermission> toPermissions(int bits) { EnumSet<PosixFilePermission> permissions = EnumSet.noneOf(PosixFilePermission.class); for (Entry<PosixFilePermission, Integer> e : permissionsBitMap.entrySet()) { if ((bits & e.getValue()) != 0) { permissions.add(e.getKey()); } } return permissions; } private  ChmodFilePermissions(); static Set<PosixFilePermission> toPermissions(int bits); static int toBits(Set<PosixFilePermission> permissions); static String toMode(PermissionChange change, Set<PosixFilePermission> permissions);  }
@Test public void toOwnerPermissions() { Set<PosixFilePermission> permissions = ChmodFilePermissions.toPermissions(0600); assertEquals("incorrect permissions", EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE), permissions); }
@Test public void toGroupPermissions() { Set<PosixFilePermission> permissions = ChmodFilePermissions.toPermissions(0050); assertEquals("incorrect permissions", EnumSet.of(PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_EXECUTE), permissions); }
@Test public void toOtherPermissions() { Set<PosixFilePermission> permissions = ChmodFilePermissions.toPermissions(0003); assertEquals("incorrect permissions", EnumSet.of(PosixFilePermission.OTHERS_WRITE, PosixFilePermission.OTHERS_EXECUTE), permissions); }
@Test public void toCombinedPermissions() { Set<PosixFilePermission> permissions = ChmodFilePermissions.toPermissions(0724); assertEquals("incorrect permissions", EnumSet.of( PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_WRITE, PosixFilePermission.OTHERS_READ), permissions); }