Repository navigation
[Unit Tests] Add tests for CombatHealingReportEvent, display events, and CenterContentPriority #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
src/test/java/us/eunoians/mcrpg/display/hud/CenterContentPriorityTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package us.eunoians.mcrpg.display.hud; | ||
|
|
||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| @DisplayName("CenterContentPriority") | ||
| class CenterContentPriorityTest { | ||
|
|
||
| @Test | ||
| @DisplayName("AMBIENT_FEEDBACK is higher than COMBAT_EXIT_FEEDBACK") | ||
| void ambientFeedback_isHigherThanCombatExitFeedback() { | ||
| assertTrue(CenterContentPriority.AMBIENT_FEEDBACK > CenterContentPriority.COMBAT_EXIT_FEEDBACK); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("SAFE_ZONE_TRANSITION is higher than AMBIENT_FEEDBACK") | ||
| void safeZoneTransition_isHigherThanAmbientFeedback() { | ||
| assertTrue(CenterContentPriority.SAFE_ZONE_TRANSITION > CenterContentPriority.AMBIENT_FEEDBACK); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("ABILITY_FEEDBACK is higher than SAFE_ZONE_TRANSITION") | ||
| void abilityFeedback_isHigherThanSafeZoneTransition() { | ||
| assertTrue(CenterContentPriority.ABILITY_FEEDBACK > CenterContentPriority.SAFE_ZONE_TRANSITION); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("COMBO_STATE is higher than ABILITY_FEEDBACK") | ||
| void comboState_isHigherThanAbilityFeedback() { | ||
| assertTrue(CenterContentPriority.COMBO_STATE > CenterContentPriority.ABILITY_FEEDBACK); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("all priorities are positive") | ||
| void allPriorities_arePositive() { | ||
| assertTrue(CenterContentPriority.COMBAT_EXIT_FEEDBACK > 0); | ||
| assertTrue(CenterContentPriority.AMBIENT_FEEDBACK > 0); | ||
| assertTrue(CenterContentPriority.SAFE_ZONE_TRANSITION > 0); | ||
| assertTrue(CenterContentPriority.ABILITY_FEEDBACK > 0); | ||
| assertTrue(CenterContentPriority.COMBO_STATE > 0); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("third-party gap between COMBAT_EXIT_FEEDBACK and AMBIENT_FEEDBACK exists") | ||
| void gap_betweenCombatExitAndAmbient() { | ||
| assertTrue(CenterContentPriority.AMBIENT_FEEDBACK - CenterContentPriority.COMBAT_EXIT_FEEDBACK > 1, | ||
| "gap should allow third-party priorities between combat exit and ambient"); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("third-party gap between AMBIENT_FEEDBACK and SAFE_ZONE_TRANSITION exists") | ||
| void gap_betweenAmbientAndSafeZone() { | ||
| assertTrue(CenterContentPriority.SAFE_ZONE_TRANSITION - CenterContentPriority.AMBIENT_FEEDBACK > 1, | ||
| "gap should allow third-party priorities between ambient and safe zone"); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("third-party gap between SAFE_ZONE_TRANSITION and ABILITY_FEEDBACK exists") | ||
| void gap_betweenSafeZoneAndAbilityFeedback() { | ||
| assertTrue(CenterContentPriority.ABILITY_FEEDBACK - CenterContentPriority.SAFE_ZONE_TRANSITION > 1, | ||
| "gap should allow third-party priorities between safe zone and ability feedback"); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("third-party gap between ABILITY_FEEDBACK and COMBO_STATE exists") | ||
| void gap_betweenAbilityFeedbackAndComboState() { | ||
| assertTrue(CenterContentPriority.COMBO_STATE - CenterContentPriority.ABILITY_FEEDBACK > 1, | ||
| "gap should allow third-party priorities between ability feedback and combo state"); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("COMBO_STATE is below 100 to leave room for emergency overrides") | ||
| void comboState_isBelowHundred() { | ||
| assertTrue(CenterContentPriority.COMBO_STATE < 100, | ||
| "COMBO_STATE should be below 100 to leave room for third-party emergency overrides"); | ||
| } | ||
| } |
176 changes: 176 additions & 0 deletions
176
src/test/java/us/eunoians/mcrpg/event/combat/CombatHealingReportEventTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| package us.eunoians.mcrpg.event.combat; | ||
|
|
||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Nested; | ||
| import org.junit.jupiter.api.Test; | ||
| import us.eunoians.mcrpg.McRPGBaseTest; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| @DisplayName("CombatHealingReportEvent") | ||
| class CombatHealingReportEventTest extends McRPGBaseTest { | ||
|
|
||
| @Nested | ||
| @DisplayName("Constructor and getters") | ||
| class ConstructorAndGetters { | ||
|
|
||
| @Test | ||
| @DisplayName("constructor stores healer UUID") | ||
| void constructor_storesHealerUUID() { | ||
| UUID healer = UUID.randomUUID(); | ||
| UUID target = UUID.randomUUID(); | ||
| var event = new CombatHealingReportEvent(healer, target, 5.0); | ||
|
|
||
| assertEquals(healer, event.getHealerUUID()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("constructor stores target UUID") | ||
| void constructor_storesTargetUUID() { | ||
| UUID healer = UUID.randomUUID(); | ||
| UUID target = UUID.randomUUID(); | ||
| var event = new CombatHealingReportEvent(healer, target, 5.0); | ||
|
|
||
| assertEquals(target, event.getTargetUUID()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("constructor stores amount") | ||
| void constructor_storesAmount() { | ||
| UUID healer = UUID.randomUUID(); | ||
| UUID target = UUID.randomUUID(); | ||
| var event = new CombatHealingReportEvent(healer, target, 7.5); | ||
|
|
||
| assertEquals(7.5, event.getAmount()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("constructor accepts zero amount") | ||
| void constructor_acceptsZeroAmount() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 0.0); | ||
|
|
||
| assertEquals(0.0, event.getAmount()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("constructor accepts negative amount") | ||
| void constructor_acceptsNegativeAmount() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), -3.0); | ||
|
|
||
| assertEquals(-3.0, event.getAmount()); | ||
| } | ||
| } | ||
|
|
||
| @Nested | ||
| @DisplayName("Mutable amount") | ||
| class MutableAmount { | ||
|
|
||
| @Test | ||
| @DisplayName("setAmount updates the healing amount") | ||
| void setAmount_updatesAmount() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| event.setAmount(10.0); | ||
|
|
||
| assertEquals(10.0, event.getAmount()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("setAmount to zero clears the amount") | ||
| void setAmount_toZero() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| event.setAmount(0.0); | ||
|
|
||
| assertEquals(0.0, event.getAmount()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("setAmount accepts negative values for scaling down") | ||
| void setAmount_acceptsNegative() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| event.setAmount(-2.0); | ||
|
|
||
| assertEquals(-2.0, event.getAmount()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("setAmount can be called multiple times") | ||
| void setAmount_canBeCalledMultipleTimes() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| event.setAmount(10.0); | ||
| event.setAmount(20.0); | ||
|
|
||
| assertEquals(20.0, event.getAmount()); | ||
| } | ||
| } | ||
|
|
||
| @Nested | ||
| @DisplayName("Cancellable contract") | ||
| class CancellableContract { | ||
|
|
||
| @Test | ||
| @DisplayName("isCancelled defaults to false") | ||
| void isCancelled_defaultsFalse() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| assertFalse(event.isCancelled()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("setCancelled(true) makes isCancelled return true") | ||
| void setCancelled_true() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| event.setCancelled(true); | ||
|
|
||
| assertTrue(event.isCancelled()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("setCancelled can revert to false") | ||
| void setCancelled_canRevert() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| event.setCancelled(true); | ||
| event.setCancelled(false); | ||
|
|
||
| assertFalse(event.isCancelled()); | ||
| } | ||
| } | ||
|
|
||
| @Nested | ||
| @DisplayName("HandlerList") | ||
| class HandlerListTests { | ||
|
|
||
| @Test | ||
| @DisplayName("getHandlers returns non-null") | ||
| void getHandlers_returnsNonNull() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| assertNotNull(event.getHandlers()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("static getHandlerList returns non-null") | ||
| void getHandlerList_returnsNonNull() { | ||
| assertNotNull(CombatHealingReportEvent.getHandlerList()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("instance and static handler lists are the same object") | ||
| void handlerLists_areSameObject() { | ||
| var event = new CombatHealingReportEvent(UUID.randomUUID(), UUID.randomUUID(), 5.0); | ||
|
|
||
| assertNotNull(event.getHandlers()); | ||
| assertEquals(CombatHealingReportEvent.getHandlerList(), event.getHandlers()); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
Run these event tests as plain JUnit tests.
No test in this class uses MockBukkit or tracks an
McRPGPlayer. ExtendingMcRPGBaseTestloads and tears down the plugin for every test. Remove the inheritance. As per coding guidelines, “Do not extendMcRPGBaseTestwhen a test requires neither MockBukkit server interaction nor McRPGPlayer tracking; use plain JUnit instead.”🤖 Prompt for AI Agents
Source: Coding guidelines