Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "11.0.3"
}
8 changes: 4 additions & 4 deletions docs/extensions/autoparams-kotlin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 4
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock } from '@site/src/components/Custom';

# `autoparams-kotlin`

Expand All @@ -18,7 +18,7 @@ For Maven, you can add the following dependency to your `pom.xml`:
<dependency>
<groupId>io.github.autoparams</groupId>
<artifactId>autoparams-kotlin</artifactId>
<version>11.0.1</version>
<version>11.0.3</version>
</dependency>
```

Expand All @@ -27,15 +27,15 @@ For Maven, you can add the following dependency to your `pom.xml`:
For Gradle Groovy DSL, use:

```gradle
testImplementation 'io.github.autoparams:autoparams-kotlin:11.0.1'
testImplementation 'io.github.autoparams:autoparams-kotlin:11.0.3'
```

### Gradle (Kotlin)

For Gradle Kotlin DSL, use:

```gradle
testImplementation("io.github.autoparams:autoparams-kotlin:11.0.1")
testImplementation("io.github.autoparams:autoparams-kotlin:11.0.3")
```

## `@AutoKotlinParams` Annotation
Expand Down
8 changes: 4 additions & 4 deletions docs/extensions/autoparams-lombok.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 3
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock } from '@site/src/components/Custom';

# `autoparams-lombok`

Expand All @@ -18,7 +18,7 @@ For Maven, you can add the following dependency to your `pom.xml`:
<dependency>
<groupId>io.github.autoparams</groupId>
<artifactId>autoparams-lombok</artifactId>
<version>11.0.1</version>
<version>11.0.3</version>
</dependency>
```

Expand All @@ -27,15 +27,15 @@ For Maven, you can add the following dependency to your `pom.xml`:
For Gradle Groovy DSL, use:

```gradle
testImplementation 'io.github.autoparams:autoparams-lombok:11.0.1'
testImplementation 'io.github.autoparams:autoparams-lombok:11.0.3'
```

### Gradle (Kotlin)

For Gradle Kotlin DSL, use:

```gradle
testImplementation("io.github.autoparams:autoparams-lombok:11.0.1")
testImplementation("io.github.autoparams:autoparams-lombok:11.0.3")
```

## `BuilderCustomizer` Class
Expand Down
8 changes: 4 additions & 4 deletions docs/extensions/autoparams-mockito.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 2
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock } from '@site/src/components/Custom';

# `autoparams-mockito`

Expand All @@ -18,7 +18,7 @@ For Maven, you can add the following dependency to your `pom.xml`:
<dependency>
<groupId>io.github.autoparams</groupId>
<artifactId>autoparams-mockito</artifactId>
<version>11.0.1</version>
<version>11.0.3</version>
</dependency>
```

Expand All @@ -27,15 +27,15 @@ For Maven, you can add the following dependency to your `pom.xml`:
For Gradle Groovy DSL, use:

```gradle
testImplementation 'io.github.autoparams:autoparams-mockito:11.0.1'
testImplementation 'io.github.autoparams:autoparams-mockito:11.0.3'
```

### Gradle (Kotlin)

For Gradle Kotlin DSL, use:

```gradle
testImplementation("io.github.autoparams:autoparams-mockito:11.0.1")
testImplementation("io.github.autoparams:autoparams-mockito:11.0.3")
```

## Generating Test Doubles with Mockito
Expand Down
11 changes: 6 additions & 5 deletions docs/extensions/autoparams-spring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ sidebar_position: 1
sidebar_label: autoparams-spring
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock, JavadocLink } from '@site/src/components/Custom';
import { version } from '../data.json';

# `autoparams-spring`

Expand All @@ -26,7 +27,7 @@ For Maven, you can add the following dependency to your pom.xml:
<dependency>
<groupId>io.github.autoparams</groupId>
<artifactId>autoparams-spring</artifactId>
<version>11.0.1</version>
<version>11.0.3</version>
</dependency>
```

Expand All @@ -35,15 +36,15 @@ For Maven, you can add the following dependency to your pom.xml:
For Gradle Groovy, use:

```gradle
testImplementation 'io.github.autoparams:autoparams-spring:11.0.1'
testImplementation 'io.github.autoparams:autoparams-spring:11.0.3'
```

### Gradle (Kotlin)

For Gradle Kotlin, use:

```gradle
testImplementation("io.github.autoparams:autoparams-spring:11.0.1")
testImplementation("io.github.autoparams:autoparams-spring:11.0.3")
```

## `@UseBeans` Annotation
Expand Down Expand Up @@ -89,7 +90,7 @@ class HelloSupplier : MessageSupplier {
```
</JavaKotlinCodeBlock>

If you want to test how your `MessageSupplier` bean behaves, you can use the [`@UseBeans`](https://www.javadoc.io/static/io.github.autoparams/autoparams-spring/11.0.1/autoparams/spring/UseBeans.html) annotation like this:
If you want to test how your `MessageSupplier` bean behaves, you can use the <JavadocLink version={version} path="autoparams/spring/UseBeans.html">`@UseBeans`</JavadocLink> annotation like this:

<JavaKotlinCodeBlock>
```java
Expand Down
2 changes: 1 addition & 1 deletion docs/features/collections-and-arrays.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 4.5
sidebar_label: Collections and Arrays
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock } from '@site/src/components/Custom';

