### Question:
SearchableClasses { public Class<?> findNearestAssignableFrom(Class<?> clazz) { if ((clazz == Object.class) || (clazz == null)) { return null; } if (classes.contains(clazz)) { return clazz; } for (Class<?> interfaceClass : clazz.getInterfaces()) { Class<?> classFound = findNearestAssignableFrom(interfaceClass); if (classFound != null) { return classFound; } } return findNearestAssignableFrom(clazz.getSuperclass()); } SearchableClasses(Set<Class<?>> classes); Class<?> findNearestAssignableFrom(Class<?> clazz); Queue<Class<?>> findAssignablesInOrderFrom(Class<?> clazz);  }### Answer:
@Test public void whenFindNearestAssignableFromUnknownClazz_thenNullIsReturned() { Class<?> foundClazz = searchableClasses.findNearestAssignableFrom(UnknownClazz.class); assertThat(foundClazz, is(nullValue())); }
@SuppressWarnings("rawtypes") @Test public void whenfindNearestAssignableFrom_thenNearestAssignableIsReturned() { assertThat(searchableClasses.findNearestAssignableFrom(Clazz.class), sameInstance((Class) Clazz.class)); assertThat(searchableClasses.findNearestAssignableFrom(UnregisteredParentClazz.class), sameInstance((Class) GrandparentSuperInterface.class)); assertThat(searchableClasses.findNearestAssignableFrom(UnregisteredGrandparentInterface.class), sameInstance((Class) GrandparentSuperInterface.class)); }