@Test void testGetPermissionSetInvalidMask() { AccessControlEntry accessControlEntry = mock(AccessControlEntry.class); Permission permission = when(mock(Permission.class).getMask()).thenReturn(32).getMock(); when(accessControlEntry.getPermission()).thenReturn(permission); assertThrows( IllegalArgumentException.class, () -> PermissionSetUtils.getPermissionSet(accessControlEntry)); }
public static PermissionSet getPermissionSet(AccessControlEntry accessControlEntry) { int mask = accessControlEntry.getPermission().getMask(); switch (mask) { case READ_META_MASK: return PermissionSet.READMETA; case COUNT_MASK: return PermissionSet.COUNT; case READ_MASK: return PermissionSet.READ; case WRITE_MASK: return PermissionSet.WRITE; case WRITEMETA_MASK: return PermissionSet.WRITEMETA; default: throw new IllegalArgumentException(format(UNEXPECTED_MASK_MESSAGE, mask)); } }
PermissionSetUtils { public static PermissionSet getPermissionSet(AccessControlEntry accessControlEntry) { int mask = accessControlEntry.getPermission().getMask(); switch (mask) { case READ_META_MASK: return PermissionSet.READMETA; case COUNT_MASK: return PermissionSet.COUNT; case READ_MASK: return PermissionSet.READ; case WRITE_MASK: return PermissionSet.WRITE; case WRITEMETA_MASK: return PermissionSet.WRITEMETA; default: throw new IllegalArgumentException(format(UNEXPECTED_MASK_MESSAGE, mask)); } } }
PermissionSetUtils { public static PermissionSet getPermissionSet(AccessControlEntry accessControlEntry) { int mask = accessControlEntry.getPermission().getMask(); switch (mask) { case READ_META_MASK: return PermissionSet.READMETA; case COUNT_MASK: return PermissionSet.COUNT; case READ_MASK: return PermissionSet.READ; case WRITE_MASK: return PermissionSet.WRITE; case WRITEMETA_MASK: return PermissionSet.WRITEMETA; default: throw new IllegalArgumentException(format(UNEXPECTED_MASK_MESSAGE, mask)); } } private  PermissionSetUtils(); }
PermissionSetUtils { public static PermissionSet getPermissionSet(AccessControlEntry accessControlEntry) { int mask = accessControlEntry.getPermission().getMask(); switch (mask) { case READ_META_MASK: return PermissionSet.READMETA; case COUNT_MASK: return PermissionSet.COUNT; case READ_MASK: return PermissionSet.READ; case WRITE_MASK: return PermissionSet.WRITE; case WRITEMETA_MASK: return PermissionSet.WRITEMETA; default: throw new IllegalArgumentException(format(UNEXPECTED_MASK_MESSAGE, mask)); } } private  PermissionSetUtils(); static PermissionSet getPermissionSet(AccessControlEntry accessControlEntry); static PermissionSet paramValueToPermissionSet(String paramValue); static Optional<String> getPermissionStringValue(LabelledPermission labelledPermission); static String getPermissionStringValue(PermissionSet permissionSet); }
PermissionSetUtils { public static PermissionSet getPermissionSet(AccessControlEntry accessControlEntry) { int mask = accessControlEntry.getPermission().getMask(); switch (mask) { case READ_META_MASK: return PermissionSet.READMETA; case COUNT_MASK: return PermissionSet.COUNT; case READ_MASK: return PermissionSet.READ; case WRITE_MASK: return PermissionSet.WRITE; case WRITEMETA_MASK: return PermissionSet.WRITEMETA; default: throw new IllegalArgumentException(format(UNEXPECTED_MASK_MESSAGE, mask)); } } private  PermissionSetUtils(); static PermissionSet getPermissionSet(AccessControlEntry accessControlEntry); static PermissionSet paramValueToPermissionSet(String paramValue); static Optional<String> getPermissionStringValue(LabelledPermission labelledPermission); static String getPermissionStringValue(PermissionSet permissionSet); static final String READMETA; static final String COUNT; static final String READ; static final String WRITE; static final String WRITEMETA; static final String UNEXPECTED_MASK_MESSAGE; }