@Test
    void require_that_component_is_not_reused_when_injected_component_registry_has_one_component_removed() {
        Function<Boolean, ComponentGraph> buildGraph = useBothInjectedComponents -> {
            ComponentGraph graph = new ComponentGraph();
            graph.add(mockComponentNode(ComponentTakingAllSimpleComponents.class, "root_component"));

            /* Below if-else has code duplication, but explicit ordering of the two components
             * was necessary to reproduce erroneous behaviour in ComponentGraph.reuseNodes that
             * occurred before ComponentRegistryNode got its own 'equals' implementation.
             */
            if (useBothInjectedComponents) {
                graph.add(mockComponentNode(SimpleComponent.class, "injected_component2"));
                graph.add(mockComponentNode(SimpleComponent.class, "injected_component1"));
            } else {
                graph.add(mockComponentNode(SimpleComponent.class, "injected_component1"));
            }

            graph.complete();
            graph.setAvailableConfigs(Map.of());
            return graph;
        };

        ComponentGraph oldGraph = buildGraph.apply(true);
        ComponentRegistry<SimpleComponent> oldSimpleComponentRegistry = getComponent(oldGraph, ComponentTakingAllSimpleComponents.class).simpleComponents;

        ComponentGraph newGraph = buildGraph.apply(false);
        newGraph.reuseNodes(oldGraph);
        ComponentRegistry<SimpleComponent> newSimpleComponentRegistry = getComponent(newGraph, ComponentTakingAllSimpleComponents.class).simpleComponents;

        assertNotSame(newSimpleComponentRegistry, oldSimpleComponentRegistry);
    }
@author gjoranv
@author Tony Vaagenes
@author ollivir
container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ReuseComponentsTest.java