Top Description Inners Fields Constructors Methods
org.testng.internal

public Class DynamicGraph<T>

extends Object
implements IDynamicGraph<T>
Class Inheritance
All Implemented Interfaces
org.testng.IDynamicGraph
Imports
java.util.Collection, .Collections, .List, .Map, .Optional, .Set, java.util.concurrent.ConcurrentHashMap, org.testng.IDynamicGraph, .IExecutionVisualiser, org.testng.collections.Lists, .Maps, .Sets

Representation of the graph of methods.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DynamicGraph.Edges<T>

Manage edges and weights between nodes.

Field Summary

Modifier and TypeField and Description
private final DynamicGraph.Edges<T>
private final Set<T>
private final Set<T>
private final Set<T>
private Set<IExecutionVisualiser>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addEdge(int
- Represents one of org.testng.TestRunner.PriorityWeight ordinals indicating the weightage of a particular node in the graph
weight
,
T
- Represents the edge that depends on another edge.
from
,
T
- Represents the edge on which another edge depends upon.
to
)

Implements org.testng.IDynamicGraph.addEdge.

public void
addEdges(int weight, T from, Iterable<T> tos)

Implements org.testng.IDynamicGraph.addEdges.

Add an edge between two nodes.
public boolean
addNode(T node)

Implements org.testng.IDynamicGraph.addNode.

Add a node to the graph.
private List<T>
dependencies(Map<T, Integer> dependencies)

private static <T> String
public List<T>
pack-priv Map<T, Map<T, Integer>>
getEdges()

For tests only

public List<T>

Returns:

a set of all the nodes that don't depend on any other nodes.
getFreeNodes
()

Implements org.testng.IDynamicGraph.getFreeNodes.

public int

Returns:

the number of nodes in this graph.
getNodeCount
()

Implements org.testng.IDynamicGraph.getNodeCount.

public int
public Set<T>
public List<T>
public void
setStatus(Collection<T> nodes, IDynamicGraph.Status status)

Implements org.testng.IDynamicGraph.setStatus, org.testng.IDynamicGraph.setStatus.

Set the status for a set of nodes.
public void
setStatus(T node, IDynamicGraph.Status status)

Implements org.testng.IDynamicGraph.setStatus.

Set the status for a node.
public void
public String

Returns:

a .dot file (GraphViz) version of this graph.
toDot
()

Implements org.testng.IDynamicGraph.toDot.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

m_edgesback to summary
private final DynamicGraph.Edges<T> m_edges
m_nodesFinishedback to summary
private final Set<T> m_nodesFinished
m_nodesReadyback to summary
private final Set<T> m_nodesReady
m_nodesRunningback to summary
private final Set<T> m_nodesRunning
visualisersback to summary
private Set<IExecutionVisualiser> visualisers

Constructor Detail

DynamicGraphback to summary
public DynamicGraph()

Method Detail

addEdgeback to summary
public void addEdge(int weight, T from, T to)

Implements org.testng.IDynamicGraph.addEdge.

Parameters
weight:int

- Represents one of org.testng.TestRunner.PriorityWeight ordinals indicating the weightage of a particular node in the graph

from:T

- Represents the edge that depends on another edge.

to:T

- Represents the edge on which another edge depends upon.

addEdgesback to summary
public void addEdges(int weight, T from, Iterable<T> tos)

Implements org.testng.IDynamicGraph.addEdges.

Add an edge between two nodes.

addNodeback to summary
public boolean addNode(T node)

Implements org.testng.IDynamicGraph.addNode.

Add a node to the graph.

dependenciesback to summary
private List<T> dependencies(Map<T, Integer> dependencies)
dotShortNameback to summary
private static <T> String dotShortName(T t)
getDependenciesForback to summary
public List<T> getDependenciesFor(T node)

Implements org.testng.IDynamicGraph.getDependenciesFor.

getEdgesback to summary
pack-priv Map<T, Map<T, Integer>> getEdges()

For tests only

getFreeNodesback to summary
public List<T> getFreeNodes()

Implements org.testng.IDynamicGraph.getFreeNodes.

Returns:List<T>

a set of all the nodes that don't depend on any other nodes.

getNodeCountback to summary
public int getNodeCount()

Implements org.testng.IDynamicGraph.getNodeCount.

Returns:int

the number of nodes in this graph.

getNodeCountWithStatusback to summary
public int getNodeCountWithStatus(IDynamicGraph.Status status)

Implements org.testng.IDynamicGraph.getNodeCountWithStatus.

getNodesWithStatusback to summary
public Set<T> getNodesWithStatus(IDynamicGraph.Status status)

Implements org.testng.IDynamicGraph.getNodesWithStatus.

getUpstreamDependenciesForback to summary
public List<T> getUpstreamDependenciesFor(T node)

Overrides default org.testng.IDynamicGraph.getUpstreamDependenciesFor.

Annotations
@Override
setStatusback to summary
public void setStatus(Collection<T> nodes, IDynamicGraph.Status status)

Implements org.testng.IDynamicGraph.setStatus, org.testng.IDynamicGraph.setStatus.

Set the status for a set of nodes.

setStatusback to summary
public void setStatus(T node, IDynamicGraph.Status status)

Implements org.testng.IDynamicGraph.setStatus.

Set the status for a node.

setVisualisersback to summary
public void setVisualisers(Set<IExecutionVisualiser> listener)

Implements org.testng.IDynamicGraph.setVisualisers.

toDotback to summary
public String toDot()

Implements org.testng.IDynamicGraph.toDot.

Returns:String

a .dot file (GraphViz) version of this graph.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
org.testng.internal back to summary

private Class DynamicGraph.Edges<T>

extends Object
Class Inheritance

Manage edges and weights between nodes.

Field Summary

Modifier and TypeField and Description
private final Map<T, Map<T, Integer>>
private final Map<T, Map<T, Integer>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
addEdge(int weight, T from, T to, boolean ignoreCycles)

private static <T> void
addEdgeToMap(Map<T, Map<T, Integer>> map, T n1, T n2, int weight)

pack-priv void
appendDotEdges(StringBuilder sb, Set<T> finished)

private Integer

Returns:

the weight of the reversed edge or null if edge does not exist
findReversedEdge
(T
- the from edge
from
,
T
- the to edge
to
)

Return the weight of the edge in the graph that is the reversed direction of edge.

pack-priv Map<T, Integer>
from(T node)

pack-priv Set<T>

Returns:

the set of nodes that have outgoing edges.
fromNodes
()

pack-priv Map<T, Map<T, Integer>>
getEdges()

Allow raw access to the edges, but protect inside unmodifiableMaps.

pack-priv int
pack-priv boolean
hasAllEdgesWithWeight(T node, int level)

private static <T> void
removeEdgesFromMap(Map<T, Map<T, Integer>> map, Collection<T> nodes, T node)

Remove edges from a map given a node and a list of destination nodes.

pack-priv void
removeNode(T
Node to remove.
node
)

Remove a node from the graph and all associated edges.

pack-priv Map<T, Integer>
to(T node)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

m_incomingEdgesback to summary
private final Map<T, Map<T, Integer>> m_incomingEdges
m_outgoingEdgesback to summary
private final Map<T, Map<T, Integer>> m_outgoingEdges

Constructor Detail

Edgesback to summary
private Edges()

Method Detail

addEdgeback to summary
public void addEdge(int weight, T from, T to, boolean ignoreCycles)
addEdgeToMapback to summary
private static <T> void addEdgeToMap(Map<T, Map<T, Integer>> map, T n1, T n2, int weight)
appendDotEdgesback to summary
pack-priv void appendDotEdges(StringBuilder sb, Set<T> finished)
findReversedEdgeback to summary
private Integer findReversedEdge(T from, T to)

Return the weight of the edge in the graph that is the reversed direction of edge. For example, if edge a -> b exists, and edge b -> a is passed in, then return a -> b.

Parameters
from:T

- the from edge

to:T

- the to edge

Returns:Integer

the weight of the reversed edge or null if edge does not exist

fromback to summary
pack-priv Map<T, Integer> from(T node)
fromNodesback to summary
pack-priv Set<T> fromNodes()
Returns:Set<T>

the set of nodes that have outgoing edges.

getEdgesback to summary
pack-priv Map<T, Map<T, Integer>> getEdges()

Allow raw access to the edges, but protect inside unmodifiableMaps. This is for tests, toString and toDot.

getLowestEdgeWeightback to summary
pack-priv int getLowestEdgeWeight(Set<T> nodes)
hasAllEdgesWithWeightback to summary
pack-priv boolean hasAllEdgesWithWeight(T node, int level)
removeEdgesFromMapback to summary
private static <T> void removeEdgesFromMap(Map<T, Map<T, Integer>> map, Collection<T> nodes, T node)

Remove edges from a map given a node and a list of destination nodes. Given:

m_outgoingEdges:
   a -> b
        c
        d
m_incomingEdges:
   b -> a
   c -> a
   d -> a

Then, calling this method to remove node c on both maps as done in removeNode(), would result in a -> c and c -> a edges being removed.
removeNodeback to summary
pack-priv void removeNode(T node)

Remove a node from the graph and all associated edges. Each edge needs to be removed from both maps to keep the maps in sync.

Parameters
node:T

Node to remove.

toback to summary
pack-priv Map<T, Integer> to(T node)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override