### Question:
CommonPermissionCheckingUtils { public Object proceed(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime) { LOGGER.debug("Permission check took {} ms (method: {})", System.currentTimeMillis() - startTime, methodSignature.getMethod().getDeclaringClass().getSimpleName() + "#" + methodSignature.getMethod().getName()); try { Object proceed = proceedingJoinPoint.proceed(); if (proceed == null) { LOGGER.debug("Return value is null, method signature: {}", methodSignature.toLongString()); } return proceed; } catch (Error | RuntimeException unchecked) { throw unchecked; } catch (Throwable t) { throw new AccessDeniedException(t.getMessage(), t); } }  @PostConstruct void init(); boolean legacyAuthorizationNeeded(); ResourceBasedCrnProvider getResourceBasedCrnProvider(AuthorizationResourceAction action); void checkPermissionForUser(AuthorizationResourceAction action, String userCrn); void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn); void checkPermissionForUserOnResource(AuthorizationResourceAction action, String userCrn, String resourceCrn); void checkPermissionForUserOnResources(AuthorizationResourceAction action,
            String userCrn, Collection<String> resourceCrns); Map<String, Boolean> getPermissionsForUserOnResources(AuthorizationResourceAction action,
            String userCrn, List<String> resourceCrns); Object proceed(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime); boolean isAuthorizationDisabled(ProceedingJoinPoint proceedingJoinPoint); boolean isInternalOnly(ProceedingJoinPoint proceedingJoinPoint); T getParameter(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, Class annotation, Class<T> target);  }### Answer:
@Test public void testProceedWhenProceedingJoinPointProceedThrowsUncheckedExceptionThenAccessDeniedExceptionComes() throws Throwable { String exceptionMessage = "somethingHappened!!!"; doThrow(new RuntimeException(exceptionMessage)).when(proceedingJoinPoint).proceed(); RuntimeException exception = Assert.assertThrows(RuntimeException.class, () -> underTest.proceed(proceedingJoinPoint, methodSignature, 0L)); assertEquals(exception.getMessage(), exceptionMessage); verify(proceedingJoinPoint, times(1)).proceed(); }
@Test public void testProceedWhenProceedingJoinPointProceedThrowsCheckedExceptionThenAccessDeniedExceptionComes() throws Throwable { String exceptionMessage = "somethingHappened!!!"; doThrow(new FileNotFoundException(exceptionMessage)).when(proceedingJoinPoint).proceed(); RuntimeException exception = Assert.assertThrows(RuntimeException.class, () -> underTest.proceed(proceedingJoinPoint, methodSignature, 0L)); assertEquals(exception.getMessage(), exceptionMessage); verify(proceedingJoinPoint, times(1)).proceed(); }
@Test public void testProceedWhenProceedingJoinPointProceedReturnsNullThenItShouldHaveLoggedWithMethodSignatureCallAndNullReturnsAtTheEnd() throws Throwable { when(proceedingJoinPoint.proceed()).thenReturn(null); Object result = underTest.proceed(proceedingJoinPoint, methodSignature, 0L); Assert.assertNull(result); verify(methodSignature, times(1)).toLongString(); verify(proceedingJoinPoint, times(1)).proceed(); }
@Test public void testProceedWhenProceedingJoinPointProceedReturnsWithAnObjectThenThatObjectShouldReturnAtTheEnd() throws Throwable { Object expected = new Object(); when(proceedingJoinPoint.proceed()).thenReturn(expected); Object result = underTest.proceed(proceedingJoinPoint, methodSignature, 0L); Assert.assertNotNull(result); Assert.assertEquals(expected, result); verify(methodSignature, times(0)).toLongString(); verify(proceedingJoinPoint, times(1)).proceed(); }