import { MetaTable } from '../model/index.js'; import { TestcaseDefinitionDecision } from './TestcaseDefinitionDecision.js'; import { SectionErrorInterface, SectionInterface } from './interface/SectionInterface.js'; import { SectionType } from './sections/SectionTypeEnum.js'; import { FieldSectionDefinition } from './sections/FieldSectionDefinition.js'; import { SummarySectionDefinition } from './sections/SummarySectionDefinition.js'; import { MultiplicitySectionDefinition } from './sections/MultiplicitySectionDefinition.js'; import { NeverExecuteSectionDefinition } from './sections/NeverExecuteSectionDefinition.js'; import { ExecuteSectionDefinition } from './sections/ExecuteSectionDefinition.js'; import { GeneratorSwitchSectionDefinition } from './sections/GeneratorSwitchSectionDefinition.js'; import { FilterSectionDefinition } from './sections/FilterSectionDefinition.js'; import { TagSectionDefinition } from './sections/TagSectionDefinition.js'; import { MultiRowSectionDefinition } from './sections/MultiRowSectionDefinition.js'; import { TableDecisionInterface } from './interface/TableDecisionInterface.js'; import { LoggerInterface } from '../logger/index.js'; export interface TableDecisionOptions { /** The file name of the table */ fileName: string; /** The human-readable name of the table */ tableName: string; /** Logger instance for this model */ logger: LoggerInterface; } /** * Implementation of a decision table model. * * This class manages test cases and their associated sections for a decision table. * It maintains the order of test cases, stores their definitions, and holds the definitions of various sections, * such as field, summary, multiplicity, etc. It provides methods to retrieve test cases by name, iterate over * test cases for execution, calculate summary information, validate the model, and add new sections or test cases. */ export declare class TableDecision implements TableDecisionInterface { /** The table type, set to the constant TABLE_TYPE_DECISION_TABLE */ readonly tableType: string; /** Logger instance used for logging operations */ logger: LoggerInterface; /** The file name from which the table is loaded */ fileName: string; /** The human-readable name of the table */ tableName: string; /** Array of test case IDs defining the order in which test cases are processed */ testcaseOrder: string[]; /** Mapping of test case IDs to their TestcaseDefinitionDecision objects */ testcases: Record; /** Mapping of section IDs to section definitions */ sections: Record; /** Array of section IDs representing the order of sections in the table */ sectionOrder: string[]; /** * Map to enforce that sections which should exist only once are not duplicated. * The key is the section type and the value is the corresponding section definition. */ singleCheck: Map; /** * Set to store unique keys for sections (combination of section type and section name) * to ensure that section names are unique within the same type. */ sectionNames: Set; /** * Constructs a new instance of TableDecision. * @param opts - Options for initializing the table, including fileName, tableName, and logger. */ constructor(opts: TableDecisionOptions); /** * Returns the meta-information of the table. * @returns An object containing fileName, tableName, and tableType. */ get tableMeta(): MetaTable; /** * Retrieves the test case definition for the specified test case name. * Iterates over the test cases in order and returns the one matching the given name. * @param testcaseName - The name of the test case to retrieve. * @returns The matching TestcaseDefinitionDecision. * @throws Error if no matching test case is found. */ getTestcaseForName(testcaseName: string): TestcaseDefinitionDecision; /** * Generator function that yields all test cases intended for execution. * For each test case marked for execution, the method clones the test case definition. * If a test case has a multiplicity greater than one, its name is updated to include the instance number. * @returns A generator yielding cloned TestcaseDefinitionDecision objects. */ getTestcasesForExecution(): Generator; /** * Parses a test case name that may represent a range. * If the input is a range (e.g., "[tc12-14]"), it expands it to an array of individual test case names. * Otherwise, it returns an array containing the original test case name. * @param testcaseName - The test case name or range string. * @returns An array of test case names. */ processRanges(testcaseName: string): string[]; /** * Calculates summary values for each section and updates the test case data. * Iterates over each test case and section, calculating multiplicative summaries based on * counts from field sub-sections, and updates the summary section with totals and percentages. * @throws Error if the summary section is missing. */ calculate(): void; /** * Validates the decision table model by checking for configuration and data issues. * Validation rules include: * - The table must have a name. * - There must be at least one field section. * - Field names must be unique within the table. * - The table must contain at least one test case. * @returns An array of validation issues, each conforming to SectionErrorInterface. */ validate(): SectionErrorInterface[]; /** * Validates a given section by invoking its own validate method. * Appends any validation issues found to the provided issues array. * @param section - The section to validate. * @param issues - The array to store any validation issues. */ private validateSection; /** * Validates each test case against a given section. * Iterates over all test cases and collects validation issues from each test case's validate method. * @param section - The section against which to validate the test cases. * @param issues - The array to store any validation issues. */ private validateTestcase; /** * Adds a new section to the table model. * Ensures that the section name is unique for its type and that sections which should only appear once are not duplicated. * Validates the insertion position and updates the sections record and sectionOrder array. * @param sectionDefinition - The section definition to be added. * @param position - (Optional) The position at which to insert the new section. * @returns The added section definition. * @throws Error if the section name is duplicated or if a single-instance section is added more than once. */ private addNewSection; /** * Adds a new test case to the table. * Creates a new TestcaseDefinitionDecision instance with the current table meta-information, * inserts it into the testcases record, and updates the testcaseOrder array. * @param name - The name for the new test case. * @param position - (Optional) The position at which to insert the new test case. * @returns The newly created TestcaseDefinitionDecision instance. */ addNewTestcase(name: string, position?: number): TestcaseDefinitionDecision; /** * Adds a new FieldSection to the table. * Instantiates a new FieldSectionDefinition and adds it via the addNewSection helper. * @param name - The unique name for the new field section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created FieldSectionDefinition. */ addNewFieldSection(name: string, position?: number): FieldSectionDefinition; /** * Adds a new MultiRowSection to the table. * Instantiates a new MultiRowSectionDefinition and adds it via the addNewSection helper. * @param name - The unique name for the new multi-row section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created MultiRowSectionDefinition. */ addNewMultiRowSection(name: string, position?: number): MultiRowSectionDefinition; /** * Adds a new TagSection to the table. * Instantiates a new TagSectionDefinition and adds it via the addNewSection helper. * @param name - The unique name for the new tag section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created TagSectionDefinition. */ addNewTagSection(name: string, position?: number): TagSectionDefinition; /** * Adds a new FilterSection to the table. * Instantiates a new FilterSectionDefinition and adds it via the addNewSection helper. * @param name - The unique name for the new filter section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created FilterSectionDefinition. */ addNewFilterSection(name: string, position?: number): FilterSectionDefinition; /** * Adds a new GeneratorSwitchSection to the table. * Instantiates a new GeneratorSwitchSectionDefinition and adds it via the addNewSection helper. * @param name - The unique name for the new generator switch section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created GeneratorSwitchSectionDefinition. */ addNewGeneratorSwitchSection(name: string, position?: number): GeneratorSwitchSectionDefinition; /** * Adds a new SummarySection to the table. * Instantiates a new SummarySectionDefinition and adds it via the addNewSection helper. * Note: Test cases are not updated when adding a summary section. * @param name - The unique name for the new summary section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created SummarySectionDefinition. */ addNewSummarySection(name: string, position?: number): SummarySectionDefinition; /** * Adds a new ExecuteSection to the table. * Instantiates a new ExecuteSectionDefinition and adds it via the addNewSection helper. * Note: Test cases are not updated when adding an execute section. * @param name - The unique name for the new execute section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created ExecuteSectionDefinition. */ addNewExecuteSection(name: string, position?: number): ExecuteSectionDefinition; /** * Adds a new NeverExecuteSection to the table. * Instantiates a new NeverExecuteSectionDefinition and adds it via the addNewSection helper. * Note: Test cases are not updated when adding a never-execute section. * @param name - The unique name for the new never-execute section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created NeverExecuteSectionDefinition. */ addNewNeverExecuteSection(name: string, position?: number): NeverExecuteSectionDefinition; /** * Adds a new MultiplicitySection to the table. * Instantiates a new MultiplicitySectionDefinition and adds it via the addNewSection helper. * Note: Test cases are not updated when adding a multiplicity section. * @param name - The unique name for the new multiplicity section. * @param position - (Optional) The position at which to insert the new section. * @returns The newly created MultiplicitySectionDefinition. */ addNewMultiplicitySection(name: string, position?: number): MultiplicitySectionDefinition; /** * Validates the position parameter for adding a new section. * Throws an error if the position is defined and is less than 0. * @param position - (Optional) The position at which the section is to be added. */ private checkParameterAddSection; } //# sourceMappingURL=TableDecision.d.ts.map