spring-fixtures

A library to help create fixtures in spring applications

Лицензия

Лицензия

Категории

Категории

Ant Компиляция и сборка Сеть
Группа

Группа

net.savantly
Идентификатор

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

spring-fixtures
Последняя версия

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

1.0.0-RELEASE
Дата

Дата

Тип

Тип

jar
Описание

Описание

spring-fixtures
A library to help create fixtures in spring applications
Ссылка на сайт

Ссылка на сайт

https://github.com/savantly-net/spring-fixtures
Система контроля версий

Система контроля версий

https://github.com/savantly-net/spring-fixtures

Скачать spring-fixtures

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

<!-- https://jarcasting.com/artifacts/net.savantly/spring-fixtures/ -->
<dependency>
    <groupId>net.savantly</groupId>
    <artifactId>spring-fixtures</artifactId>
    <version>1.0.0-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/net.savantly/spring-fixtures/
implementation 'net.savantly:spring-fixtures:1.0.0-RELEASE'
// https://jarcasting.com/artifacts/net.savantly/spring-fixtures/
implementation ("net.savantly:spring-fixtures:1.0.0-RELEASE")
'net.savantly:spring-fixtures:jar:1.0.0-RELEASE'
<dependency org="net.savantly" name="spring-fixtures" rev="1.0.0-RELEASE">
  <artifact name="spring-fixtures" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.savantly', module='spring-fixtures', version='1.0.0-RELEASE')
)
libraryDependencies += "net.savantly" % "spring-fixtures" % "1.0.0-RELEASE"
[net.savantly/spring-fixtures "1.0.0-RELEASE"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
joda-time : joda-time jar 2.9.1
org.springframework.data : spring-data-jpa jar 2.0.5.RELEASE

test (5)

Идентификатор библиотеки Тип Версия
org.eclipse.persistence : eclipselink jar 2.6.2
org.hsqldb : hsqldb jar 2.3.3
junit : junit jar 4.12
org.springframework : spring-test jar 5.0.4.RELEASE
ch.qos.logback : logback-classic jar 1.1.3

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

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

spring-fixtures

Spring-fixtures is a library that makes integration testing easier. It is also helpful when prototyping and demonstrating an application.

Fixtures

A fixture can implement the Fixture interface, or extend the provided AbstractBaseFixture

The AbstractBaseFixture manages fixture dependencies on other fixtures. Suppose you have an "Order" entity that requires instances of "Item" and "Customer" entities. The "Item" and "Customer" fixtures can be added as dependencies of the "Order" fixture so the installation of the prerequisites are ensured. An example of this can be found here

The AbstractBaseFixture expects an Entity, and a Repository class that extends CrudReposity

Examples of fixtures and tests are included src/test/java/

Fixture Tests

An abstract fixture test is available. No implementation is required. src/test/java/net/savantly/example/test/AbstractFixtureTest.java

public class ItemFixtureTest extends AbstractFixtureTest<Item, ItemFixture, ItemRepository> {}

RandomGenerator

A RandomGenerator class is provided to mock data for your entities

The RandomGenerator can produce varying lengths of strings or paragraphs, and provides other functions like Address generation, and random date generation in the future or past.

Example Fixture -

@Service
public class ItemFixture extends AbstractBaseFixture<Item, ItemRepository>{
    @Autowired
    public ItemFixture(ItemRepository repository) {
    	super(repository);
    }

    @Override
    public void addEntities(List<Item> entityList) {
    	log.info("Adding Item Entities to Fixture");
    	for (int i = 0; i < 20; i++) {
    		Item item = new Item();
    		item.setDescription(getRandomAlphaWordString(20, 10));
    		item.setPrice(getRandomMoneyValue(8000, 2, false));
    		entityList.add(item);
    		log.debug(String.format("Entity added: %s", item));
    	}
    }

    @Override
    public void addDependencies(List<Fixture<?>> dependencies) {
    	// There are no fixture dependencies
    }
}
net.savantly

Savantly

Savantly custom software solutions for your business

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

Версия
1.0.0-RELEASE
0.0.1-RELEASE