Portfolio case study based on a Java/JPA university assignment: generate unit tests with one AI prompt, review the output, and organize the result into a runnable Maven test suite.
The original assignment implemented a small JPA model for a TOVAR table and three static methods:
Application.novyTovar(String nazov, Double cena)Application.tovarBezCeny()Application.odstranTovarBezCeny()
The AI task was to generate JUnit 4 tests that grade the solution from 0 to 10 points and verify persistence behavior, database constraints, duplicate handling, null prices, JPQL queries, and delete operations.
| Path | Purpose |
|---|---|
src/main/java/vsa/ |
Sanitized Java/JPA assignment solution |
src/test/java/vsa/ |
Runnable Codex-generated JUnit 4 test suite |
ai-generated/gemini/ |
Gemini-generated Java test outputs kept for comparison |
ai-generated/chatgpt/ |
ChatGPT-generated Java test outputs kept for comparison |
prompts/codex-prompt.md |
The one-prompt test-generation request |
docs/assignment-summary.md |
Short summary of the original assignment |
docs/test-results.md |
Captured test-result summary |
docs/comparison.md |
Notes comparing the generated approaches |
Requirements:
- Java 21
- Maven 3.9+
mvn testThe Maven project uses an in-memory H2 database in PostgreSQL compatibility mode so the tests can run without a local PostgreSQL server.
Current verification:
mvn testpasses locally with Java 21 and Maven 3.9.9.- The runnable Codex suite prints
BODY = 10for bothApplicationTestandApplicationTestAlt. - EclipseLink may print expected warnings during constraint checks because the tests intentionally try invalid
NULLand duplicate inserts.
- A new product is persisted and receives an ID.
- Duplicate product names return
nullinstead of throwing. NAZOVis unique and not nullable.CENAcan benull.tovarBezCeny()returns all products without a price.odstranTovarBezCeny()removes only products without a price.
This project shows more than "AI wrote tests." It demonstrates:
- turning an assignment specification into testable requirements;
- using AI as a test-generation assistant;
- reviewing generated tests for coverage and correctness;
- separating runnable tests from comparison artifacts;
- documenting results and tradeoffs.
Raw submission archives, saved browser pages, account-related browser assets, and .docx logs are intentionally excluded.