test-persistence-adapter

Generate @DataJpaTest slice tests for JPA persistence adapters using H2 and TestEntityManager.

3|Updated Feb 6, 2025
One-click install
npx skills add https://github.com/emaarco/easy-zeebe --skill test-persistence-adapter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-persistence-adapter
Source: https://github.com/emaarco/easy-zeebe/tree/main/.claude/skills/test-persistence-adapter
Command: npx skills add https://github.com/emaarco/easy-zeebe --skill test-persistence-adapter

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automates the creation of robust unit tests for your persistence adapters, ensuring data integrity and correct CRUD operations.

Core Features & Use Cases

  • Automated Test Generation: Creates @DataJpaTest compatible tests for JPA persistence adapters.
  • In-Memory Database: Utilizes H2 for fast, isolated testing without external dependencies.
  • Fixture Management: Employs @Sql for data setup, ensuring test independence.
  • Use Case: When you've implemented a new NewsletterSubscriptionPersistenceAdapter, use this Skill to quickly generate a comprehensive test suite that verifies its save, find, search, and delete functionalities.

Quick Start

Generate a test for the persistence adapter located at services/example-service/src/main/kotlin/io/miragon/example/adapter/outbound/db/NewsletterSubscriptionPersistenceAdapter.kt.

Frequently Asked Questions about test-persistence-adapter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate JPA tests for a persistence adapter?

To generate JPA tests for a persistence adapter, this Skill automatically creates `@DataJpaTest` slice tests that verify CRUD operations using an H2 in-memory database and `TestEntityManager`.

What is the best way to test JPA repository adapters in Kotlin?

The best way to test JPA repository adapters in Kotlin is using `@DataJpaTest` slice tests with H2 and `TestEntityManager`, which this Skill generates automatically to ensure data integrity and correct operations.

Does this approach to JPA testing use an in-memory database?

Yes, this JPA testing approach uses an H2 in-memory database to provide fast, isolated testing without external dependencies, alongside `@Sql` fixtures for test data setup.

How does @DataJpaTest handle test data fixtures for read and delete operations?

`@DataJpaTest` handles test data fixtures by employing `@Sql` scripts for data setup, ensuring test independence for read and delete operations while asserting results with `usingRecursiveComparison()`.

Can I use this to write tests for any JPA persistence adapter?

Yes, you can use this Skill to write tests for any JPA persistence adapter by requesting it to generate tests for a specific repository adapter file path in your Kotlin Gradle project.