keepcosmos / beanmother Goto Github PK
View Code? Open in Web Editor NEWA library for setting up Java objects as test data.
Home Page: http://beanmother.io
License: Apache License 2.0
A library for setting up Java objects as test data.
Home Page: http://beanmother.io
License: Apache License 2.0
This is a how to query
. Apologies if this is not the right place to post queries:
book: &book
id: ${sequence.number}
title: ${faker.book.title}
publishedAt: &anchor_val2 ${faker.date.between('2000-01-01', '2010-01-01')}
author:
id: ${sequence.number}
policies:
id1:
id: ${sequence.number}
title: ${faker.book.title}
publishedAt: *anchor_val2
id2:
id: ${sequence.number}
title: ${faker.book.title}
publishedAt: ${current.date}
Using yaml anchors here, publishedAt: *anchor_val2
generates new ${faker.date.between('2000-01-01', '2010-01-01')}
Is there a way I can reference (reuse) the data generated in publishedAt: &anchor_val2 ${faker.date.between('2000-01-01', '2010-01-01')}
in the lombok builder pattern, how to build instance of a target class which reference another class instance?
class A {
private String fieldA;
}
@Data
@Builder
class B {
private String fieldB;
private A a;
}
`
appreciate for any help~~
I am trying to create an instance of a object that is annotated with @Builder
from lombok.Builder
It throws an java.lang.UnsupportedOperationException saying that the object has no default constructor.
Is it possible to add a new feature to create the object with All args constructor ?
Add a single and static html page for introduction in /docs
path.
The Introduction should be from README.md
for example)
Want use randomNumber method of faker in yaml.
hoge:
number: ${faker.number.randomNumber(12, true)}
FakerScriptRunner extends MethodReflectionEvalScriptRunner.
MethodReflectionEvalScriptRunner has ConverterFactory privately.
And ConverterFactory does not have StringToBooleanConverter (only KnownConverterModuleLoader knowns).
So, randomNumber(int, boolean)
can not be resolved.
Support google guava data type by adding converter module like java-8-converts and jodatime-converters module
my:
book: &book
id: ${sequence.number}
title: ${faker.book.title}
language: en
publishedAt: ${faker.date.between('2000-01-01', '2010-01-01')}
author:
id: ${sequence.number}
works:
- <<: *book
- <<: *book
- <<: *book
somethingElse: bla
first.yml
book: &book
id: 1
title: ${faker.book.title}
language: en
publishedAt: ${faker.date.between('2000-01-01', '2010-01-01')}
and
second.yml
book: &book
id: 2
title: ${faker.book.title}
language: en
publishedAt: ${faker.date.between('2000-01-01', '2010-01-01')}
See: also IDEA plugin and
another code generator
I'm using this with Kotlin data classes, they don't have default constructors. Since I can use _construct
this shouldn't be a problem. However, when trying to create a class with a script ${sequence.number}
, Beanmother gives an exception that my class doesn't have a default constructor.
This works:
valid_account:
_construct:
- 1 # Int
- Roxo # String
- 'BRL 0.00' # BigMoney
This doesn't:
valid_account:
_construct:
- ${sequence.number} # Int
- Roxo # String
- 'BRL 0.00' # BigMoney
Is this the correct behavior? Shouldn't scripts work anywhere?
Excellent tool again. I am using this for test data in a test project. Is there a way to read the values of the yaml file to a map of objects. Something like, map<Object, Object>?
Because the test data can grow over time and the structure will never get complex. So, it can get to a max of 2 or 3 levels in hierarchy. I am open to suggestions if this approach doesn't make sense. Please recommend what makes sense.
Thanks.
Add style guide for contributors. something like checkstyle.
Hi!
I want to try this library for testing, but the immediate problem I've run into is that I can't re-use an instance. Essentially I want to do this:
pizza: &pizza
ingredients:
- ham
- cheese
- pineapple
name: hawaiian
mario: &mario
name: Mario
lunch: *pizza
dinner: *pizza
breakfast: *pizza
Except I want a single instance of Pizza
. Eg so that mario.lunch == mario.dinner
instead of just mario.lunch.equals(mario.dinner)
Is there a built in way I can do this?
If target object has field of type Set, following exception is thrown
io.beanmother.core.mapper.FixtureMappingException: Target setter of 'name-of-the-property' must be List or array.
this method only checks for arrays or lists, because of that having custom converter doesn't resolve the problem.
author:
id: ${sequence.number}
policies:
id2:
id: ${sequence.number}
title: ${faker.book.title}
pubInfo:
publishedAt: ${current.date}
publishedAt: ${faker.date.between('2020-01-01', '2030-01-01')}
Is it possible to translate it to
private Pair<String, Book> policies;
I'm able to read it into a map though.
private Map<String, Book> policies;
Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.