Klasse CoverageNode
java.lang.Object
io.jenkins.plugins.coverage.model.CoverageNode
- Alle implementierten Schnittstellen:
Serializable
- Bekannte direkte Unterklassen:
FileCoverageNode
,MethodCoverageNode
,PackageCoverageNode
A hierarchical decomposition of coverage results.
- Autor:
- Ullrich Hafner
- Siehe auch:
-
Konstruktorübersicht
KonstruktorBeschreibungCoverageNode
(CoverageMetric metric, String name) Creates a new coverage item node with the given name.CoverageNode
(CoverageMetric metric, String name, CoverageTreeCreator coverageTreeCreator) Creates a new coverage item node with the given name and a mockedCoverageTreeCreator
. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
add
(CoverageLeaf leaf) Appends the specified leaf element to the list of leaves.void
add
(CoverageNode child) Appends the specified child element to the list of children.SortedMap
<CoverageMetric, org.apache.commons.lang3.math.Fraction> computeDelta
(CoverageNode reference) Computes the coverage delta between this node and the specified reference node as fractions between 0 and 1.computeDeltaAsPercentage
(CoverageNode reference) Computes the coverage delta between this node and the specified reference node as percentage between 0 and 100.protected CoverageNode
Creates a copied instance of this node that has no children, leaves, and parent yet.copyTree()
Creates a deep copy of the coverage tree with this as root node.protected CoverageNode
copyTree
(CoverageNode copiedParent) Recursively copies the coverage tree with the passedCoverageNode
as root.boolean
Filters the package structure for only package nodes which contain file nodes.find
(CoverageMetric searchMetric, String searchPath) Finds the coverage metric with the given path starting from this node.findByHashCode
(CoverageMetric searchMetric, int searchNameHashCode) Finds the coverage metric with the given hash code starting from this node.getAll
(CoverageMetric searchMetric) Returns recursively all nodes for the specified metric type.Returns recursively all nodes of the instanceFileCoverageNode
.Creates a filtered coverage tree which only contains nodes with code changes.getCoverage
(CoverageMetric searchMetric) Returns the coverage for the specified metric.int
int
Returns the most important coverage metrics.Creates a filtered coverage tree which only contains nodes with indirect coverage changes.long
long
Returns the type if the coverage metric for this node.SortedMap
<CoverageMetric, org.apache.commons.lang3.math.Fraction> Gets the coverage for each available metric as a fraction between 0 and 1.Gets the coverage for each available metric as a percentage between 0 and 100.Returns the available coverage metrics for the whole tree starting with this node.Returns a mapping of metric to coverage.getName()
Gets the parent node.Returns the name of the parent element or "-" if there is no such element.getPath()
Returns the source code path of this node.boolean
Checks whether the coverage tree contains a change coverage at all.boolean
hasChangeCoverage
(CoverageMetric coverageMetric) Checks whether the coverage tree contains a change coverage for the passedCoverageMetric
.boolean
Checks whether code any changes have been detected no matter if the code coverage is affected or not.int
hashCode()
boolean
Checks whether the coverage tree contains indirect coverage changes at all.boolean
hasIndirectCoverageChanges
(CoverageMetric coverageMetric) Checks whether the coverage tree contains indirect coverage changes for the passedCoverageMetric
.boolean
Returns whether this node has a parent node.boolean
isRoot()
Returns whether this node is the root of the tree.protected String
printCoverageFor
(CoverageMetric searchMetric) Prints the coverage for the specified element.printCoverageFor
(CoverageMetric searchMetric, Locale locale) Prints the coverage for the specified element.protected Object
Called after de-serialization to restore transient fields.void
Splits flat packages into a package hierarchy.toString()
-
Konstruktordetails
-
CoverageNode
Creates a new coverage item node with the given name.- Parameter:
metric
- the coverage metric this node belongs toname
- the human-readable name of the node
-
CoverageNode
Creates a new coverage item node with the given name and a mockedCoverageTreeCreator
.- Parameter:
metric
- the coverage metric this node belongs toname
- the human-readable name of the nodecoverageTreeCreator
- the coverage tree creator
-
-
Methodendetails
-
readResolve
Called after de-serialization to restore transient fields.- Gibt zurück:
- this
- Löst aus:
ObjectStreamException
- if the operation failed
-
getParent
Gets the parent node.- Gibt zurück:
- the parent, if existent
- Löst aus:
IllegalStateException
- if no parent exists
-
getPath
Returns the source code path of this node.- Gibt zurück:
- the element type
-
mergePath
-
getMetric
Returns the type if the coverage metric for this node.- Gibt zurück:
- the element type
-
getMetrics
Returns the available coverage metrics for the whole tree starting with this node.- Gibt zurück:
- the elements in this tree
-
getImportantMetrics
Returns the most important coverage metrics.- Gibt zurück:
- most important coverage metrics
-
getMetricsDistribution
Returns a mapping of metric to coverage. The root of the tree will be skipped.- Gibt zurück:
- a mapping of metric to coverage.
-
getMetricFractions
Gets the coverage for each available metric as a fraction between 0 and 1.- Gibt zurück:
- the coverage fractions mapped by their metric
-
getMetricPercentages
Gets the coverage for each available metric as a percentage between 0 and 100.- Gibt zurück:
- the coverage percentages mapped by their metric
-
getName
-
getChildren
-
getLeaves
-
add
Appends the specified child element to the list of children.- Parameter:
child
- the child to add
-
add
Appends the specified leaf element to the list of leaves.- Parameter:
leaf
- the leaf to add
-
isRoot
public boolean isRoot()Returns whether this node is the root of the tree.- Gibt zurück:
true
if this node is the root of the tree,false
otherwise
-
hasParent
public boolean hasParent()Returns whether this node has a parent node.- Gibt zurück:
true
if this node has a parent node,false
if it is the root of the hierarchy
-
getParentName
Returns the name of the parent element or "-" if there is no such element.- Gibt zurück:
- the name of the parent element
-
printCoverageFor
Prints the coverage for the specified element. UsesLocale.getDefault()
to format the percentage.- Parameter:
searchMetric
- the element to print the coverage for- Gibt zurück:
- coverage ratio in a human-readable format
- Siehe auch:
-
printCoverageFor
Prints the coverage for the specified element.- Parameter:
searchMetric
- the element to print the coverage forlocale
- the locale to use when formatting the percentage- Gibt zurück:
- coverage ratio in a human-readable format
-
getCoverage
Returns the coverage for the specified metric.- Parameter:
searchMetric
- the element to get the coverage for- Gibt zurück:
- coverage ratio
-
computeDelta
public SortedMap<CoverageMetric,org.apache.commons.lang3.math.Fraction> computeDelta(CoverageNode reference) Computes the coverage delta between this node and the specified reference node as fractions between 0 and 1.- Parameter:
reference
- the reference node- Gibt zurück:
- the delta coverage for each available metric as fraction
-
computeDeltaAsPercentage
public SortedMap<CoverageMetric,CoveragePercentage> computeDeltaAsPercentage(CoverageNode reference) Computes the coverage delta between this node and the specified reference node as percentage between 0 and 100.- Parameter:
reference
- the reference node- Gibt zurück:
- the delta coverage for each available metric as percentage
-
getAll
Returns recursively all nodes for the specified metric type.- Parameter:
searchMetric
- the metric to look for- Gibt zurück:
- all nodes for the given metric
-
getAllFileCoverageNodes
Returns recursively all nodes of the instanceFileCoverageNode
.- Gibt zurück:
- all file coverage nodes
- Seit:
- 3.0.0
-
find
Finds the coverage metric with the given path starting from this node.- Parameter:
searchMetric
- the coverage metric to search forsearchPath
- the path of the node- Gibt zurück:
- the result if found
-
findByHashCode
Finds the coverage metric with the given hash code starting from this node.- Parameter:
searchMetric
- the coverage metric to search forsearchNameHashCode
- the hash code of the node path- Gibt zurück:
- the result if found
-
splitPackages
public void splitPackages()Splits flat packages into a package hierarchy. Changes the internal tree structure in place. -
filterPackageStructure
Filters the package structure for only package nodes which contain file nodes. The filtered tree is required in order to calculate the package coverage. Note that packages without any files are fully removed.- Gibt zurück:
- a filtered copy of this
CoverageNode
-
hasChangeCoverage
public boolean hasChangeCoverage()Checks whether the coverage tree contains a change coverage at all. The method checks if line or branch coverage are available since these are the basic metrics which are available if changes exist.- Gibt zurück:
true
whether a change coverage exist, elsefalse
-
hasChangeCoverage
Checks whether the coverage tree contains a change coverage for the passedCoverageMetric
.- Parameter:
coverageMetric
- The coverage metric- Gibt zurück:
true
whether a change coverage exist for the coverage metric, elsefalse
-
getChangeCoverageTree
Creates a filtered coverage tree which only contains nodes with code changes. The root of the tree is this.- Gibt zurück:
- the filtered coverage tree
-
getFileAmountWithChangedCoverage
public int getFileAmountWithChangedCoverage() -
getLineAmountWithChangedCoverage
public long getLineAmountWithChangedCoverage() -
getFileAmountWithIndirectCoverageChanges
public int getFileAmountWithIndirectCoverageChanges() -
getLineAmountWithIndirectCoverageChanges
public long getLineAmountWithIndirectCoverageChanges() -
hasIndirectCoverageChanges
public boolean hasIndirectCoverageChanges()Checks whether the coverage tree contains indirect coverage changes at all. The method checks if line or branch coverage are available since these are the basic metrics which are available if changes exist.- Gibt zurück:
true
whether indirect coverage changes exist, elsefalse
-
hasIndirectCoverageChanges
Checks whether the coverage tree contains indirect coverage changes for the passedCoverageMetric
.- Parameter:
coverageMetric
- The coverage metric- Gibt zurück:
true
whether indirect coverage changes exist for the coverage metric, elsefalse
-
getIndirectCoverageChangesTree
Creates a filtered coverage tree which only contains nodes with indirect coverage changes. The root of the tree is this.- Gibt zurück:
- the filtered coverage tree
-
hasCodeChanges
public boolean hasCodeChanges()Checks whether code any changes have been detected no matter if the code coverage is affected or not.- Gibt zurück:
true
whether code changes have been detected
-
copyTree
Creates a deep copy of the coverage tree with this as root node.- Gibt zurück:
- the root node of the copied tree
-
copyTree
Recursively copies the coverage tree with the passedCoverageNode
as root.- Parameter:
copiedParent
- The root node- Gibt zurück:
- the copied tree
-
copyEmpty
Creates a copied instance of this node that has no children, leaves, and parent yet.- Gibt zurück:
- the new and empty node
-
toString
-
equals
-
hashCode
public int hashCode()
-