# Collections and Arrays

Expand Down
2 changes: 1 addition & 1 deletion docs/features/constructor-selection-policy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 7
sidebar_label: Constructor Selection Policy
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock } from '@site/src/components/Custom';

# Constructor Selection Policy

Expand Down
17 changes: 9 additions & 8 deletions docs/features/customization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ sidebar_position: 5
sidebar_label: Customization
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock, JavadocLink } from '@site/src/components/Custom';
import { version } from '../data.json';

# Customization

Expand All @@ -14,7 +15,7 @@ For example, suppose the `Product` entity must follow these business rules:
- `priceAmount` must be greater than or equal to `10`
- `priceAmount` must be less than or equal to `10000`

You can implement these rules using a custom generator by extending [`ObjectGeneratorBase<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/ObjectGeneratorBase.html):
You can implement these rules using a custom generator by extending <JavadocLink version={version} path="autoparams/generator/ObjectGeneratorBase.html">`ObjectGeneratorBase<T>`</JavadocLink>:

<JavaKotlinCodeBlock>
```java
Expand Down Expand Up @@ -49,9 +50,9 @@ class ProductGenerator : ObjectGeneratorBase<Product>() {
```
</JavaKotlinCodeBlock>

This custom generator creates a `Product` instance that adheres to the business constraints. It uses [`ResolutionContext`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/ResolutionContext.html) to generate supporting values like `id` and `name`, and applies explicit logic to generate a valid `priceAmount`.
This custom generator creates a `Product` instance that adheres to the business constraints. It uses <JavadocLink version={version} path="autoparams/ResolutionContext.html">`ResolutionContext`</JavadocLink> to generate supporting values like `id` and `name`, and applies explicit logic to generate a valid `priceAmount`.

You can apply this custom generator using the [`@Customization`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/Customization.html) annotation:
You can apply this custom generator using the <JavadocLink version={version} path="autoparams/customization/Customization.html">`@Customization`</JavadocLink> annotation:

<JavaKotlinCodeBlock>
```java
Expand Down Expand Up @@ -142,7 +143,7 @@ fun testMethod(product: Product, review: Review) {
```
</JavaKotlinCodeBlock>

Alternatively, if you prefer to encapsulate multiple generators into a single reusable configuration, you can extend [`CompositeCustomizer`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/CompositeCustomizer.html):
Alternatively, if you prefer to encapsulate multiple generators into a single reusable configuration, you can extend <JavadocLink version={version} path="autoparams/customization/CompositeCustomizer.html">`CompositeCustomizer`</JavadocLink>:

<JavaKotlinCodeBlock>
```java
Expand Down Expand Up @@ -312,7 +313,7 @@ class TestClass {
```
</JavaKotlinCodeBlock>

In this example, we use the [`set`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/dsl/ArgumentCustomizationDsl.html#set(autoparams.customization.dsl.FunctionDelegate)) static method from the [`ArgumentCustomizationDsl`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/dsl/ArgumentCustomizationDsl.html) class to customize the behavior of the `ResolutionContext`. Specifically:
In this example, we use the <JavadocLink version={version} path="autoparams/customization/dsl/ArgumentCustomizationDsl.html#set(autoparams.customization.dsl.FunctionDelegate)">`set`</JavadocLink> static method from the <JavadocLink version={version} path="autoparams/customization/dsl/ArgumentCustomizationDsl.html">`ArgumentCustomizationDsl`</JavadocLink> class to customize the behavior of the `ResolutionContext`. Specifically:

- The `product` property in any `Review` instance created by the context will be set to the `product` parameter of the test.
- Likewise, the `rating` property will be set to the `rating` parameter.
Expand Down Expand Up @@ -359,7 +360,7 @@ class TestClass {
```
</JavaKotlinCodeBlock>

The [`Factory<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html) class provides a convenient way to create customized objects when working with a single type. It avoids managing an explicit resolution context and keeps the test focused on the instances under test.
The <JavadocLink version={version} path="autoparams/generator/Factory.html">`Factory<T>`</JavadocLink> class provides a convenient way to create customized objects when working with a single type. It avoids managing an explicit resolution context and keeps the test focused on the instances under test.

:::note

Expand All @@ -376,7 +377,7 @@ The `set` method relies on the availability of parameter names at runtime. Howev

## Settable Properties

If a class follows the JavaBeans convention—meaning it has a no-arguments constructor and public setter methods—AutoParams can automatically populate its properties using the [`InstancePropertyWriter`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/processor/InstancePropertyWriter.html) customizer.
If a class follows the JavaBeans convention—meaning it has a no-arguments constructor and public setter methods—AutoParams can automatically populate its properties using the <JavadocLink version={version} path="autoparams/processor/InstancePropertyWriter.html">`InstancePropertyWriter`</JavadocLink> customizer.

Here's a simple example:

Expand Down
7 changes: 4 additions & 3 deletions docs/features/factory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ sidebar_position: 4
sidebar_label: Factory<T> class
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock, JavadocLink } from '@site/src/components/Custom';
import { version } from '../data.json';

# `Factory<T>` class

The [`Factory<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html) class is useful when you need to generate multiple instances of the same type. It allows you to create single instances or collections of generated objects on demand.
The <JavadocLink version={version} path="autoparams/generator/Factory.html">`Factory<T>`</JavadocLink> class is useful when you need to generate multiple instances of the same type. It allows you to create single instances or collections of generated objects on demand.

Here's an example:

Expand All @@ -31,4 +32,4 @@ fun testMethod() {
```
</JavaKotlinCodeBlock>

In this example, a `Factory<Product>` is created to produce `Product` instances. The [`get()`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html#get()) method creates a single instance, while [`getRange(n)`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html#getRange(int,autoparams.customization.Customizer...)) returns a list of `n` instances. This approach is particularly helpful when you need bulk data generation in your tests.
In this example, a `Factory<Product>` is created to produce `Product` instances. The <JavadocLink version={version} path="autoparams/generator/Factory.html#get()">`get()`</JavadocLink> method creates a single instance, while <JavadocLink version={version} path="autoparams/generator/Factory.html#getRange(int,autoparams.customization.Customizer...)">`getRange(n)`</JavadocLink> returns a list of `n` instances. This approach is particularly helpful when you need bulk data generation in your tests.
13 changes: 7 additions & 6 deletions docs/features/freeze-by.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ sidebar_position: 1
sidebar_label: '@FreezeBy Annotation'
---

import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
import { JavaKotlinCodeBlock, JavadocLink } from '@site/src/components/Custom';
import { version } from '../data.json';

# `@FreezeBy` Annotation

The [`@FreezeBy`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/FreezeBy.html) annotation enables fine-grained control over value freezing in tests. It allows you to freeze a single value and reuse it across multiple generation targets that match specific conditions, such as type or name. This helps improve test readability and ensures consistency among generated values.
The <JavadocLink version={version} path="autoparams/customization/FreezeBy.html">`@FreezeBy`</JavadocLink> annotation enables fine-grained control over value freezing in tests. It allows you to freeze a single value and reuse it across multiple generation targets that match specific conditions, such as type or name. This helps improve test readability and ensures consistency among generated values.

## Matching Strategies

AutoParams provides several matching strategies that determine which targets should receive the frozen value during object generation. The following examples illustrate some strategies:

- [`EXACT_TYPE`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/Matching.html#EXACT_TYPE)
- <JavadocLink version={version} path="autoparams/customization/Matching.html#EXACT_TYPE">`EXACT_TYPE`</JavadocLink>

Reuses the frozen value for all targets with the exact same type.

Expand Down Expand Up @@ -72,7 +73,7 @@ AutoParams provides several matching strategies that determine which targets sho

In this example, all `String` targets—including the `String` field inside `StringContainer`—are generated with the same frozen value.

- [`IMPLEMENTED_INTERFACES`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/Matching.html#IMPLEMENTED_INTERFACES)
- <JavadocLink version={version} path="autoparams/customization/Matching.html#IMPLEMENTED_INTERFACES">`IMPLEMENTED_INTERFACES`</JavadocLink>

Reuses the frozen value for targets whose types are interfaces that the frozen value's type implements.

Expand Down Expand Up @@ -116,7 +117,7 @@ AutoParams provides several matching strategies that determine which targets sho

In this example, `String` implements `CharSequence`, so the same value is reused for both `s1` and `chars`. `StringContainer` is not affected because its type is not an interface.

- [`PARAMETER_NAME`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/Matching.html#PARAMETER_NAME)
- <JavadocLink version={version} path="autoparams/customization/Matching.html#PARAMETER_NAME">`PARAMETER_NAME`</JavadocLink>

Reuses the frozen value for other targets with matching names.

Expand Down Expand Up @@ -210,7 +211,7 @@ In this example, the frozen value `s1` is reused for both `s2` (same type) and `

## Shorthand for `EXACT_TYPE`

Using [`@Freeze`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/Freeze.html) is equivalent to `@FreezeBy(EXACT_TYPE)`. It's a convenient shorthand for the most common matching strategy.
Using <JavadocLink version={version} path="autoparams/customization/Freeze.html">`@Freeze`</JavadocLink> is equivalent to `@FreezeBy(EXACT_TYPE)`. It's a convenient shorthand for the most common matching strategy.

<JavaKotlinCodeBlock>
```java
Expand Down
Loading