java.lang.Object
com.parasoft.findings.jenkins.coverage.model.Node
com.parasoft.findings.jenkins.coverage.model.FileNode
All Implemented Interfaces:
Serializable

public final class FileNode extends Node
A Node for a specific file. It stores the actual file name along with the coverage information.
Author:
Ullrich Hafner
See Also:
  • Constructor Details

    • FileNode

      public FileNode(String name, edu.hm.hafner.util.TreeString relativePath)
      Creates a new FileNode with the given name.
      Parameters:
      name - the human-readable name of the node
      relativePath - the relative path of the file
    • FileNode

      public FileNode(String name, String relativePath)
      Creates a new FileNode with the given name.
      Parameters:
      name - the human-readable name of the node
      relativePath - the relative path of the file
  • Method Details

    • copy

      public FileNode copy()
      Description copied from class: Node
      Creates a copy of this instance that has no children and no parent yet. Node properties from the parent class Node must not be copied. All other immutable properties need to be copied one by one.
      Specified by:
      copy in class Node
      Returns:
      the copied node
    • matches

      public boolean matches(Metric searchMetric, String searchName)
      Description copied from class: Node
      Returns whether this node matches the specified metric and name.
      Overrides:
      matches in class Node
      Parameters:
      searchMetric - the metric to search for
      searchName - the name of the node
      Returns:
      the result if found
    • matches

      public boolean matches(Metric searchMetric, int searchNameHashCode)
      Description copied from class: Node
      Returns whether this node matches the specified metric and name.
      Overrides:
      matches in class Node
      Parameters:
      searchMetric - the metric to search for
      searchNameHashCode - the hash code of the node name
      Returns:
      the result if found
    • getModifiedLines

      public SortedSet<Integer> getModifiedLines()
    • hasModifiedLines

      public boolean hasModifiedLines()
      Returns whether this file has been modified in the active change set.
      Overrides:
      hasModifiedLines in class Node
      Returns:
      true if this file has been modified in the active change set, false otherwise
    • hasModifiedLine

      public boolean hasModifiedLine(int line)
      Returns whether this file has been modified at the specified line.
      Parameters:
      line - the line to check
      Returns:
      true if this file has been modified at the specified line, false otherwise
    • addModifiedLines

      public void addModifiedLines(int... lines)
      Marks the specified lines as being modified.
      Parameters:
      lines - the modified code lines
    • filterTreeByModifiedLines

      protected Optional<Node> filterTreeByModifiedLines()
      Overrides:
      filterTreeByModifiedLines in class Node
    • filterTreeByModifiedFiles

      protected Optional<Node> filterTreeByModifiedFiles()
      Overrides:
      filterTreeByModifiedFiles in class Node
    • filterTreeByIndirectChanges

      protected Optional<Node> filterTreeByIndirectChanges()
      Overrides:
      filterTreeByIndirectChanges in class Node
    • addIndirectCoverageChange

      public void addIndirectCoverageChange(int line, int hitsDelta)
      Adds an indirect coverage change for a specific line.
      Parameters:
      line - The line with the coverage change
      hitsDelta - The delta of the coverage hits before and after the code changes
    • getIndirectCoverageChanges

      public SortedMap<Integer,Integer> getIndirectCoverageChanges()
    • getLinesWithCoverage

      public NavigableSet<Integer> getLinesWithCoverage()
    • hasCoverageForLine

      public boolean hasCoverageForLine(int line)
      Returns whether this file has a coverage result for the specified line.
      Parameters:
      line - the line to check
      Returns:
      true if this file has a coverage result for the specified line, false otherwise
    • getFiles

      public Set<String> getFiles()
      Description copied from class: Node
      Returns the file names that are contained within the subtree of this node.
      Overrides:
      getFiles in class Node
      Returns:
      the file names
    • hasIndirectCoverageChanges

      public boolean hasIndirectCoverageChanges()
      Returns whether the coverage of this node is affected indirectly by the tests in the change set.
      Returns:
      true if this node is affected indirectly by the tests.
    • computeDelta

      public void computeDelta(FileNode referenceFile)
      Computes the delta of all values between this file and the given reference file. Values that are not present in both files are ignored.
      Parameters:
      referenceFile - the file to compare with this file
    • getDelta

      public org.apache.commons.lang3.math.Fraction getDelta(Metric metric)
      Returns the delta for the specified metric. If no delta is available for the specified metric, then 0 is returned.
      Parameters:
      metric - the metric to get the delta for
      Returns:
      the delta for the specified metric
    • hasDelta

      public boolean hasDelta(Metric metric)
      Returns whether this file has a delta result for the specified metric.
      Parameters:
      metric - the metric to check
      Returns:
      true has delta results are available, false otherwise
    • getCoveredAndModifiedLines

      public SortedSet<Integer> getCoveredAndModifiedLines()
      Returns the lines with code coverage that also have been modified.
      Returns:
      the lines with code coverage that also have been modified
    • hasCoveredAndModifiedLines

      public boolean hasCoveredAndModifiedLines()
      Returns whether this file has lines with code coverage that also have been modified.
      Returns:
      true if this file has lines with code coverage that also have been modified, false otherwise.
    • addCounters

      public void addCounters(int lineNumber, int covered, int missed)
      Add the coverage counters for the specified line.
      Parameters:
      lineNumber - the line number to add the counters for
      covered - the number of covered items
      missed - the number of missed items
    • getCoveredCounters

      public int[] getCoveredCounters()
    • getMissedCounters

      public int[] getMissedCounters()
    • getCoveredOfLine

      public int getCoveredOfLine(int line)
      Returns the number of covered items for the specified line.
      Parameters:
      line - the line to check
      Returns:
      the number of covered items for the specified line
    • getMissedOfLine

      public int getMissedOfLine(int line)
      Returns the number of missed items for the specified line.
      Parameters:
      line - the line to check
      Returns:
      the number of missed items for the specified line
    • getMissedLines

      public NavigableSet<Integer> getMissedLines()
      Returns the lines that have no line coverage. Note that lines that have no branch coverage are not included as these are reported separately in getPartiallyCoveredLines().
      Returns:
      the lines that have no line coverage
    • getSurvivedMutationsPerLine

      public NavigableMap<Integer,List<Mutation>> getSurvivedMutationsPerLine()
      Returns the lines that contain survived mutations. The returned map contains the line number as the key and a list of survived mutations as value.
      Returns:
      the lines that have no line coverage
    • getMutationsPerLine

      public NavigableMap<Integer,List<Mutation>> getMutationsPerLine()
      Returns the lines that contain mutations. The returned map contains the line number as the key and a list of mutations as value.
      Returns:
      the lines that have no line coverage
    • getPartiallyCoveredLines

      public NavigableMap<Integer,Integer> getPartiallyCoveredLines()
      Returns the lines that have a branch coverage less than 100%. The returned map contains the line number as the key and the number of missed branches as value.
      Returns:
      the mapping of not fully covered lines to the number of missed branches
    • getCounters

      public NavigableMap<Integer,Integer> getCounters()
    • addMutation

      public void addMutation(Mutation mutation)
      Adds a mutation to the method.
      Parameters:
      mutation - the mutation to add
    • getMutations

      public List<Mutation> getMutations()
    • createClassNode

      public ClassNode createClassNode(String className)
      Create a new class node with the given name and add it to the list of children.
      Parameters:
      className - the class name
      Returns:
      the created and linked class node
    • findOrCreateClassNode

      public ClassNode findOrCreateClassNode(String className)
      Searches for the specified class node. If the class node is not found then a new class node will be created and linked to this file node.
      Parameters:
      className - the class name
      Returns:
      the created and linked class node
      See Also:
    • getRelativePath

      public String getRelativePath()
      Returns the relative path of the file. If no relative path is set then the name of this node is returned.
      Returns:
      the relative path of the file
    • setRelativePath

      public void setRelativePath(edu.hm.hafner.util.TreeString relativePath)
      Sets the relative path of the file.
      Parameters:
      relativePath - the relative path
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Node
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Node