package com.example.tests;
import com.frotty27.hrtk.api.annotation.HytaleSuite;
import com.frotty27.hrtk.api.annotation.HytaleTest;
import com.frotty27.hrtk.api.annotation.Tag;
import com.frotty27.hrtk.api.annotation.DisplayName;
import com.frotty27.hrtk.api.annotation.Order;
import com.frotty27.hrtk.api.assert_.ChatAssert;
import com.frotty27.hrtk.api.assert_.HytaleAssert;
import com.frotty27.hrtk.api.lifecycle.IsolationStrategy;
@HytaleSuite(value = "Chat Surface Tests", isolation = IsolationStrategy.NONE)
@Tag("chat")
public class ChatSurfaceTests {
@HytaleTest
@Order(1)
@DisplayName("Message contains expected keyword")
void messageContainsKeyword() {
String captured = "Welcome to the Hytale server!";
// assertMessageContains checks for a substring match.
ChatAssert.assertMessageContains(captured, "Welcome");
ChatAssert.assertMessageContains(captured, "Hytale");
}
@HytaleTest
@Order(2)
@DisplayName("Non-empty message passes check")
void nonEmptyMessagePasses() {
String captured = "Player joined the game";
// assertMessageNotEmpty fails if the string is null or empty.
ChatAssert.assertMessageNotEmpty(captured);
}
@HytaleTest
@Order(3)
@DisplayName("Empty message is detected")
void emptyMessageDetected() {
String captured = "";
// This is a negative test - verify that empty messages are caught.
HytaleAssert.assertTrue(
"Empty string should have length 0",
captured.isEmpty()
);
}
@HytaleTest
@Order(4)
@DisplayName("Chat event class is available on the classpath")
void chatEventClassAvailable() {
// chatEventClassAvailable checks if PlayerChatEvent exists.
// If this fails, chat event testing will not work.
HytaleAssert.assertTrue(
"PlayerChatEvent class should be available",
ChatTestAdapter.chatEventClassAvailable()
);
}
@HytaleTest
@Order(5)
@DisplayName("Broadcast message succeeds")
void broadcastMessageSucceeds() {
// broadcastMessage sends a message to all players via the Universe API.
// Returns true on success, false if the API is unavailable.
boolean sent = ChatTestAdapter.broadcastMessage("Test broadcast from HRTK");
HytaleAssert.assertTrue("Broadcast should succeed", sent);
}
}