All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.tinkoff.kora.test.extension.junit5.GraphReplacementNoDeps Maven / Gradle / Ivy

There is a newer version: 1.1.15
Show newest version
package ru.tinkoff.kora.test.extension.junit5;

import org.junit.jupiter.api.extension.ExtensionConfigurationException;
import ru.tinkoff.kora.application.graph.ApplicationGraphDraw;
import ru.tinkoff.kora.application.graph.Node;

import java.util.function.Function;

record GraphReplacementNoDeps(Function function,
                                 GraphCandidate candidate) implements GraphModification {

    @Override
    public void accept(ApplicationGraphDraw graphDraw) {
        var nodesToReplace = GraphUtils.findNodeByTypeOrAssignable(graphDraw, candidate());
        if (nodesToReplace.isEmpty()) {
            throw new ExtensionConfigurationException("Can't find Nodes to Replace: " + candidate());
        }

        for (var nodeToReplace : nodesToReplace) {
            @SuppressWarnings("unchecked")
            var casted = (Node) nodeToReplace;
            graphDraw.replaceNode(casted, g -> function.apply(new DefaultKoraAppGraph(graphDraw, g)));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy