Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
class CommunicationWebSocketCrossServiceTest {
private static final Duration COMMAND_WAIT = Duration.ofSeconds(45);
private static final long TENANT_ID = 1L;
private static final long ACCOUNT_ID = Long.parseLong(ChatTestFixtures.PLAYER_EMBERLINE);
private static final long SORA_ACCOUNT_ID = Long.parseLong(ChatTestFixtures.PLAYER_SORA);
private static final long NYX_ACCOUNT_ID = Long.parseLong(ChatTestFixtures.PLAYER_NYX);
private static final long ACCOUNT_ID = ChatTestFixtures.EMBERLINE_ACCOUNT_ROW_ID;
private static final long SORA_ACCOUNT_ID = ChatTestFixtures.SORA_ACCOUNT_ROW_ID;
private static final long NYX_ACCOUNT_ID = ChatTestFixtures.NYX_ACCOUNT_ROW_ID;
private static final long DEMO_WORLD_INSTANCE_ID = 1L;
private static final String READY_LOOK_TEXT = "Candle-lit Antechamber";

Expand Down Expand Up @@ -664,9 +664,9 @@ private long prepareGameInstance() {
DEMO_WORLD_INSTANCE_ID,
ACCOUNT_ID,
7L,
ACCOUNT_ID,
Long.parseLong(ChatTestFixtures.PLAYER_SORA),
Long.parseLong(ChatTestFixtures.PLAYER_NYX));
ChatTestFixtures.EMBERLINE_CHARACTER_ID,
ChatTestFixtures.SORA_CHARACTER_ID,
ChatTestFixtures.NYX_CHARACTER_ID);
}

