Klasse CoverageNode

java.lang.Object
io.jenkins.plugins.coverage.model.CoverageNode
Alle implementierten Schnittstellen:
Serializable
Bekannte direkte Unterklassen:
FileCoverageNode, MethodCoverageNode, PackageCoverageNode

public class CoverageNode extends Object implements Serializable
A hierarchical decomposition of coverage results.
Autor:
Ullrich Hafner
Siehe auch:
  • Konstruktordetails

    • CoverageNode

      public CoverageNode(CoverageMetric metric, String name)
      Creates a new coverage item node with the given name.
      Parameter:
      metric - the coverage metric this node belongs to
      name - the human-readable name of the node
    • CoverageNode

      public CoverageNode(CoverageMetric metric, String name, CoverageTreeCreator coverageTreeCreator)
      Creates a new coverage item node with the given name and a mocked CoverageTreeCreator.
      Parameter:
      metric - the coverage metric this node belongs to
      name - the human-readable name of the node
      coverageTreeCreator - the coverage tree creator
  • Methodendetails

    • readResolve

      protected Object readResolve() throws ObjectStreamException
      Called after de-serialization to restore transient fields.
      Gibt zurück:
      this
      Löst aus:
      ObjectStreamException - if the operation failed
    • getParent

      public CoverageNode getParent()
      Gets the parent node.
      Gibt zurück:
      the parent, if existent
      Löst aus:
      IllegalStateException - if no parent exists
    • getPath

      public String getPath()
      Returns the source code path of this node.
      Gibt zurück:
      the element type
    • mergePath

      protected String mergePath(String localPath)
    • getMetric

      public CoverageMetric getMetric()
      Returns the type if the coverage metric for this node.
      Gibt zurück:
      the element type
    • getMetrics

      public SortedSet<CoverageMetric> getMetrics()
      Returns the available coverage metrics for the whole tree starting with this node.
      Gibt zurück:
      the elements in this tree
    • getImportantMetrics

      public Collection<CoverageMetric> getImportantMetrics()
      Returns the most important coverage metrics.
      Gibt zurück:
      most important coverage metrics
    • getMetricsDistribution

      public SortedMap<CoverageMetric,Coverage> 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

      public SortedMap<CoverageMetric,org.apache.commons.lang3.math.Fraction> 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

      public SortedMap<CoverageMetric,CoveragePercentage> 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

      public String getName()
    • getChildren

      public List<CoverageNode> getChildren()
    • getLeaves

      public List<CoverageLeaf> getLeaves()
    • add

      public void add(CoverageNode child)
      Appends the specified child element to the list of children.
      Parameter:
      child - the child to add
    • add

      public void add(CoverageLeaf leaf)
      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

      public String 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

      public String printCoverageFor(CoverageMetric searchMetric)
      Prints the coverage for the specified element. Uses Locale.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

      public String printCoverageFor(CoverageMetric searchMetric, Locale locale)
      Prints the coverage for the specified element.
      Parameter:
      searchMetric - the element to print the coverage for
      locale - the locale to use when formatting the percentage
      Gibt zurück:
      coverage ratio in a human-readable format
    • getCoverage

      public Coverage getCoverage(CoverageMetric searchMetric)
      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

      public List<CoverageNode> getAll(CoverageMetric searchMetric)
      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

      public List<FileCoverageNode> getAllFileCoverageNodes()
      Returns recursively all nodes of the instance FileCoverageNode.
      Gibt zurück:
      all file coverage nodes
      Seit:
      3.0.0
    • find

      public Optional<CoverageNode> find(CoverageMetric searchMetric, String searchPath)
      Finds the coverage metric with the given path starting from this node.
      Parameter:
      searchMetric - the coverage metric to search for
      searchPath - the path of the node
      Gibt zurück:
      the result if found
    • findByHashCode

      public Optional<CoverageNode> findByHashCode(CoverageMetric searchMetric, int searchNameHashCode)
      Finds the coverage metric with the given hash code starting from this node.
      Parameter:
      searchMetric - the coverage metric to search for
      searchNameHashCode - 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

      public CoverageNode 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, else false
    • hasChangeCoverage

      public boolean hasChangeCoverage(CoverageMetric coverageMetric)
      Checks whether the coverage tree contains a change coverage for the passed CoverageMetric.
      Parameter:
      coverageMetric - The coverage metric
      Gibt zurück:
      true whether a change coverage exist for the coverage metric, else false
    • getChangeCoverageTree

      public CoverageNode 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, else false
    • hasIndirectCoverageChanges

      public boolean hasIndirectCoverageChanges(CoverageMetric coverageMetric)
      Checks whether the coverage tree contains indirect coverage changes for the passed CoverageMetric.
      Parameter:
      coverageMetric - The coverage metric
      Gibt zurück:
      true whether indirect coverage changes exist for the coverage metric, else false
    • getIndirectCoverageChangesTree

      public CoverageNode 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

      public CoverageNode 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

      protected CoverageNode copyTree(@CheckForNull CoverageNode copiedParent)
      Recursively copies the coverage tree with the passed CoverageNode as root.
      Parameter:
      copiedParent - The root node
      Gibt zurück:
      the copied tree
    • copyEmpty

      protected CoverageNode 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

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object
    • equals

      public boolean equals(Object o)
      Setzt außer Kraft:
      equals in Klasse Object
    • hashCode

      public int hashCode()
      Setzt außer Kraft:
      hashCode in Klasse Object