Skip to content

Add JUnit5 tests for DefaultPasteUtil#2833

Merged
tastybento merged 1 commit intodevelopfrom
worktree-default-paste-util
Mar 8, 2026
Merged

Add JUnit5 tests for DefaultPasteUtil#2833
tastybento merged 1 commit intodevelopfrom
worktree-default-paste-util

Conversation

@tastybento
Copy link
Member

Summary

  • Adds 32 JUnit5 tests for DefaultPasteUtil covering all public and package-private methods
  • Tests use MockBukkit + Mockito following the CommonTestSetup pattern used throughout the project

Test coverage

  • createBlockData — success and fallback to convertBlockData on exception
  • convertBlockData — AIR fallback for unknown blocks, signoak_sign and wall_signoak_wall_sign legacy conversions, IllegalArgumentException logs warnings
  • setBlock — async completion via Util.getChunkAtAsync, biome set/skip
  • setSpawner — all seven spawner fields plus update()
  • setBlockState — InventoryHolder, CreatureSpawner, Banner (patterns present/null), Sign (writeSign called per side), ItemsAdder hook lookup, generic state no-op
  • setEntity — entity spawn and empty-list no-op
  • spawnBlueprintEntity — null type, Bukkit entity spawn + configureEntity, custom name with owner placeholder, null island, MythicMobs hook absent fallthrough
  • writeSign — normal paste, SPAWN_HERE (AIR/WATER + spawn point), SPAWN_HERE on back side ignored, null island, START_TEXT locale queries, START_TEXT null owner, WallSign facing

Notable implementation detail

DefaultPasteUtil stores BentoBox.getInstance() in a private static final field at class-load time. Mockito 5's inline mock maker clears mock instrumentation between tests via clearInlineMocks(), de-stubbing that captured mock. The test class uses sun.misc.Unsafe.putObject() in @BeforeEach to re-inject the current test's plugin mock into the final field before each test.

Test plan

  • All 32 tests pass locally (./gradlew test --tests "world.bentobox.bentobox.util.DefaultPasteUtilTest")

🤖 Generated with Claude Code

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

@tastybento tastybento merged commit fd9e7d7 into develop Mar 8, 2026
3 checks passed
@tastybento tastybento deleted the worktree-default-paste-util branch March 8, 2026 23:08
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