Comments (8)
@phuc16102001
In this case you could setup just as below.
private final FixtureMonkey fixtureMonkey = FixtureMonkey.builder()
.objectIntrospector(BuilderArbitraryIntrospector.INSTANCE)
.pushExactTypeArbitraryIntrospector(B.class, (ctx) -> new ArbitraryIntrospectorResult(Arbitraries.just(null)))
.defaultNotNull(true)
.build();
@Test
void testCode() {
B fieldB = new B("123");
A createdObject = fixtureMonkey.giveMeBuilder(A.class)
.set("fieldB", Values.just(fieldB)).sample();
Assertions.assertNotNull(createdObject.getFieldB());
}
from fixture-monkey.
Oh thank you, it works now. π
Ah also where I can find the latest document for the Fixture Monkey? Currently, it the 0.5.6 version has already available right? But the document still 0.5.0 which has some deprecated methods.
from fixture-monkey.
the 0.5.6 version has already available right?
Yes, 0.5.7 is the latest version.
where I can find the latest document for the Fixture Monkey
You'd better to check release
Document is now out-of-date since updating documentation has a lower priority.
I'll update the document as soon as possible.
from fixture-monkey.
Ok thank you very much.
I will close the issue then.
Once again, thank you! π
from fixture-monkey.
@phuc16102001
Hello, removeArbitray
is not recommended in this situation.
removeArbitrary
means remove the property fieldB
, so set
does not work as well.
In this situation, you'd better use pushExactTypeArbitraryIntrospector
.
You have to find out which introspector would generate B
.
B has @AllArgsConstructor
, so ConstructorPropertiesArbitraryIntrospector
would work if you have lombok.anyConstructor.addConstructorProperties=true
in your lombok.config
private final FixtureMonkey fixtureMonkey = FixtureMonkey.builder()
.objectIntrospector(BuilderArbitraryIntrospector.INSTANCE)
.pushExactTypeArbitraryIntrospector(B.class, ConstructorPropertiesArbitraryIntrospector.INSTANCE)
.defaultNotNull(true)
.build();
If not work, please let me know.
Thank you
from fixture-monkey.
But what if the B class does not have the @AllArgsConstructor
too? Particularly, it is the GeoBoundingBox in Elastic Search. I have tried the ConstructorPropertiesArbitraryIntrospector
but it throw this:
Primary Constructor does not exist. type GeoBoundingBox
java.lang.IllegalArgumentException: Primary Constructor does not exist. type GeoBoundingBox
Here is the constructor of the class:
public class GeoBoundingBox implements ToXContentObject, Writeable {
private final GeoPoint topLeft;
private final GeoPoint bottomRight;
public GeoBoundingBox(GeoPoint topLeft, GeoPoint bottomRight) {
this.topLeft = topLeft;
this.bottomRight = bottomRight;
}
public GeoBoundingBox(StreamInput input) throws IOException {
this.topLeft = input.readGeoPoint();
this.bottomRight = input.readGeoPoint();
}
}
from fixture-monkey.
Which version of Fixture Monkey are you using? Because I cannot find the setJust
method.
from fixture-monkey.
@phuc16102001
Oh, sorry, you could use set
instead of setJust
from fixture-monkey.
Related Issues (20)
- μν μ°Έμ‘°κ° μλ νμ μ νλμ 컬λ μ νμ νλκ° ν¨κ» μμ λ κ°νμ μΌλ‘ fixture μμ±μ μ€ν¨ν¨ HOT 4
- Interface subtypes HOT 3
- [Kotlin] Primary Constructorμ ν¬ν¨λμ§ μλ νλ‘νΌν° μ΄κΈ°ν νλ λ°©λ² HOT 1
- Is there a way to set only positive numbers in a numeric field? HOT 2
- Issue Excluding classes from generation HOT 1
- μμνκΈ° - "Bean μ ν¨μ± κ²μ¬ μΆκ°νκΈ°" λμ μ§λ¬Έ HOT 3
- JakartaValidationPluginμ μ¬μ©νλ κ²½μ°μ, μ ν¨νμ§ μμ κ°μΌλ‘ 컀μ€ν°λ§μ΄μ§ ν μ μλμ? HOT 2
- 무쑰건 getX, setXλ‘ μ¬μ©ν΄μΌνλμ? HOT 1
- Call for first Fixture Monkey Meetup participants
- Implement InnerSpec Kotlin DSL HOT 6
- Jpa μ°κ΄κ΄κ³κ° μλ μν°ν°λ₯Ό μμ±νλ €λ©΄ μ΄λ»κ² νλ©΄λ κΉμ? (ν΄κ²°νμ΅λλ€.)
- Version 1.017 is not available on maven central HOT 1
- νκ΅μ΄ λ¬Έμμ μλͺ»λ λ§ν¬κ° μλ κ² κ°μ΅λλ€. HOT 1
- 1.0.17 λ²μ μμ SimpleValueJqwikPlugin μ¬μ©μ Set<Integer> μ μμκ°μ΄ μμ±λμ§ μμ΅λλ€. HOT 1
- setPostCondition stuck in infinite loop HOT 2
- Print seed if test fails in JUnit HOT 5
- μ€λ³΅λ κ°μ΄ νμ©νμ§ μλ νλμ κ³ μ ν κ°μ λ£λ λ°©λ²μ΄ μλμ§ κΆκΈν©λλ€. HOT 4
- kotlin Lambda ν¨μ μ¬μ©ν μ μλλ² HOT 3
- How can I set a 'yyyyMMdd' date value in a String field? HOT 3
- Optional κ°μ set ν λ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fixture-monkey.