@@ -241,42 +241,6 @@ public void checkSpigotMessage(String expectedMessage) {
241
241
checkSpigotMessage (expectedMessage , 1 );
242
242
}
243
243
244
- /*
245
- public void checkSpigotMessage(String expectedMessage, boolean shouldBePresent) {
246
- // Capture the argument passed to spigot().sendMessage(...) if messages are sent
247
- ArgumentCaptor<TextComponent> captor = ArgumentCaptor.forClass(TextComponent.class);
248
-
249
- if (shouldBePresent) {
250
- // If we expect a message to be present, verify that sendMessage() was called at least once
251
- verify(spigot, atLeastOnce()).sendMessage(captor.capture());
252
-
253
- // Get all captured TextComponents
254
- List<TextComponent> capturedMessages = captor.getAllValues();
255
-
256
- // Check if any captured message contains the expected text
257
- boolean messageFound = capturedMessages.stream()
258
- .map(component -> component.toPlainText()) // Convert each TextComponent to plain text
259
- .anyMatch(messageText -> messageText.contains(expectedMessage)); // Check if the expected message is present
260
-
261
- // Assert that the message was found
262
- assertTrue("Expected message not found: " + expectedMessage, messageFound);
263
-
264
- } else {
265
- // If we expect no messages with this text, capture any sent messages to ensure none match the given message
266
- verify(spigot, atLeast(0)).sendMessage(captor.capture());
267
-
268
- // Get all captured TextComponents
269
- List<TextComponent> capturedMessages = captor.getAllValues();
270
-
271
- // Check that none of the captured messages contain the forbidden text
272
- boolean messageFound = capturedMessages.stream().map(component -> component.toPlainText()) // Convert each TextComponent to plain text
273
- .anyMatch(messageText -> messageText.contains(expectedMessage)); // Check if the message is present
274
-
275
- // Assert that the message was NOT found
276
- assertFalse("Unexpected message found: " + expectedMessage, messageFound);
277
- }
278
- }*/
279
-
280
244
public void checkSpigotMessage (String expectedMessage , int expectedOccurrences ) {
281
245
// Capture the argument passed to spigot().sendMessage(...) if messages are sent
282
246
ArgumentCaptor <TextComponent > captor = ArgumentCaptor .forClass (TextComponent .class );
0 commit comments