TLDR
Improving test coverage for CatanGraph. Actually found a pretty nice bug! Overriding equals and hashCode of ResourceBundle so tests can do easy equality checks. Hitting all branches of conditional logic so Jacoco is happy.

Equals and Hash Code overrides.
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof ResourceBundle that) {
return Objects.equals(resources, that.resources);
} else {
return false;
}
}
@Override
public int hashCode() {
return Objects.hash(
ALL_RESOURCE_COLORS.stream().map(resources::get).toArray()
);
}
Main work
- Used ChatGPT to generate tests for equals and hashCode for
ResourceBundle- Also used it to debug issue with
Objects.hash(...), it was not working as expected at first.
- Also used it to debug issue with
- Copying over test data from actual application running and writing assertions against it.
- Tracking down bug with overwritting hash map values.
- Thinking about how future tests will need to be added.
- Mostly, creating the
resourcestest folder containing board screenshots and JSONGameStatedumps.
- Mostly, creating the
Challenges
- Difficulty debugging long functional
Stream APIexpressions. - Difficulty trying to quickly grok differences between
Objects.hash(...)andObject.hashCode().- I’m sure I could dive into this and be 1000% sure about the differences, but I have a concert to go to. :D
Learnings
- Test Driven Design might have some merits!
- Caught a bug where adjacent
Roadnodes for aSettlementwereput()into theHashMap<GraphNode, List<GraphNode>>graph data structure, before being overwritten by a subsequentput()that adds the adjacentHexagonnodes.
- Caught a bug where adjacent