- ChatRoom chatRoom = mock(ChatRoom.class);
- when(chatHome.getChatroom(any(UUID.class)))
- .thenReturn(Mono.just(chatRoom));
- Message.MessageKey key = Message.MessageKey.of("foo", 1l);
- LocalDateTime timestamp = LocalDateTime.now();
- Message existing = new Message(key, 0l, timestamp, "Existing");
- when(chatRoom.addMessage(any(Long.class), any(String.class), any(String.class)))
- .thenReturn(Mono.error(() -> new MessageMutationException(existing, "Mutated!")));
+ Message.MessageKey key = Message.MessageKey.of(user, messageId);
+ Long serialNumberExistingMessage = 0l;
+ String timeExistingMessageAsString = "2023-01-09T20:44:57.389665447";
+ LocalDateTime timeExistingMessage = LocalDateTime.parse(timeExistingMessageAsString);
+ String textExistingMessage = "Existing";
+ String textMutatedMessage = "Mutated!";
+ ChatRoom chatRoom = new ChatRoom(
+ chatroomId,
+ "Test-ChatRoom",
+ Clock.systemDefaultZone(),
+ chatRoomService, 8);
+ when(chatHomeService.getChatRoom(any(UUID.class))).thenReturn(Mono.just(chatRoom));
+ Message existingMessage = new Message(
+ key,
+ serialNumberExistingMessage,
+ timeExistingMessage,
+ textExistingMessage);
+ when(chatRoomService.getMessage(any(Message.MessageKey.class)))
+ .thenReturn(Mono.just(existingMessage));
+ // Needed for readable error-reports, in case of a bug that leads to according unwanted call
+ when(chatRoomService.persistMessage(any(Message.MessageKey.class), any(LocalDateTime.class), any(String.class)))
+ .thenReturn(mock(Message.class));