Prototype

The small library for creating object by class and fill it random data for easy-test.

Лицензия

Лицензия

Группа

Группа

com.github.nmuzhichin
Идентификатор

Идентификатор

prototest
Последняя версия

Последняя версия

1.0.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Prototype
The small library for creating object by class and fill it random data for easy-test.

Скачать prototest

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.nmuzhichin/prototest/ -->
<dependency>
    <groupId>com.github.nmuzhichin</groupId>
    <artifactId>prototest</artifactId>
    <version>1.0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.nmuzhichin/prototest/
implementation 'com.github.nmuzhichin:prototest:1.0.2.0'
// https://jarcasting.com/artifacts/com.github.nmuzhichin/prototest/
implementation ("com.github.nmuzhichin:prototest:1.0.2.0")
'com.github.nmuzhichin:prototest:jar:1.0.2.0'
<dependency org="com.github.nmuzhichin" name="prototest" rev="1.0.2.0">
  <artifact name="prototest" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.nmuzhichin', module='prototest', version='1.0.2.0')
)
libraryDependencies += "com.github.nmuzhichin" % "prototest" % "1.0.2.0"
[com.github.nmuzhichin/prototest "1.0.2.0"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.apache.commons : commons-lang3 jar 3.9
org.slf4j : slf4j-api jar 1.7.26
com.fasterxml.jackson.core : jackson-databind jar 2.9.10.1

provided (1)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-api Необязательный jar 5.4.2

test (2)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-engine jar 5.4.2
com.fasterxml.jackson.core : jackson-core jar 2.9.8

Модули Проекта

Данный проект не имеет модулей.

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);
    }
}
See more in test

Версии библиотеки

Версия
1.0.2.0
1.0.0.1