Skip to content

Commit

Permalink
Updated sounds tests for compatibility reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
fulminazzo committed Dec 24, 2024
1 parent 4d27a0c commit 8550d2a
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void testInvalidDataTypeButNotOption() {

@Test
void testPlaySound() {
Sound sound = new Sound(org.bukkit.Sound.BLOCK_GLASS_STEP.name(),10, 2, SoundCategory.BLOCKS.name());
Sound sound = new Sound("BLOCK_GLASS_STEP",10, 2, SoundCategory.BLOCKS.name());
Player player = mock(Player.class);

when(player.getLocation()).thenReturn(new Location(null, 0, 1, 0));
Expand All @@ -289,7 +289,7 @@ void testPlaySound() {
verify(player).playSound(any(Location.class), soundArg.capture(),
categoryArg.capture(), volumeArg.capture(), pitchArg.capture());

assertEquals(sound.getName(), soundArg.getValue().name());
assertEquals(sound.getName(), new Refl<>(soundArg).invokeMethodRefl("getValue").invokeMethod("name"));

assertEquals(sound.getVolume(), volumeArg.getValue());
assertEquals(sound.getPitch(), pitchArg.getValue());
Expand All @@ -299,7 +299,7 @@ void testPlaySound() {

@Test
void testPlaySoundNoCategory() {
Sound sound = new Sound(org.bukkit.Sound.BLOCK_GLASS_STEP.name(),10, 2);
Sound sound = new Sound("BLOCK_GLASS_STEP",10, 2);
Player player = mock(Player.class);

when(player.getLocation()).thenReturn(new Location(null, 0, 1, 0));
Expand All @@ -311,7 +311,7 @@ void testPlaySoundNoCategory() {
ArgumentCaptor<Float> pitchArg = ArgumentCaptor.forClass(Float.class);
verify(player).playSound(any(Location.class), soundArg.capture(), volumeArg.capture(), pitchArg.capture());

assertEquals(sound.getName(), soundArg.getValue().name());
assertEquals(sound.getName(), new Refl<>(soundArg).invokeMethodRefl("getValue").invokeMethod("name"));

assertEquals(sound.getVolume(), volumeArg.getValue());
assertEquals(sound.getPitch(), pitchArg.getValue());
Expand All @@ -321,7 +321,7 @@ void testPlaySoundNoCategory() {
void testPlaySoundInvalidCategory() {
Player player = mock(Player.class);
assertThrowsExactly(IllegalArgumentException.class, () ->
WrappersAdapter.playSound(player, new Sound(org.bukkit.Sound.BLOCK_ANVIL_FALL.name(),
WrappersAdapter.playSound(player, new Sound("BLOCK_ANVIL_FALL",
1f, 1f, "hostiles")));
}

Expand Down

0 comments on commit 8550d2a

Please sign in to comment.