Releases: instancio/instancio
4.5.1
What's Changed
- Bump nl.jqno.equalsverifier:equalsverifier-nodep from 3.15.8 to 3.16 by @dependabot in #978
- Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.1 to 3.2.2 by @dependabot in #979
- Bump org.ow2.asm:asm from 9.6 to 9.7 by @dependabot in #977
- Bump com.puppycrawl.tools:checkstyle from 10.14.2 to 10.15.0 by @dependabot in #981
- Bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.12 by @dependabot in #982
- Bump nl.jqno.equalsverifier:equalsverifier-nodep from 3.16 to 3.16.1 by @dependabot in #983
- Bump version.jooq from 3.19.6 to 3.19.7 by @dependabot in #985
- Bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.3.1 by @dependabot in #984
- Bump com.github.spotbugs:spotbugs-maven-plugin from 4.8.3.1 to 4.8.4.0 by @dependabot in #986
- Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.2 to 3.2.3 by @dependabot in #988
- Bump com.tngtech.archunit:archunit from 1.2.1 to 1.3.0 by @dependabot in #987
- Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 by @dependabot in #990
- Bump org.apache.maven.plugins:maven-jar-plugin from 3.3.0 to 3.4.0 by @dependabot in #989
- Add
InstancioExtension
to feature tests where missing by @armandino in #991 - Bugfix: generating empty
javax.xml.namespace.QName
objects leads to NPE by @armandino in #993 - Fix generator caching by @armandino in #994
Full Changelog: instancio-parent-4.5.0...instancio-parent-4.5.1
4.5.0
What's Changed
New Features
- New SPI for processing custom annotations (#975)
Improvements
- misc performance improvements
- Bump version.jooq from 3.19.5 to 3.19.6 by @dependabot in #955
- Bump com.puppycrawl.tools:checkstyle from 10.14.0 to 10.14.1 by @dependabot in #956
- Refactored model context / selector maps by @armandino in #960
- Bump org.apache.maven.plugins:maven-gpg-plugin from 3.1.0 to 3.2.0 by @dependabot in #957
- Fix typo in user-guide.md by @nok3zy in #961
- Use sonar-fork-analysis action by @EvaristeGalois11 in #962
- Refactored internal classes related to generation by @armandino in #965
- Bump org.sonarsource.scanner.maven:sonar-maven-plugin from 3.10.0.2594 to 3.11.0.3922 by @dependabot in #958
- Perf: reuse
DatatypeFactory
when creatingXMLGregorianCalendar
by @armandino in #967 - Perf: cache generators by @armandino in #968
- Bump com.puppycrawl.tools:checkstyle from 10.14.1 to 10.14.2 by @dependabot in #966
- Perf: use no-op classes to avoid unnecessary work by @armandino in #971
- Bump com.google.guava:guava from 33.0.0-jre to 33.1.0-jre by @dependabot in #959
- Bump org.apache.maven.plugins:maven-compiler-plugin from 3.11.0 to 3.13.0 by @dependabot in #970
- Rerfactor/cleanup selector classes by @armandino in #973
- Bump org.projectlombok:lombok from 1.18.30 to 1.18.32 by @dependabot in #972
- SPI for processing custom annotations by @armandino in #975
- Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.0 to 3.2.1 by @dependabot in #969
New Contributors
Full Changelog: instancio-parent-4.4.0...instancio-parent-4.5.0
4.4.0
What's Changed
Potentially breaking change
Allow selectors to overwrite initialised values even if Keys.OVERWRITE_EXISTING_VALUES
is set to false
Previously, selectors could not overwrite initialised values if OVERWRITE_EXISTING_VALUES
was set to false
. This behaviour made the setting too restrictive. Starting from this release, selectors can overwrite initialised values.
For details, see: https://www.instancio.org/user-guide/#initialised-fields
New Features
New top-level API: setModel(TargetSelector, Model)
The new API promotes reuse of models. It allows applying a model instance to specific targets via a selector.
Example:
record Foo(String value) {}
record Container(Foo fooA, Foo fooB) {}
Model<Foo> fooModel = Instancio.of(Foo.class)
.set(field(Foo::value), "foo")
.toModel();
The model can be applied to a specific Foo
field declared by the Container
:
Container container = Instancio.of(Container.class)
.setModel(field(Container::fooA), fooModel)
.create();
// Sample output:
// Container[fooA=Foo[value="foo"], fooB=Foo[value="ANBQNR"]]
Coordinate generator for latitude and longitude
Location location = Instancio.of(Location.class)
.generate(field(Location::lat), gen -> gen.spatial().coordinate().lat())
.generate(field(Location::lon), gen -> gen.spatial().coordinate().lon())
.create();
// Sample output: Location[lat=-77.80297026108207, lon=-122.08201176512672]
Thanks to @StevenPG for the contribution!
Support for marking an individual selector as lenient()
Example example = Instancio.of(Example.class)
.set(fields().named("fieldThatMayNotExist").lenient(), "foo") // will not result in unused selector error
.create();
Other Improvements
- better seed reporting by
instancio-junit
- improved
verbose()
output
- Support for marking an individual selector as
lenient()
by @armandino in #932 - Selectors to have higher precedence than
Keys.OVERWRITE_EXISTING_VALUES
by @armandino in #909 - Bump nl.jqno.equalsverifier:equalsverifier-nodep from 3.15.6 to 3.15.7 by @dependabot in #934
- Add selector matches to
verbose()
output by @armandino in #936 - Tests for
java.util.concurrent.locks.*
by @armandino in #937 - Predicate selector builder minor refactoring by @armandino in #938
- Bump version.jooq from 3.19.4 to 3.19.5 by @dependabot in #939
- Additional seed tests + user guide update (#940) by @armandino in #942
- Bump com.puppycrawl.tools:checkstyle from 10.13.0 to 10.14.0 by @dependabot in #941
- Bump com.github.siom79.japicmp:japicmp-maven-plugin from 0.18.5 to 0.19.1 by @dependabot in #944
- Bump nl.jqno.equalsverifier:equalsverifier-nodep from 3.15.7 to 3.15.8 by @dependabot in #945
- Bug fix: assignment with predicate selector by @armandino in #946
- Seed reporting improvements (#940) by @armandino in #948
- Bump com.github.siom79.japicmp:japicmp-maven-plugin from 0.19.1 to 0.20.0 by @dependabot in #950
- Bump version.kotlin from 1.9.22 to 1.9.23 by @dependabot in #952
- Coordinate generator for latitude and longitude by @StevenPG in #953
- New top-level API:
setModel(TargetSelector, Model)
by @armandino in #943
New Contributors
Full Changelog: instancio-parent-4.3.2...instancio-parent-4.4.0
4.3.2
What's Changed
As of this release, internal classes will no longer be accessible on the module path. This will be a breaking change for client code that relies on org.instancio.internal.*
or @InternalApi
annotated classes.
Previous releases of Instancio supported Java moduies via Automatic-Module-Name
. This release adds module-info.java
files with exports
for public APIs only. Module names are unchanged.
Big thanks to @grubeninspekteur for this contribution!
- Refactor
Result
from class to interface by @armandino in #923 - Added JPMS module information by @grubeninspekteur in #921
- Javadoc: add custom stylesheet by @armandino in #928
- Bump com.github.siom79.japicmp:japicmp-maven-plugin from 0.18.4 to 0.18.5 by @dependabot in #922
- Convert
instancio-test-support
to a Java module by @armandino in #929 - Bump version.jooq from 3.19.3 to 3.19.4 by @dependabot in #927
- Bump org.apache.maven.plugins:maven-antrun-plugin from 3.0.0 to 3.1.0 by @dependabot in #926
- Move JPMS smoke tests from external repository to the main project (#925) by @armandino in #930
New Contributors
- @grubeninspekteur made their first contribution in #921
Full Changelog: instancio-parent-4.3.1...instancio-parent-4.3.2
4.3.1
What's Changed
- Add convenience method for overriding a setting key. by @armandino in #917
- Bug fix: setting 'max' size setting to zero results in negative 'min' value by @armandino in #918
- Bug fix: bean validation NPE when creating a collection by @armandino in #919
- Bump com.github.siom79.japicmp:japicmp-maven-plugin from 0.18.3 to 0.18.4 by @dependabot in #916
Full Changelog: instancio-parent-4.3.0...instancio-parent-4.3.1
4.3.0
What's Changed
New Features
Support for ElementType.TYPE_USE
bean validation annotations (#911)
class Pojo {
@Size(min = 3, max = 3)
private Map<@Email String, @Negative Integer> map;
// ...
}
Pojo pojo = Instancio.of(Pojo.class)
.withSettings(Settings.create().set(Keys.BEAN_VALIDATION_ENABLED, true))
.create();
// Sample output:
// Pojo(map={vo4ira@zv5.com=-5809899, arhis@ktt2ricfw.net=-74162228, dpy99t@hdezns.org=-186211504})
Limitation: nested annotations are not supported. In the following example, the @Negative
annotation will be ignored:
Map<@Email String, List<@Negative Integer>> map;
emit()
spec support for recycling items (#905)
class Outer {
List<Mid> midList;
}
class Mid {
String value;
List<Inner> innerList;
}
class Inner {
String value;
}
Outer outer = Instancio.of(Outer.class)
.generate(field(Outer::getMidList), gen -> gen.collection().size(2))
.generate(field(Mid::getValue), gen -> gen.emit().items("A", "B"))
.generate(field(Mid::getInnerList), gen -> gen.collection().size(3))
.generate(field(Inner::getValue), gen -> gen.emit().items("X", "Y", "Z").whenEmptyRecycle())
.create();
assertThat(outer.getMidList())
.hasSize(2)
.allSatisfy(r -> assertThat(r.getInnerList())
.hasSize(3)
.extracting(Inner::getValue)
.containsExactly("X", "Y", "Z"))
.extracting(Mid::getValue)
.containsExactly("A", "B");
emit()
support for recycling items (#905) by @armandino in #906- Removed usage of internal JUnit APIs from
instancio-quickcheck
(#908) by @armandino in #912 - Support for
ElementType.TYPE_USE
bean validation annotations (#911) by @armandino in #914
Full Changelog: instancio-parent-4.2.0...instancio-parent-4.3.0
4.2.0
What's Changed
New Features
Support for predicate scopes and predicate selector within(Scope...)
and toScope()
- creating a
Scope
from a predicate selector:Select.scope(PredicateSelector)
PredicateSelector.toScope()
- narrowing down predicate selectors using
within(Scope...)
Example:
record Foo(String value) {}
record Container(Foo one, Foo two, Foo three) {}
Scope scope = fields(f -> f.getType() == Foo.class && f.getName().startsWith("t")).toScope();
Container container = Instancio.of(Container.class)
.set(fields().ofType(String.class).within(scope), "hello!")
.create();
// Sample output:
// Container(one=Foo(value=PDILAMI), two=Foo(value=hello!), three=Foo(value=hello!))
Added support for truncatedTo()
to applicable java.time
specs
Instant
LocalTime
LocalDateTime
OffsetTime
OffsetDateTime
ZonedDateTime
Duration.truncatedTo()
requires Java 9 and is currently not supported.
Examples:
record Venue(LocalTime openingTime) {}
Venue venue = Instancio.of(Venue.class)
.generate(field(Venue::openingTime), gen -> gen.temporal().localTime().truncatedTo(ChronoUnit.HOURS))
.create();
// Sample output:
// Venue[openingTime=18:00]
Using Gen
:
List<Instant> list = Gen.temporal().instant()
.truncatedTo(ChronoUnit.HOURS)
.list(3);
// Sample output:
// 1990-06-10T16:00:00Z
// 2031-02-10T10:00:00Z
// 2037-12-12T06:00:00Z
- Add support for
truncatedTo()
to applicablejava.time
specs (#881) by @armandino in #894 - Bump org.assertj:assertj-bom from 3.25.2 to 3.25.3 by @dependabot in #898
- Bug fix: propagate Map/Collection generator errors conditionally (#900) by @armandino in #902
- Bump org.junit:junit-bom from 5.10.1 to 5.10.2 by @dependabot in #897
- Bump org.slf4j:slf4j-api from 2.0.11 to 2.0.12 by @dependabot in #901
- Support for predicate scopes and predicate selector
within(Scope...)
andtoScope()
by @armandino in #896
Full Changelog: instancio-parent-4.1.0...instancio-parent-4.2.0
4.1.0
What's Changed
New Features
Support predicate selector scopes
record Widget(String name, String type) {}
record WidgetHolder(Widget widgetA, Widget widgetB) {}
WidgetHolder person = Instancio.of(WidgetHolder.class)
.set(fields(f -> f.getType() == String.class).within(scope(WidgetHolder::widgetB)), "foo")
.create();
// Sample output:
// WidgetHolder[widgetA=Widget[name=DGGM, type=MVCNQICSHC], widgetB=Widget[name=foo, type=foo]]
Bug fixes
- Error returning array/collection specs from generator provider SPI (#882)
- Unconditional assignment with records (#892)
- Bump org.slf4j:slf4j-api from 2.0.10 to 2.0.11 by @dependabot in #876
- Bump nl.jqno.equalsverifier:equalsverifier-nodep from 3.15.5 to 3.15.6 by @dependabot in #878
- Bug fix: error returning array/collection specs from generator provider SPI by @armandino in #882
- Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.2.3 to 3.2.5 by @dependabot in #879
- Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.3 to 3.2.5 by @dependabot in #877
- Collection/map generator cleanup + tests by @armandino in #883
- Predicate selectors: support for
within(Scope)
by @armandino in #885 - Bump version.jooq from 3.19.1 to 3.19.2 by @dependabot in #884
- Bump actions/cache from 3 to 4 by @dependabot in #887
- Bump version.jooq from 3.19.2 to 3.19.3 by @dependabot in #888
- Bump org.assertj:assertj-bom from 3.25.1 to 3.25.2 by @dependabot in #889
- Bump com.puppycrawl.tools:checkstyle from 10.12.7 to 10.13.0 by @dependabot in #891
- Bug fix: unconditional assignment with records by @armandino in #892
Full Changelog: instancio-parent-4.0.0...instancio-parent-4.1.0
4.0.0
What's Changed
New Features
Method assignment improvements
Added a new setting Keys.ON_SET_METHOD_UNMATCHED
which allows populating an object via setters even if the setter does not have a corresponding field. This allows populating objects with dynamic attributes, such as jOOQ records (see #767 for details and Assignment Settings section of the User Guide).
Support for Java 21 sequenced collections
record Foo(SequencedCollection<String> values) {}
Foo foo = Instancio.create(Foo.class);
// Sample output:
// Foo[values=[BFMSUX, NGCNBXVI, CTXLC, QQTM]]
New API for generating the Cartesian product (experimental feature)
A selector and values can be specified using the with()
method and the results can be obtained by calling list()
:
Example:
record Widget(String type, int num) {}
List<Widget> results = Instancio.ofCartesianProduct(Widget.class)
.with(field(Widget::type), "FOO", "BAR", "BAZ")
.with(field(Widget::num), 1, 2, 3)
.list();
This will produce the following list of Widget
objects:
[Widget[type=FOO, num=1],
Widget[type=FOO, num=2],
Widget[type=FOO, num=3],
Widget[type=BAR, num=1],
Widget[type=BAR, num=2],
Widget[type=BAR, num=3],
Widget[type=BAZ, num=1],
Widget[type=BAZ, num=2],
Widget[type=BAZ, num=3]]
Breaking changes
Using stream()
with stateful generators such as emit()
and intSeq()
.
Since version 4.0.0
, all root objects created by stream()
are completely independent of each other, e.g.:
List<String> results = Instancio.of(String.class)
.generate(allStrings(), gen -> gen.emit().items("foo", "bar", "baz").ignoreUnused())
.stream()
.limit(3)
.toList();
// Before v4:
assertThat(results).containsExactly("foo", "bar", "baz");
// Since v4:
assertThat(results).containsExactly("foo", "foo", "foo");
- Bump actions/upload-artifact from 3 to 4 by @dependabot in #851
- Method assignment improvements by @armandino in #767
- Clean up tests by @armandino in #852
- Tests: renamed custom assert methods by @armandino in #853
- Support for Java 21 sequenced collections by @armandino in #854
- Bump version.jooq from 3.18.7 to 3.19.0 by @dependabot in #855
- Updated test dependencies by @armandino in #859
- Bump com.google.guava:guava from 32.1.3-jre to 33.0.0-jre by @dependabot in #857
- Bump version.jooq from 3.19.0 to 3.19.1 by @dependabot in #861
- Address remaining items from #739 by @armandino in #862
- Bump version.kotlin from 1.9.21 to 1.9.22 by @dependabot in #863
- Bump nl.jqno.equalsverifier:equalsverifier-nodep from 3.15.4 to 3.15.5 by @dependabot in #865
- New top-level API for generating the Cartesian product by @armandino in #864
- Simplified API contract tests and moved to
instancio-core-tests
by @armandino in #867 - Bump org.slf4j:slf4j-api from 2.0.9 to 2.0.10 by @dependabot in #868
- Breaking change:
stream()
semantics when used with stateful generators by @armandino in #869 - Upgrade AssertJ to
3.25.0
by @armandino in #872 - Updated license headers by @armandino in #873
- Bump com.puppycrawl.tools:checkstyle from 10.12.6 to 10.12.7 by @dependabot in #870
- Bump org.assertj:assertj-bom from 3.25.0 to 3.25.1 by @dependabot in #874
Full Changelog: instancio-parent-3.7.1...instancio-parent-4.0.0
3.7.1
What's Changed
- Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.2 to 3.2.3 by @dependabot in #847
- Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.2.2 to 3.2.3 by @dependabot in #848
- Downgrage JUnit Platform APIs usage to 1.9.x baseline for Instancio Quickcheck test engine by @reta in #850
Full Changelog: instancio-parent-3.7.0...instancio-parent-3.7.1