Description

The DateFilterGen Generator can be used to filter out generated dates based on the configured exclude conditions. Two exclude options are provided for filtering dates (Filter by Dates or Filter by Days). At least one must be configured.

In This Article


Generator Parameters

The following parameters may be configured for the DateFilterGen Generator. Items with an asterisk* are required.

  • referenceDate* - Reference a date to be checked for exclusion during test data generation (based on configured exclude options).
     
  • referenceFormat*- Must be the same as the referenced date. Examples
    • yyyy-MM-dd
    • MM-dd-yyyy
    • MM/dd/yyyy
    • MM/dd
    • MM/yyyy

  • outputFormat- Defines how the generated date after exclusion will be formatted. Examples below:  
    • MM/dd/yyyy - The output date would look like 08/01/1990.
    • yyyy-MM-dd - The output date would look like 1990-08-01.

  • resourcePath - Defines the path of the text file containing a list of dates to be excluded.
  • subDir - Defines an optional subdirectory under the resourcePath where the file exists. 
  • fileName - Defines the name of the text file containing a list of the dates to be excluded from the output (e.g., holidays).
  • excludeDateFormat - Defines exclude date format loaded from the file. 
  • excludeDays - Defines a list of the days to be excluded from the output. A maximum of six days can be specified. The format of the day must be: MON, TUE, WED, THU, FRI, SAT, and SUN.


Exclude Options

At least one exclude option must be configured. Both may be used together as well. 

  • Filter by Dates- Filter by a list of dates mentioned within a file. The resourcePath and Filename parameters are required when using this option. (Examples: Holidays, Festival dates, etc.)



  • Filter by Days- Filter by day names specified in the excludeDays parameter. (Examples: SAT, SUN, etc.)



Use Case 1 - Filter US Holidays from Generated Dates

A tester would like to generate dates within a specified date range and exclude US Holidays within that date range. For this example, dates will be generated between 11-01-2022 and 12-31-2022. In this case, the generated output should not include Thanksgiving and Christmas. 


A Date Domain will be used for this example, and the loopCount has been set to '100'.


FlexibleDateRangeGen

The FlexibleDateRangeGen generates the reference date to which the exclusion condition(s) will be applied. For this example, the date range will start on November 1, 2022, increase by '1' day for 61 days, and end on December 31, 2022. The sequence will repeat unit the Domain loopCount is met.

The following Generator parameter values have been changed: 

  • startDate = 2022-11-01
  • startRange = 0
  • endRange = 61
  • nextBy = Day
  • randomize = false


DateFilterGen

The DateFilterGen will reference the FlexibleDateRangeGen and exclude the dates specified within the file. 



Parameter changes for the DateFilterGen:

  • referenceDate = references 'gen1' in Attribute
  • resourcePath = resource.output.directory
  • fileName = excludeDates.txt
  • exlcudeDateFormat = MM-dd-yyyy (This is how the dates are formatted in the file.)


Text File

The following text file contains the dates that should be excluded from the generated dates:

 

Sample Output

For this example, dates have been generated for November and December 2022.



Use Case 2 - Filter Saturdays and Sundays from Generated Dates

A tester wants to generate dates while excluding Saturdays and Sundays from the generated output. They would also like to generate sequential dates for January 2023. 



FlexibleDateRangeGen

The FlexibleDateRangeGen generates the reference date to which the exclusion condition(s) will be applied. For this example, the date range will start on January 1, 2023, increase by '1' day for 31 days, and end on January 31, 2022. The sequence will repeat unit the Domain loopCount is met.

The following Generator parameter values have been changed: 

  • startDate = 2023-01-01
  • endRange = 31
  • nextBy = Day
  • randomize = false


DateFilterGen

The DateFilterGen will reference the FlexibleDateRangeGen and exclude all Saturdays and Sundays from the generated output. 



Parameter changes for DateFilterGen:

  • referenceDate = references gen1 in Attribute
  • excludeDays = SAT, SUN


Sample Output

The following dates are not part of the generated output because they are Saturdays and Sundays in January.

  • 2023-01-01
  • 2023-01-07
  • 2023-01-08
  • 2023-01-14
  • 2023-01-15
  • 2023-01-21
  • 2023-01-22
  • 2023-01-28
  • 2023-01-29