### Question:
ConversionAnalyzer { @SuppressWarnings("unchecked") public Optional<Function<Object, Object>> getConversionFunction(final Class<?> sourceClass, final Class<?> targetClass) { final String cacheKey = "ConversionFunction-" + sourceClass.getName() + "-" + targetClass.getName(); return CACHE_MANAGER.getFromCache(cacheKey, Optional.class).orElseGet(() -> { Optional conversionFunction = empty(); if (!targetClass.getSimpleName().equalsIgnoreCase(sourceClass.getSimpleName()) && (classUtils.isPrimitiveType(sourceClass) || classUtils.isPrimitiveTypeArray(sourceClass))) { conversionFunction = getConversionProcessor(targetClass) .flatMap(cp -> getTypeConversionFunction(cp, sourceClass)); } CACHE_MANAGER.cacheObject(cacheKey, conversionFunction); return conversionFunction; }); } ConversionAnalyzer(); @SuppressWarnings("unchecked") Optional<Function<Object, Object>> getConversionFunction(final Class<?> sourceClass, final Class<?> targetClass);  }### Answer:
@Test(dataProvider = "dataGetConversionFunctionEmptyCaseTesting") public void testGetConversionFunctionReturnsAnEmptyOptional(final String testCaseDescription, final Class<?> sourceFieldType, final Class<?> destinationFieldType) { Optional<Function<Object, Object>> actual = underTest.getConversionFunction(sourceFieldType, destinationFieldType); assertThat(actual).isEmpty(); }
@Test(dataProvider = "dataGetConversionFunctionTesting") public void testGetConversionFunctionReturnsTheExpectedConversionFunction(final String testCaseDescription, final Class<?> sourceFieldType, final Class<?> destinationFieldType, final Function<?, ?> expectedConversionFunction) { Optional<Function<Object, Object>> actual = underTest.getConversionFunction(sourceFieldType, destinationFieldType); assertThat(actual).contains((Function<Object, Object>) expectedConversionFunction); }