Skip to content

Add tests for the food item and event factories - #166

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/food-and-event-factory-tests
Nov 13, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/food-and-event-factory-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • FoodItemFactoryTest is added: a food item is added to the square's entities, each call adds a separate entity, its appearance is written to the event log as A new food item called <name> has appeared at <x>, <y>., and it is not registered as an actor.
  • The two behaviors described in Food items on a square are treated as missing actors by view and by the actor actions #160 are pinned as they are today rather than changed: Square#getNumActors counts the food item, and Square#getRandomActor throws ActorNotFoundException on a square holding only food. These two tests are expected to be updated when Food items on a square are treated as missing actors by view and by the actor actions #160 is decided.
  • FoodItemTest is added: the name is kept, UUIDs differ between items with the same name, starting nutrition falls in [0, CONFIG.MAX_NUTRITION), and setNutrition overwrites it.
  • EventFactoryTest is added: the message is kept unchanged (including null), the timestamp falls between the instants before and after creation, and each call returns a new event.
  • No production code is changed. The log-writing test points the data directory at a temporary directory of its own, the same way LoggerTest does.

Test plan

  • mvn -B clean test: 228 tests run, 0 failures, 0 errors
  • mvn surefire:test -Dtest='FoodItem*Test,EventFactoryTest': 14 tests run, all passing

Deferred issues

No tracking issue exists for this work; the gap was found during triage (unit-test expansion).

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (scored against the diff, the local mvn -B clean test run, and the Browser build check):

  • Scope: PASS. Three new test files and nothing else; git diff --stat origin/main...HEAD shows 3 files and 208 insertions, all under src/main/java/dansapps/interakt/tests/.
  • Tests-new: PASS. No production methods are added. Each method of the classes under test (FoodItemFactory#createFoodItemAt, FoodItem constructor, getNutrition and setNutrition, EventFactory#createEvent, Event#getMessage and getTimestamp) is exercised by at least one new test.
  • Tests-fix: N/A. No bug fix is included. The Food items on a square are treated as missing actors by view and by the actor actions #160 behavior is characterized, not changed.
  • Sibling structure: PASS. The files follow TimePartitionFactoryTest and LoggerTest: a class Javadoc describing what is characterized, org.junit.Assert, and a temporary data directory restored through LocalStorageServiceTest.restoreDataDirectoryProperty.
  • Sibling renames: N/A. Nothing is renamed.
  • Docs: PASS. No commands, build steps, or modes change, so README.md, HelpCommand, compile.sh and pom.xml are unaffected.
  • Issue resolution: PASS. Nothing is claimed as closed. Food items on a square are treated as missing actors by view and by the actor actions #160 is referenced but deliberately left open.
  • Local build+test run: PASS. mvn -B clean test ran 228 tests with 0 failures and 0 errors, and a targeted run executed all 14 new tests. The Browser build check passed on the PR head.
  • No singleton reintroduction: PASS. Each test constructs its own PersistentData.
  • License header on new files: PASS by convention. The new files carry no header, which matches every existing file under tests/. The wider header question remains with Per-file copyright headers cite Apache License 2.0 while LICENSE is Stephenson-NC #104.

Judgment calls for the owner:

The diff contains test code only, with green local and CI anchors.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 61e1442 into main Nov 13, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/food-and-event-factory-tests branch November 13, 2026 03:52
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Correction to the self-review above: the two #160 characterization tests are at FoodItemFactoryTest.java:93 (testSquareCountsTheFoodItemAsAnActor) and FoodItemFactoryTest.java:101 (testRandomActorOnASquareWithOnlyFoodThrows), not lines 91 and 99 as stated.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant