Prototest
The small library for creating object by class and fill it random data for easy testing.
From 1.0.2.0 version, you can use annotation with Junit5 extension.
Requirements
- JDK >= 8
- Maven >= 3
Maven configuration
Add the Maven dependency:
<dependency>
  <groupId>com.github.nmuzhichin</groupId>
  <artifactId>prototest</artifactId>
  <version>1.0.2.0</version>
  <scope>test</scope>
</dependency> 
How to use
Entry point is Prototest class that has methods for creating lazy pipeline.
Method execute() run pipeline and take ready to use object.
Sample
- Generate empty pipeline and run it:
final Empty empty = Prototest.empty().execute(); 
- Now take by class:
final SomethingClass newObj = Prototest.now(SomethingClass.class); 
- Uses flatten, identity, logs methods:
final SomethingClass obj = Prototest
                                    .configure()
                                    .fromClass(SomethingClass.class)
                                    .flatten(it -> Prototest.configure()
                                                            .fromClass(SimpleObject.class)
                                                            .side(q -> q.setName(it)))
                                    .log()
                                    .execute(); 
- Complex generate with configuration and listeners:
final TypeListener listener = type -> String.class == type ? RandomStringUtils.randomNumeric(12) : null;
Prototest
         .configure(config -> config.addImplementationFor(CustomInterface.class, new CustomInterfaceAbstractImpl("123")))
         .registerContainerListener(ContainerPhase.OBJECT_EMMIT, System.out::println)
         .registerTypesListener(TypePhase.CONSTRUCTOR_ARGS, listener)
         .fromClass(ComplexObject.class)
         .log()
         .assertions(it -> it.as().nonNull())
         .execute(); 
Annotation sample (from 1.0.2.0)
@ExtendWith(PrototestExtension.class)
@PrototestImplementations({
        @PrototestImplementation(className = String.class, value = "123456"),
        @PrototestImplementation(className = Integer.class),
        @PrototestImplementation(className = Byte.class, value = "123"),
})
public class ExtensionTest {
    private final ComplexObject object;
    @AsPrototest
    private ComplexObject object2;
    public ExtensionTest(@AsPrototest final ComplexObject object) {
        this.object = object;
    }
    @Test
    void t(@AsPrototest(DefaultConfig.DEFAULT) ComplexObject methodArg) {
        Assertions.assertNotNull(methodArg);
        Assertions.assertNotNull(object);
        Assertions.assertNotNull(object2);
    }
}
 
 JarCasting
 JarCasting