Skip to content

Commit

Permalink
Fix UpdateRequirementsPacketTests being skipped because MockPlayer#up…
Browse files Browse the repository at this point in the history
…dateCommands threw UnsupportedOperationException
  • Loading branch information
willkroboth committed Sep 22, 2023
1 parent 7c17e18 commit 0163561
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

class UpdateRequirementsPacketTests extends NetworkTestBase {

Expand All @@ -29,7 +30,12 @@ public void tearDown() {

@Test
void sendReceiveTestWithUpdateRequirementsPacket() {
PlayerMock player = server.addPlayer(); // Protocol version currently 0
PlayerMock player = Mockito.spy(new PlayerMock(server, "player"));
// Interrupt normal calls to updateCommands, because MockPlayer throws an UnimplementedOperationException
Mockito.doNothing().when(player).updateCommands();
server.addPlayer(player);

// Protocol version currently 0

// Error when sending packet to target that has not declared they understand CommandAPI plugin messages
assertThrowsWithMessage(
Expand All @@ -47,5 +53,8 @@ void sendReceiveTestWithUpdateRequirementsPacket() {
new UpdateRequirementsPacket(),
new byte[]{0}
);

// Update commands should have been called for this player
Mockito.verify(player, Mockito.times(1)).updateCommands();
}
}

0 comments on commit 0163561

Please sign in to comment.