### Question:
ApplicationContextWalker { public Collection<String> getBeanDefinitionNames() { return walkContext(ctx -> asList(ctx.getBeanDefinitionNames())) .stream() .flatMap(Collection::stream) .collect(Collectors.toSet()); } ApplicationContextWalker(ApplicationContext applicationContext); BeanDefinition getBeanDefinition(String beanName); boolean hasOnlyOneBeanOfClass(Class<?> beanClass); Collection<String> getBeanDefinitionNames();  }### Answer:
@Test public void should_find_names_of_beans_from_complete_context_hierarchy() { final String childName = "child"; final String middleName = "middle"; final String parentName = "parent"; final ApplicationContext childContext = buildAppContext(Stream.of(bean(childName, new Object()))); final ApplicationContext middleContext = buildAppContext(childContext, Stream.of(bean(middleName, new Object()))); final ApplicationContext parentContext = buildAppContext(middleContext, Stream.of( withEmptyDoubleRegistry(), bean(parentName, new Object()))); final ApplicationContextWalker walker = new ApplicationContextWalker(parentContext); final Collection<String> beanNames = walker.getBeanDefinitionNames(); assertEquals( new HashSet<>(asList(childName, middleName, parentName, BEAN_NAME)), new HashSet<>(beanNames)); }