### Question:
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } private  PosixModes(); static Set<PosixFilePermission> intModeToPosix(int intMode);  }### Answer:
@Test(expected = RuntimeException.class) public void outOfRangeNumberThrowsIllegalArgumentException() { try { PosixModes.intModeToPosix(-1); shouldHaveThrown(IllegalArgumentException.class); } catch (IllegalArgumentException e) { assertThat(e).isExactlyInstanceOf(RuntimeException.class); } try { PosixModes.intModeToPosix(01000); shouldHaveThrown(IllegalArgumentException.class); } catch (IllegalArgumentException e) { assertThat(e).isExactlyInstanceOf(RuntimeException.class); } }
@Test @UseDataProvider("intModeTestData") public void translatingToPosixPermissionsWorks(int intMode, String asString) { final Set<PosixFilePermission> expected = PosixFilePermissions.fromString(asString); assertThat(PosixModes.intModeToPosix(intMode)) .as("integer mode is correctly translated") .isEqualTo(expected); }