| name | new-challenge |
| description | Generate a fresh Java coding exercise (stub + failing JUnit tests) on a given topic for the user to solve on their own, TDD-style. Use when the user asks for a new challenge, exercise, or technical test on any Java/Spring/DSA/design topic. |
Skill: new-challenge
Create a new self-contained exercise in the java-mastery repo, following the repo's TDD
learning loop. The user solves it alone — never provide the solution up front.
Input
$ARGUMENTS = a topic and optional difficulty, e.g. "streams grouping", "binary tree
traversal medium", "builder pattern". If empty, pick the next logical topic from the
tracker in the root README.md.
Steps
- Determine the target module (e.g.
m05_streams_functional). Create the package
folders under src/main/java/com/mastery/<module>/exercises/ and the test folder
under src/test/java/com/mastery/<module>/ if they don't exist.
- Write an exercise class:
- Rich Javadoc describing the task, rules, edge cases, and hints (concepts, not answers).
- Public method signatures with
// TODO and throw new UnsupportedOperationException(...).
- Write a JUnit 5 test class (the technical test):
- Use AssertJ (
assertThat) and @DisplayName.
- Cover happy paths, edge cases (empty, null, negatives, boundaries), and at least one
tricky case. Prefer
@ParameterizedTest where it fits.
- Tests must currently FAIL (red) because of the stub.
- Run
mvn -Dtest=<TestClass> test to confirm it compiles and fails for the right reason
(assertion / UnsupportedOperationException), not a compile error.
- Report the file paths, the concepts covered, and the command to run.
Do NOT reveal the implementation.
Difficulty guidance
- easy: 1 method, single concept.
- medium: 2–3 methods, an edge case that bites, or a small algorithm.
- hard: interview-grade — non-trivial algorithm, performance constraint, or multi-class design.