Skip to content
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

Test QOL Changes #6001

Merged
merged 4 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions megamek/unittests/megamek/client/bot/ChatProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
*/
package megamek.client.bot;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import java.util.HashSet;
import java.util.Set;
import java.util.Vector;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;

import megamek.client.bot.princess.BehaviorSettingsFactory;
import megamek.client.bot.princess.CardinalEdge;
import megamek.client.bot.princess.ChatCommands;
Expand All @@ -28,25 +46,13 @@
import megamek.common.Game;
import megamek.common.Player;
import megamek.common.event.GamePlayerChatEvent;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;

import java.util.HashSet;
import java.util.Set;
import java.util.Vector;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;

/**
* User: Deric "Netzilla" Page (deric dot page at usa dot net)
* Date: 8/17/13
* Time: 9:32 AM
*/
public class ChatProcessorTest {
class ChatProcessorTest {

private static BotClient mockBotHal;
private static final Game MOCK_GAME = mock(Game.class);
Expand All @@ -57,7 +63,7 @@ public class ChatProcessorTest {
private static Player mockHumanPlayerKirk;

@BeforeAll
public static void beforeAll() {
static void beforeAll() {
mockHumanPlayerDave = mock(Player.class);
mockHumanPlayerKirk = mock(Player.class);
mockBotPlayerHal = mock(Player.class);
Expand Down Expand Up @@ -108,7 +114,7 @@ public static void beforeAll() {
}

@Test
public void testAdditionalPrincessCommands() {
void testAdditionalPrincessCommands() {
final ChatProcessor testChatProcessor = new ChatProcessor();

final Board mockBoard = mock(Board.class);
Expand Down Expand Up @@ -537,7 +543,7 @@ public void testAdditionalPrincessCommands() {

// Test a chat message not directed at Princess.
mockChatEvent = mock(GamePlayerChatEvent.class);
chatMessage = "MovementDisplay: tried to select non-existant entity: -1";
chatMessage = "MovementDisplay: tried to select non-existent entity: -1";
when(mockChatEvent.getMessage()).thenReturn(chatMessage);
when(mockChatEvent.getPlayer()).thenReturn(null);
mockPrincess = spy(new Princess(mockBotPlayerVGer.getName(), "test", 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,9 @@ void testAssertWillStallOnAtmosphereGroundMap() {
assertFalse(result);
}

@Test
void testAssertWillStallNotOnAtmosphereGroundMap() {
final Entity mockEntity = MockGenerators.generateMockAerospace(0, 0);
when(mockEntity.isAirborne()).thenReturn(true);

final MovePath mockPath = MockGenerators.generateMockPath(16, 16, mockEntity);
when(mockPath.isOnAtmosphericGroundMap()).thenReturn(true);
when(mockPath.getFinalVelocity()).thenReturn(0);

boolean result = AeroPathUtil.willStall(mockPath);
assertTrue(result);
}

@Test
void testAssertWillStallAsSpheroidDropshipWithVLAND() {
final Entity mockEntity = MockGenerators.generateMockAerospace(0, 0);
when(mockEntity.isAirborne()).thenReturn(true);
when(mockEntity.isAero()).thenReturn(true);
when(mockEntity.isSpheroid()).thenReturn(true);

final MovePath mockPath = MockGenerators.generateMockPath(16, 16, mockEntity);
Expand All @@ -79,7 +64,6 @@ void testAssertWillStallAsSpheroidDropshipWithVLAND() {
@Test
void testAssertWillCrashWithOutLandOrVland() {
final Entity mockEntity = MockGenerators.generateMockAerospace(0, 0);
when(mockEntity.isAero()).thenReturn(true);

final MovePath mockPath = MockGenerators.generateMockPath(16, 16, mockEntity);
when(mockPath.getFinalVelocity()).thenReturn(1);
Expand All @@ -91,7 +75,6 @@ void testAssertWillCrashWithOutLandOrVland() {
@Test
void testAssertWillCrashWithLandOrVland() {
final Entity mockEntity = MockGenerators.generateMockAerospace(0, 0);
when(mockEntity.isAero()).thenReturn(true);

final MovePath mockPath = MockGenerators.generateMockPath(16, 16, mockEntity);
when(mockPath.getFinalVelocity()).thenReturn(0);
Expand All @@ -101,5 +84,4 @@ void testAssertWillCrashWithLandOrVland() {
boolean result = AeroPathUtil.willCrash(mockPath);
assertFalse(result);
}

}
Loading