An open API service indexing awesome lists of open source software.

https://github.com/sterlp/hibernate-test-asserts

HibernateAsserts helps verifying JPA characteristics in Hibernate projects, ensuring correct fetch joins, relationships, and transaction boundaries to prevent performance issues and errors.
https://github.com/sterlp/hibernate-test-asserts

assert hibernate jpa junit lazy-loading query test testing transactions

Last synced: about 2 months ago
JSON representation

HibernateAsserts helps verifying JPA characteristics in Hibernate projects, ensuring correct fetch joins, relationships, and transaction boundaries to prevent performance issues and errors.

Awesome Lists containing this project

README

          

[![Java CI with Maven](https://github.com/sterlp/hibernate-test-asserts/actions/workflows/maven.yml/badge.svg)](https://github.com/sterlp/hibernate-test-asserts/actions/workflows/maven.yml)

# Setup

- [Maven](https://central.sonatype.com/search?q=hibernate-asserts&namespace=org.sterl.test)
- [Blog](https://sterl.org/2021/08/jpa-model-testing-with-hibernate-statistics/)

```xml

org.sterl.test
hibernate-asserts
1.0.x
test

```
# Example

```java
@Configuration
public static class Config {
@Bean
HibernateAsserts hibernateAsserts(EntityManager entityManager) {
return new HibernateAsserts(entityManager);
}
}

@Autowired
private PersonService subject;
@Autowired
private HibernateAsserts hibernateAsserts;

@Test
void testCreatePerson() {
// GIVEN
var name = "Paul";

// WHEN
subject.create(name);

// THEN
hibernateAsserts
.assertInsertCount(1)
.assertUpdateCount(0)
.assertTrxCount(1);
}
```