altan/develop: Selection Tool: refactor, tests and lab portfolio#13
Open
AltanEsmer wants to merge 9 commits into
Open
altan/develop: Selection Tool: refactor, tests and lab portfolio#13AltanEsmer wants to merge 9 commits into
AltanEsmer wants to merge 9 commits into
Conversation
Add a CI Maven settings file (.maven-settings.xml) that provides a GitHub server entry using ${env.GITHUB_ACTOR} and ${env.GITHUB_TOKEN}. Update jhotdraw-core/pom.xml to include several test dependencies (junit 4.13.2, mockito-core 3.12.4, jgiven-junit 1.3.1, assertj-core 3.24.2, assertj-swing-junit 3.17.1) and configure the maven-surefire-plugin (3.2.5) with --add-opens JVM args for java.lang and java.lang.reflect to allow reflective access during tests.
Extract mouse-press logic into helper methods (findTargetFigure, resolveTracker) and add isViewActive() for concise view checks. Consolidate tracker activation/deactivation into setTracker (with null guard) and update toolDone to use it. Replace repetitive getView()/isEnabled() checks with isViewActive and preserve existing select-behind and handle/drag/selection behaviors. Adds Javadoc for new helpers and cleans up control flow for readability and maintainability.
Add comprehensive tests for SelectionTool: a JUnit4 + Mockito test suite (SelectionToolTest) that verifies tracker lazy-init, activation/deactivation delegation, select-behind behavior, handle/drag/select-area resolution, property change firing, and boundary/invariant cases. Add JGiven BDD tests (GivenSelectionTool, WhenSelectionTool, ThenSelectionTool, SelectionToolBDDTest) to express key user stories and scenarios (clicking figures/handles/empty area, disabled view, alt-select-behind) in Given/When/Then form. Include TestableSelectionTool helper classes that expose protected SelectionTool methods for testing.
Extract selection hit-test logic into smaller helpers and clarify select-behind behavior. The method findTargetFigure now routes to isSelectBehindModifierHeld(evt) and delegates to findFigureBehindCurrentSelection(...) or findFigureAtPoint(...). Added isSelectBehindModifierHeld, findFigureBehindCurrentSelection, and findFigureAtPoint to improve readability and separate concerns; preserved original search order and select-behind semantics (ALT/CTRL modifier) and retained compatibility notes with other trackers.
- Add Labs/ portfolio write-ups for the Selection Tool feature: concept location, user story, impact analysis, refactoring, actualization (SOLID / Clean Architecture), unit testing and BDD. - Add US2 BDD scenario: clicking an empty area clears the current selection. - Enable assertions in surefire so the invariant assert checks actually run. - Remove the unused assertj-swing-junit test dependency.
jgiven-junit 1.3.1 is compiled for Java 11 (class-file major version 55) and cannot be loaded by the JDK 8 build, which broke testCompile. 0.18.2 is the last Java 7/8-compatible release and keeps the same ScenarioTest / Stage / scenario-state API the BDD scenarios use.
The surefire --add-opens options are Java 9+ only; on the JDK 8 CI they
crash the forked test VM ("Could not create the Java Virtual Machine").
Move them into a profile activated on JDK [9,) so JDK 8 runs the tests
without them (no module system, so they aren't needed there) while local
newer-JDK runs still get them for Mockito.
Collaborator
|
lgtm. please fix the merge conflict and we can then request review again. ty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My individual work on the Selection Tool feature (
org.jhotdraw.draw.tool.SelectionTool).SelectionTool: extract/compose method onmousePressed, a singleisViewActive()guard in place of the duplicated view checks, and the figure lookup split into focused helpers.Labs/portfolio write-ups: concept location, user story, impact analysis, refactoring, actualization, testing and BDD.User story: #12.