@SuppressWarnings("deprecation")
    @Test
    void require_that_component_is_not_reused_when_injected_component_is_changed() {
        Function<String, ComponentGraph> buildGraph = config -> {
            ComponentGraph graph = new ComponentGraph();

            ComponentNode rootComponent = mockComponentNode(ComponentTakingComponent.class, "root_component");

            String configId = "componentTakingConfigId";
            ComponentNode injectedComponent = mockComponentNode(ComponentTakingConfig.class, "injected_component", configId);

            rootComponent.inject(injectedComponent);

            graph.add(rootComponent);
            graph.add(injectedComponent);

            graph.complete();
            graph.setAvailableConfigs(Map.of(new ConfigKey<>(TestConfig.class, configId),
                    ConfigGetter.getConfig(TestConfig.class, "raw: stringVal \"" + config + "\"")));

            return graph;
        };

        ComponentGraph oldGraph = buildGraph.apply("oldGraph");
        ComponentTakingComponent oldInstance = getComponent(oldGraph, ComponentTakingComponent.class);

        ComponentGraph newGraph = buildGraph.apply("newGraph");
        newGraph.reuseNodes(oldGraph);
        ComponentTakingComponent newInstance = getComponent(newGraph, ComponentTakingComponent.class);

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