### Question:
LazyFunctions implements Functions { @Override public Function find(String functionName, Class<?>... parameterTypes) { Method method = MethodUtils.getMatchingAccessibleMethod(beanClass, functionName, parameterTypes); if(method == null) { return null; } MethodDescriptor methodDescriptor = new MethodDescriptor(method.getName(), method.getParameterTypes()); if(!functions.containsKey(methodDescriptor)) { throw new RuntimeException("No such method '"+new MethodDescription(beanClass, method)+"'"); } Function function = functions.get(methodDescriptor); if (function == null) { function = supply.tryToCreateFunction(methodDescriptor); if(function == null) { throw new Bug(MessageFormat.format("The method '{0}' is not generated", new MethodDescription(beanClass, method))); } functions.put(methodDescriptor, function); } return function; } LazyFunctions(Class<?> beanClass, Set<MethodDescriptor> methods, FunctionSupply supply); @Override Function find(String functionName, Class<?>... parameterTypes);  }### Answer:
@Test public void whenFindExistingFunctionWithMatchedParameterTypes_thenFunctionFound() { Function function = lazyFunctions.find(FunctionsBean.FUNCTION1, new Class<?>[] { boolean.class }); assertNotNull(function); }
@Test public void whenFindExistingFunctioWithUnmatchedParameterTypes_thenReturnNull() { Function function = lazyFunctions.find(FunctionsBean.FUNCTION1, new Class<?>[] { Boolean.class, Object.class }); assertNull(function); }
@Test public void whenFindNonExistingFunction_thenReturnNull() { Function function = lazyFunctions.find("nonExistingFunction", new Class<?>[0]); Assert.assertNull(function); }
@Test public void givenFindExistingFunctionOnce_whenFindAgain_thenReturnSameInstance() { Function function = lazyFunctions.find(FunctionsBean.FUNCTION2, new Class<?>[0]); Function cachedFunction = lazyFunctions.find(FunctionsBean.FUNCTION2, new Class<?>[0]); Assert.assertNotNull(function); Assert.assertTrue(function == cachedFunction); }