Search in sources :

Example 1 with StatefulGraphEvaluationState

use of org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState in project kie-wb-common by kiegroup.

the class ConnectorParentsMatchContainmentHandlerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    super.setup();
    candidates = Collections.singletonList(nodeA);
    when(graphHandler.getDefinitionAdapter().getId(eq(connectorDef))).thenReturn(DefinitionId.build(DEF_EDGE_ID));
    this.connector = graphHandler.newEdge(EDGE_UUID, Optional.of(connectorDef));
    GraphEvaluationState state = new StatefulGraphEvaluationState(graphHandler.graph);
    when(containmentContext.getState()).thenReturn(state);
    when(ruleExtension.getId()).thenReturn(DEF_EDGE_ID);
    when(ruleExtension.getArguments()).thenReturn(new String[] { "violation1" });
    tested = new ConnectorParentsMatchContainmentHandler(graphHandler.getDefinitionManager(), new TreeWalkTraverseProcessorImpl());
}
Also used : StatefulGraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState) GraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.GraphEvaluationState) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) StatefulGraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState) Before(org.junit.Before)

Example 2 with StatefulGraphEvaluationState

use of org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState in project kie-wb-common by kiegroup.

the class ConnectorParentsMatchConnectionHandlerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    super.setup();
    this.graph = graphHandler.graph;
    when(graphHandler.getDefinitionAdapter().getId(eq(connectorDef))).thenReturn(DefinitionId.build(DEF_EDGE_ID));
    this.connector = graphHandler.newEdge(EDGE_UUID, Optional.of(connectorDef));
    GraphEvaluationState state = new StatefulGraphEvaluationState(graph);
    when(connectionContext.getState()).thenReturn(state);
    when(connectionContext.getConnector()).thenReturn(connector);
    when(ruleExtension.getId()).thenReturn(DEF_EDGE_ID);
    when(ruleExtension.getArguments()).thenReturn(new String[] { "violation1" });
    tested = new ConnectorParentsMatchConnectionHandler(graphHandler.getDefinitionManager());
}
Also used : StatefulGraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState) GraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.GraphEvaluationState) StatefulGraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState) Before(org.junit.Before)

Example 3 with StatefulGraphEvaluationState

use of org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState in project kie-wb-common by kiegroup.

the class GraphConnectionEvaluationHandlerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    super.setup();
    final Set<String> edgeLabels = Collections.singleton(EDGE_ID);
    when(edge.getContent()).thenReturn(edgeContent);
    when(edge.getLabels()).thenReturn(edgeLabels);
    when(edgeContent.getDefinition()).thenReturn(edgeDefinition);
    when(definitionAdapter.getId(eq(edgeDefinition))).thenReturn(DefinitionId.build(EDGE_ID));
    when(context.getConnector()).thenReturn(edge);
    when(context.getSource()).thenReturn(Optional.of(parent));
    when(context.getTarget()).thenReturn(Optional.of(candidate));
    StatefulGraphEvaluationState state = new StatefulGraphEvaluationState(GraphImpl.build("graphUUID"));
    when(context.getState()).thenReturn(state);
    tested = new GraphConnectionEvaluationHandler(definitionManager, HANDLER);
}
Also used : StatefulGraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState) Before(org.junit.Before)

Example 4 with StatefulGraphEvaluationState

use of org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState in project kie-wb-common by kiegroup.

the class ConnectorCardinalityEvaluationHandlerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    super.setup();
    final Set<String> edgeLabels = Collections.singleton(EDGE_ID);
    evalUtils = spy(new GraphEvaluationHandlerUtils(definitionManager));
    StatefulGraphEvaluationState graphEvaluationState = new StatefulGraphEvaluationState(mock(Graph.class));
    when(context.getState()).thenReturn(graphEvaluationState);
    when(context.getCandidate()).thenReturn(candidate);
    when(context.getEdge()).thenReturn(edge);
    when(edge.getContent()).thenReturn(edgeContent);
    when(edge.getLabels()).thenReturn(edgeLabels);
    when(edgeContent.getDefinition()).thenReturn(edgeDefinition);
    when(definitionAdapter.getId(eq(edgeDefinition))).thenReturn(DefinitionId.build(EDGE_ID));
    tested = new ConnectorCardinalityEvaluationHandler(evalUtils, new EdgeCardinalityEvaluationHandler());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) StatefulGraphEvaluationState(org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)4 StatefulGraphEvaluationState (org.kie.workbench.common.stunner.core.rule.context.impl.StatefulGraphEvaluationState)4 GraphEvaluationState (org.kie.workbench.common.stunner.core.rule.context.GraphEvaluationState)2 Graph (org.kie.workbench.common.stunner.core.graph.Graph)1 TreeWalkTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)1