private static String truncateGuardState(JdbcTemplate jdbc, BaselineTruncateGuard guard) {
Expand Down Expand Up @@ -719,19 +719,7 @@ private static SQLException mostSpecificSqlException(Throwable failure) {

private void seedLiveTargetSession() {
STACK.seedLiveSession(
90210L,
TENANT_ID,
Long.parseLong(ChatTestFixtures.PLAYER_SORA),
"sora@example.com",
Long.parseLong(ChatTestFixtures.PLAYER_SORA),
"Sora",
DEMO_WORLD_INSTANCE_ID,
ChatTestFixtures.ROOM_ID,
"target-jwt",
"demo",
"production",
1L,
"SHARED");
ChatTestFixtures.soraRecipientSession(90210L, TENANT_ID, DEMO_WORLD_INSTANCE_ID));
}

private List<String> runCommunicationSequence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.concurrent.TimeUnit;
import net.firedevops.firemud.gamesession.entity.PlayerCommandHistoryEntry;
import net.firedevops.firemud.gamesession.service.PlayerCommandHistoryStorageService;
import net.firedevops.firemud.gamesession.test.GameplayHistoryTestFixtures;
import net.firedevops.firemud.test.TestContainerImages;
import org.flywaydb.core.Flyway;
import org.jooq.DSLContext;
Expand Down Expand Up @@ -214,12 +215,6 @@ private PlayerCommandHistoryStorageService transactionalStorageService(
}

private PlayerCommandHistoryEntry historyEntry(String commandText, Instant acceptedAt) {
PlayerCommandHistoryEntry entry = new PlayerCommandHistoryEntry();
entry.setTenantId(22L);
entry.setGameInstanceId(7L);
entry.setCharacterId(13L);
entry.setCommandText(commandText);
entry.setAcceptedAt(acceptedAt);
return entry;
return GameplayHistoryTestFixtures.retainedCommand(commandText, acceptedAt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.firedevops.firemud.entitymanagement.v1.ApplyActorConditionResponse;
import net.firedevops.firemud.gamesession.client.GameLogicClient;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -21,8 +22,7 @@ class ActionStateCommandHandlerTest {
private final GameLogicClient gameLogicClient = Mockito.mock(GameLogicClient.class);
private final ActionStateCommandHandler handler =
new ActionStateCommandHandler(gameLogicClient, Clock.fixed(NOW, ZoneOffset.UTC));
private final SessionContext context =
new SessionContext(42L, 22L, "7", "demo@example.com", 91L, "Demo", 5L, "R-1", "jwt-token");
private final SessionContext context = GameplayCommandTestFixtures.durableDemo();

@Test
void blockAppliesShortLivedBlockingState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.firedevops.firemud.gamesession.service.AuthoredCommandAdmission;
import net.firedevops.firemud.gamesession.service.CommandService;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand Down Expand Up @@ -86,8 +87,7 @@ void rejectsAuthoredActionsWithoutGameplayContext() {
}

private static SessionContext context() {
return new SessionContext(
7L, 22L, "41", "emberline@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
return GameplayCommandTestFixtures.authoredDispatchEmberline();
}

private static TextCommand authoredAction(String commandId, String rawLine, List<String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import net.firedevops.firemud.gamesession.presentation.ItemMutationResultOutput;
import net.firedevops.firemud.gamesession.presentation.PlayerOutputKind;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

class ContainerCommandHandlerTest {
private final GameLogicClient gameLogicClient = Mockito.mock(GameLogicClient.class);
private final ContainerCommandHandler handler = new ContainerCommandHandler(gameLogicClient);
private final SessionContext context =
new SessionContext(
1L, 22L, "123", "emberline@example.com", 911L, "Emberline", 77L, "R-7", "jwt-token");
private final SessionContext context = GameplayCommandTestFixtures.inventoryEmberline();

@Test
void containerViewReturnsStructuredContents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
import net.firedevops.firemud.gamesession.presentation.ItemMutationResultOutput;
import net.firedevops.firemud.gamesession.presentation.PlayerOutputKind;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import net.firedevops.firemud.shared.v1.ErrorDetail;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

class EquipmentCommandHandlerTest {
private final GameLogicClient gameLogicClient = Mockito.mock(GameLogicClient.class);
private final EquipmentCommandHandler handler = new EquipmentCommandHandler(gameLogicClient);
private final SessionContext context =
new SessionContext(
1L, 22L, "123", "emberline@example.com", 911L, "Emberline", 77L, "R-7", "jwt-token");
private final SessionContext context = GameplayCommandTestFixtures.inventoryEmberline();

@Test
void wearWithoutItemReferenceFailsFast() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.firedevops.firemud.common.settings.ScopedSettingsSnapshot;
import net.firedevops.firemud.gamesession.service.GameAuthoredHelpReader;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;

class HelpCommandHandlerTest {
Expand Down Expand Up @@ -223,9 +224,7 @@ void helpIndexHidesHistoryWhenFeatureDisabled() {
HelpCommandHandler disabledHandler =
new HelpCommandHandler(
(context, topic) -> Optional.empty(), null, capabilitiesResolver(false));
SessionContext context =
new SessionContext(
42L, 22L, "123", "emberline@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
SessionContext context = GameplayCommandTestFixtures.helpCapabilityEmberline();

TextCommandInterpretationResult result =
disabledHandler.handle(
Expand All @@ -242,9 +241,7 @@ void helpIndexHidesEveryDisabledStandardCapabilityFamily() {
(context, topic) -> Optional.empty(),
null,
CommandCapabilitiesTestSupport.resolver(false, false, false, true));
SessionContext context =
new SessionContext(
42L, 22L, "123", "emberline@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
SessionContext context = GameplayCommandTestFixtures.helpCapabilityEmberline();

TextCommandInterpretationResult result =
disabledHandler.handle(
Expand All @@ -262,9 +259,7 @@ void helpHistoryTopicUnavailableWhenFeatureDisabled() {
HelpCommandHandler disabledHandler =
new HelpCommandHandler(
(context, topic) -> Optional.empty(), null, capabilitiesResolver(false));
SessionContext context =
new SessionContext(
42L, 22L, "123", "emberline@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
SessionContext context = GameplayCommandTestFixtures.helpCapabilityEmberline();

TextCommandInterpretationResult result =
disabledHandler.handle(
Expand All @@ -280,9 +275,7 @@ void helpHistoryTopicAvailableWhenFeatureEnabled() {
HelpCommandHandler enabledHandler =
new HelpCommandHandler(
(context, topic) -> Optional.empty(), null, capabilitiesResolver(true));
SessionContext context =
new SessionContext(
42L, 22L, "123", "emberline@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
SessionContext context = GameplayCommandTestFixtures.helpCapabilityEmberline();

TextCommandInterpretationResult result =
enabledHandler.handle(
Expand All @@ -303,9 +296,7 @@ void publishedGameAuthoredTopicOverridesPlatformTopicForAdmittedSession() {
"Temple Etiquette", "Bow before entering the moonlit sanctuary."))
: Optional.empty();
HelpCommandHandler authoredHelpHandler = new HelpCommandHandler(reader, null, null);
SessionContext context =
new SessionContext(
41L, 22L, "123", "demo@example.com", 7001L, "Emberline", 7L, "R-1", "jwt");
SessionContext context = GameplayCommandTestFixtures.authoredHelpEmberline();

TextCommandInterpretationResult result =
authoredHelpHandler.handle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Optional;
import net.firedevops.firemud.gamesession.service.ScriptEventPublisher;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -18,9 +19,7 @@ class HelpTextCommandDispatchHandlerTest {

@Test
void publishesCommandEventForGameplayScopedHelp() {
SessionContext context =
new SessionContext(
7L, 22L, "41", "emberline@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
SessionContext context = GameplayCommandTestFixtures.authoredDispatchEmberline();

TextCommandInterpretationResult result =
handler.handle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.firedevops.firemud.gamesession.config.EffectiveCommandHistorySettingsResolver;
import net.firedevops.firemud.gamesession.service.PlayerCommandHistoryStorageService;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand Down Expand Up @@ -39,7 +40,10 @@ void returnsNoRecentCommandsWhenHistoryIsEmpty() {
PlayerCommandHistoryStorageService storage =
Mockito.mock(PlayerCommandHistoryStorageService.class);
HistoryCommandHandler handler = handler(storage, 10, true);
Mockito.when(storage.findRecent(7L, 9L, 7001L, 10)).thenReturn(List.of());
Mockito.when(
storage.findRecent(
7L, 9L, GameplayCommandTestFixtures.historyEmberline().characterId(), 10))
.thenReturn(List.of());

SessionContext context = standardContext();

Expand All @@ -55,7 +59,10 @@ void defaultsToConfiguredMaxWhenCountIsOmitted() {
PlayerCommandHistoryStorageService storage =
Mockito.mock(PlayerCommandHistoryStorageService.class);
HistoryCommandHandler handler = handler(storage, 2, true);
Mockito.when(storage.findRecent(7L, 9L, 7001L, 2)).thenReturn(List.of("LOOK", "SAY hi"));
Mockito.when(
storage.findRecent(
7L, 9L, GameplayCommandTestFixtures.historyEmberline().characterId(), 2))
.thenReturn(List.of("LOOK", "SAY hi"));

SessionContext context = standardContext();

Expand All @@ -71,7 +78,9 @@ void usesExplicitCountAndReturnsChronologicalEntries() {
PlayerCommandHistoryStorageService storage =
Mockito.mock(PlayerCommandHistoryStorageService.class);
HistoryCommandHandler handler = handler(storage, 10, true);
Mockito.when(storage.findRecent(7L, 9L, 7001L, 5))
Mockito.when(
storage.findRecent(
7L, 9L, GameplayCommandTestFixtures.historyEmberline().characterId(), 5))
.thenReturn(List.of("LOOK", "SAY hello", "INVENTORY"));
SessionContext context = standardContext();

Expand All @@ -87,7 +96,8 @@ void usesExplicitCountAndReturnsChronologicalEntries() {

assertTrue(result.commandResult().accepted());
assertEquals("LOOK\nSAY hello\nINVENTORY", result.outputs().get(0).text());
Mockito.verify(storage).findRecent(7L, 9L, 7001L, 5);
Mockito.verify(storage)
.findRecent(7L, 9L, GameplayCommandTestFixtures.historyEmberline().characterId(), 5);
}

@Test
Expand All @@ -113,7 +123,9 @@ void returnsUnavailableWhenSettingsResolutionFails() {
void returnsUnavailableWhenHistoryStorageReadFails() {
PlayerCommandHistoryStorageService storage =
Mockito.mock(PlayerCommandHistoryStorageService.class);
Mockito.when(storage.findRecent(7L, 9L, 7001L, 10))
Mockito.when(
storage.findRecent(
7L, 9L, GameplayCommandTestFixtures.historyEmberline().characterId(), 10))
.thenThrow(new IllegalStateException("storage unavailable"));
HistoryCommandHandler handler = handler(storage, 10, true);

Expand Down Expand Up @@ -192,8 +204,7 @@ void rejectsNonPositiveHistoryCountWithoutReadingStorage() {
}

private SessionContext standardContext() {
return new SessionContext(
22L, 7L, "99", "demo@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
return GameplayCommandTestFixtures.historyEmberline();
}

private HistoryCommandHandler handler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.firedevops.firemud.gamesession.presentation.PlayerOutput;
import net.firedevops.firemud.gamesession.service.PlayerCommandHistoryStorageService;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -28,10 +29,11 @@ class HistoryTextCommandDispatchHandlerTest {

@Test
void dispatchesToHistoryHandler() {
Mockito.when(historyStorageService.findRecent(7L, 9L, 7001L, 2))
Mockito.when(
historyStorageService.findRecent(
7L, 9L, GameplayCommandTestFixtures.historyEmberline().characterId(), 2))
.thenReturn(List.of("LOOK", "SAY hi"));
SessionContext context =
new SessionContext(22L, 7L, "99", "demo@example.com", 7001L, "Emberline", 9L, "R-1", "jwt");
SessionContext context = GameplayCommandTestFixtures.historyEmberline();

TextCommandInterpretationResult result =
handler.handle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
import net.firedevops.firemud.gamesession.presentation.PlayerOutput;
import net.firedevops.firemud.gamesession.presentation.PlayerOutputKind;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import net.firedevops.firemud.shared.v1.ErrorDetail;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

class InventoryCommandHandlerTest {
private final GameLogicClient gameLogicClient = Mockito.mock(GameLogicClient.class);
private final InventoryCommandHandler handler = new InventoryCommandHandler(gameLogicClient);
private final SessionContext context =
new SessionContext(
1L, 22L, "123", "emberline@example.com", 911L, "Emberline", 77L, "R-7", "jwt-token");
private final SessionContext context = GameplayCommandTestFixtures.inventoryEmberline();

@Test
void inventoryReturnsStructuredViewFromRuntimeContract() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.firedevops.firemud.gamesession.dto.CommandEnqueueResult;
import net.firedevops.firemud.gamesession.service.ScriptEventPublisher;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -28,9 +29,7 @@ class ItemCommandHandlerTest {
containerHandler,
meterRegistry,
scriptEventPublisher);
private final SessionContext context =
new SessionContext(
1L, 22L, "123", "emberline@example.com", 911L, "Emberline", 77L, "R-7", "jwt-token");
private final SessionContext context = GameplayCommandTestFixtures.inventoryEmberline();

@Test
void recordsInvocationForSuccessfulItemCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.firedevops.firemud.gamesession.presentation.ErrorOutput;
import net.firedevops.firemud.gamesession.service.ScriptEventPublisher;
import net.firedevops.firemud.gamesession.service.SessionContext;
import net.firedevops.firemud.gamesession.test.GameplayCommandTestFixtures;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -21,9 +22,7 @@ class StatusCommandHandlerTest {
Mockito.mock(ScriptEventPublisher.class);
private final StatusCommandHandler handler =
new StatusCommandHandler(gameLogicClient, scriptEventPublisher);
private final SessionContext context =
new SessionContext(
1L, 22L, "123", "emberline@example.com", 911L, "Emberline", 77L, "R-7", "jwt-token");
private final SessionContext context = GameplayCommandTestFixtures.inventoryEmberline();

@Test
void statusProjectsEvaluatedResourcesAndVisibleConditionsInStableOrder() {
Expand Down
Loading
Loading