Class ProjectSummary

java.lang.Object
pl.tfij.test.modulesize.ProjectSummary

public class ProjectSummary extends Object
The ProjectSummary class provides methods for analyzing and summarizing project modules. It allows to verify module sizes, generate Mermaid pie charts, save charts to files, and retrieve module summaries.
  • Method Details

    • verifyNoEmptyModules

      public ProjectSummary verifyNoEmptyModules()
      Verifies whether none of the defined modules is empty.
      Returns:
      The ProjectSummary instance to allow method chaining.
      Throws:
      AssertionError - When any of the modules is empty.
    • verifyEachModuleRelativeSizeIsSmallerThan

      public ProjectSummary verifyEachModuleRelativeSizeIsSmallerThan(double threshold)
      Verifies that the relative size of each moduleName is smaller than the given threshold.
      Parameters:
      threshold - The maximum relative size allowed for each moduleName. Must be a positive number in the range (0, 1].
      Returns:
      The ProjectSummary instance to allow method chaining.
      Throws:
      IllegalArgumentException - if the threshold is not within the valid range.
      AssertionError - if any moduleName's relative size exceeds the threshold.
    • verifyModuleRelativeSizeIsSmallerThan

      public ProjectSummary verifyModuleRelativeSizeIsSmallerThan(String module, double threshold)
      Verifies that the relative size of the specified moduleName is smaller than the given threshold.
      Parameters:
      module - The name of the moduleName to verify.
      threshold - The maximum relative size allowed for the moduleName.
      Returns:
      The ProjectSummary instance to allow method chaining.
      Throws:
      IllegalArgumentException - if the specified moduleName is not defined.
      IllegalArgumentException - if the threshold is not within the valid range.
      AssertionError - if the relative size of the moduleName exceeds the threshold.
    • verifyUndefinedModuleNumberOfFilesIsSmallerThan

      public ProjectSummary verifyUndefinedModuleNumberOfFilesIsSmallerThan(int allowedFileCount)
      Verifies that the number of files in the undefined moduleName is smaller than the specified allowedFileCount.
      Parameters:
      allowedFileCount - The maximum number of files allowed in the undefined moduleName. Value must be positive or zero int number.
      Returns:
      The ProjectSummary instance to allow method chaining.
      Throws:
      IllegalArgumentException - if the given allowedFileCount has invalid value.
      AssertionError - if the number of files in the undefined moduleName exceeds the allowedFileCount.
    • createMermaidPieChart

      public String createMermaidPieChart()
      Generates a Mermaid pie chart representation based on analyzed modules.
      Returns:
      A string representing the Mermaid pie chart.
    • saveMermaidPieChart

      public ProjectSummary saveMermaidPieChart(Path target)
      Saves the Mermaid pie chart representation of the project summary to the specified target path.
      Parameters:
      target - the path where the Mermaid pie chart will be saved.
      Returns:
      The ProjectSummary instance to allow method chaining.
      Throws:
      ModuleSizeCalculatorException - if an I/O error occurs while saving the Mermaid chart
      IllegalArgumentException - if the target path is null
    • modulesSummary

      public List<ProjectSummary.ModuleSummary> modulesSummary()
      Generates a summary of the analyzed modules.
      Returns:
      A list containing ModuleSummary objects representing each analyzed moduleName.
    • numberOfFiles

      public int numberOfFiles()
      Returns:
      total number of files in the project.
    • linesOfCode

      public int linesOfCode()
      Returns:
      total number of lines of code in the project.