Skip to content

Conversation

@kail-is
Copy link
Contributor

@kail-is kail-is commented Sep 7, 2025

Summary

Add ShortCombinableArbitrary for customizable Short value generation following existing CombinableArbitrary pattern with Short-specific enhancements including domain-specific constraints.

Description

Implemented ShortCombinableArbitrary to provide easy customization of Short value generation, addressing the lack of short-specific constraints in current API with enhanced domain-specific methods.

Added components:

  • ShortCombinableArbitrary interface with standard constraint methods and domain-specific extensions
  • ShortCombinableArbitraryDelegator for filter/null injection operations
  • JqwikShortCombinableArbitrary implementation
  • Factory method CombinableArbitrary.shorts()

Key features:

  • Standard numeric constraints: .positive(), .negative(), .even(), .odd(), .withRange(short, short)
  • Short-specific .nonZero() method for avoiding division by zero errors
  • Short-specific .multipleOf(short) method for generating multiples of specific values
  • Domain-specific methods:
    • .percentage() - generates values 0-100 for percentage representation
    • .score() - generates values 0-100 for scoring systems
    • .year() - generates values 1900-2100 for year representation
    • .month() - generates values 1-12 for month representation
    • .day() - generates values 1-31 for day representation
    • .hour() - generates values 0-23 for hour representation
    • .minute() - generates values 0-59 for minute representation
  • Last-method-wins behavior for constraint precedence (domain-specific methods override previous constraints)
  • Full integration with existing filter/map/unique operations

Usage example:

Short nonZeroShort = CombinableArbitrary.shorts().nonZero().combined();
Short multipleOfFive = CombinableArbitrary.shorts().multipleOf((short) 5).combined();
Short positiveShort = CombinableArbitrary.shorts().withRange((short) 1, (short) 1000).positive().combined();
Short yearValue = CombinableArbitrary.shorts().year().combined();
Short monthValue = CombinableArbitrary.shorts().month().combined();
Short percentageValue = CombinableArbitrary.shorts().percentage().combined();

How Has This Been Tested?

Added comprehensive test suite in ShortCombinableArbitraryTest:

  • Basic constraint validation (positive, negative, even, odd, nonZero, multipleOf)
  • Range constraint testing with various boundaries
  • Domain-specific constraint testing (percentage, score, year, month, day, hour, minute)
  • Method chaining and last-method-wins precedence verification
  • Integration with filter, map, injectNull, unique operations
  • Complex constraint combinations and mathematical operation safety
  • Domain boundary validation (ensuring month values are 1-12, hour values are 0-23, etc.)

Is the Document updated?

Documentation will be updated to include ShortCombinableArbitrary usage examples alongside existing numeric arbitrary types, with special emphasis on domain-specific constraint methods for common Short use cases in business applications.

Comment on lines 417 to 422
boolean allMultiplesOfThree = IntStream.range(0, 100)
.mapToObj(i -> CombinableArbitrary.shorts().even().multipleOf((short)3).combined())
.allMatch(s -> s % 3 == 0);

// then
then(allMultiplesOfThree).isTrue();
Copy link
Contributor

@seongahjo seongahjo Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kail-is

For the clarity, it is better to use the report of assertj.

Instead of use boolean value in then, it is better to use the actual value Rather than using a Boolean value in the 'then' clause, it is better to use the actual value CombinableArbitrary.shorts().even().multipleOf((short)3).combined().

It works same for other tests

Copy link
Contributor Author

@kail-is kail-is Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seongahjo

Done!
I've refactored all the tests to use direct assertions as suggested.
Also completed similar refactoring for other types for your reference.

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2025

CLA assistant check
All committers have signed the CLA.

@kail-is kail-is force-pushed the combinable-arbitrary-short branch from dabbfca to ad47036 Compare November 22, 2025 15:01
- nonZero() / multipleOf(short)
- percentage()
- score()
- year() / month() / day()
- hour() / minute()
- Use Kotlin Int instead of Java Integer in SimpleValueJqwikPluginTest
- Fix nonZeroWithMultipleOf test to follow Last Win strategy
- SimpleValueJqwikPluginTest
- KotestByteCombinableArbitrary
@kail-is kail-is force-pushed the combinable-arbitrary-short branch from 8a5c092 to a181516 Compare November 22, 2025 15:36
Copy link
Contributor

@seongahjo seongahjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@seongahjo seongahjo merged commit e70b0c0 into naver:main Dec 19, 2025
10 checks passed
@kail-is kail-is deleted the combinable-arbitrary-short branch December 20, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants