### Question:
ReflectionUtil { public Optional<Object> getParameter(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, Class annotation) { Optional<Parameter> optionalParameter = Arrays.stream(methodSignature.getMethod().getParameters()) .filter(parameter -> parameter.isAnnotationPresent(annotation)) .findFirst(); if (optionalParameter.isPresent()) { int parameterIndex = Lists.newArrayList(methodSignature.getMethod().getParameters()).indexOf(optionalParameter.get()); return Optional.ofNullable(proceedingJoinPoint.getArgs()[parameterIndex]); } return Optional.empty(); }  Optional<Object> getParameter(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, Class annotation); Object proceed(ProceedingJoinPoint proceedingJoinPoint);  }### Answer:
@Test public void testParameterIfParamFilled() throws NoSuchMethodException { Method method = TestClass.class.getMethod("methodB", String.class); when(methodSignature.getMethod()).thenReturn(method); when(proceedingJoinPoint.getArgs()).thenReturn(new Object[]{"param"}); assertTrue(underTest.getParameter(proceedingJoinPoint, methodSignature, NotNull.class).isPresent()); }
@Test public void testParameterIfParamNull() throws NoSuchMethodException { Method method = TestClass.class.getMethod("methodB", String.class); when(methodSignature.getMethod()).thenReturn(method); when(proceedingJoinPoint.getArgs()).thenReturn(new Object[]{null}); assertFalse(underTest.getParameter(proceedingJoinPoint, methodSignature, NotNull.class).isPresent()); }
@Test public void testParameterIfParamNotExists() throws NoSuchMethodException { Method method = TestClass.class.getMethod("methodA"); when(methodSignature.getMethod()).thenReturn(method); assertFalse(underTest.getParameter(proceedingJoinPoint, methodSignature, NotNull.class).isPresent()); }