Style: Apply Spotless

This commit is contained in:
Mathis Ginkel
2026-04-26 23:54:15 +02:00
parent b7f5a268e3
commit e9b40e9d04
5 changed files with 31 additions and 29 deletions
@@ -2,9 +2,7 @@ package ch.unibas.dmi.dbis.cs108.casono.client.chat;
import java.util.List;
/**
* Interface used to create test instances of the ChatClient
*/
/** Interface used to create test instances of the ChatClient */
public interface ChatClientInterface {
List<Message> getMessages();
@@ -12,5 +10,4 @@ public interface ChatClientInterface {
void sendMessage(Message message);
List<String> getUsers();
}
@@ -113,7 +113,9 @@ public class ChatController {
}
/**
* Another constructor to give the ChatClient directly instead of the Client Service used only for test purposes
* Another constructor to give the ChatClient directly instead of the Client Service used only
* for test purposes
*
* @param username
*/
public ChatController(String username, ChatClientInterface chatClient) {
@@ -166,17 +166,17 @@ public class ChatBoxController {
if (!activeWhisperChats.contains(target)) {
activeWhisperChats.add(target);
ChatType whisper = ChatType.WHISPER;
chatController
.getChatModelMap()
.put(new ChatKey(whisper, target), chatModel);
chatController.getChatModelMap().put(new ChatKey(whisper, target), chatModel);
ChatViewController chatViewController = addChatTab(target, chatModel, whisper);
Tab chatTab = chatViewController.getChatTab();
chatTab.setOnCloseRequest(_ -> {
chatViewController.tabIsOpen = false;
chatTabPane.getTabs().remove(chatTab);
});
chatTab.setOnCloseRequest(
_ -> {
chatViewController.tabIsOpen = false;
chatTabPane.getTabs().remove(chatTab);
});
} else {
ChatViewController chatViewController = chatController.activeChatControllers.get(new ChatKey(ChatType.WHISPER, target));
ChatViewController chatViewController =
chatController.activeChatControllers.get(new ChatKey(ChatType.WHISPER, target));
if (!chatViewController.tabIsOpen) {
reopenChatTab(chatViewController.getChatTab());
chatViewController.tabIsOpen = true;
@@ -211,8 +211,7 @@ public class ChatBoxController {
} else {
chatKey = new ChatKey(chatType);
}
chatController.activeChatControllers.put(
chatKey, chatViewController);
chatController.activeChatControllers.put(chatKey, chatViewController);
fxmlLoader.setController(chatViewController);
Node load = fxmlLoader.load();
VBox.setVgrow(load, Priority.ALWAYS);
@@ -291,9 +290,10 @@ public class ChatBoxController {
}
public void reopenChatTab(Tab chatTab) {
Platform.runLater(() -> {
chatTabPane.getTabs().add(chatTab);
chatTabPane.getSelectionModel().select(chatTab);
});
Platform.runLater(
() -> {
chatTabPane.getTabs().add(chatTab);
chatTabPane.getSelectionModel().select(chatTab);
});
}
}
@@ -2,10 +2,8 @@ package ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui;
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatController;
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatModel;
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatType;
import ch.unibas.dmi.dbis.cs108.casono.client.chat.Message;
import java.net.URL;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.fxml.FXML;
@@ -50,7 +48,11 @@ public class ChatViewController implements Initializable {
private static final int CHAT_PADDING = 20;
public ChatViewController(ChatController chatController, ChatModel chatModel, String username, ChatBoxController chatBoxController) {
public ChatViewController(
ChatController chatController,
ChatModel chatModel,
String username,
ChatBoxController chatBoxController) {
this.controller = chatController;
this.username = username;
this.chatModel = chatModel;
@@ -1,14 +1,13 @@
package ch.unibas.dmi.dbis.cs108.casono.client.chat;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.util.ArrayList;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ChatControllerTest {
ChatController chatController1;
@@ -117,7 +116,9 @@ public class ChatControllerTest {
@Test
public void sendWhisperMessage() {
ChatModel whisper = new ChatModel(ChatType.WHISPER, name2, -1, name1);
chatController2.getChatModelMap().put(new ChatController.ChatKey(ChatType.WHISPER, name1), whisper);
chatController2
.getChatModelMap()
.put(new ChatController.ChatKey(ChatType.WHISPER, name1), whisper);
Message msg1 = new Message(ChatType.WHISPER, -1, name1, name2, "Hallo Welt");
Message msg2 = new Message(ChatType.WHISPER, -1, name1, name2, "$$Hallo$$Welt$$");