1 package de.juplo.kafka.chat.backend.domain;
3 import org.junit.jupiter.api.DisplayName;
4 import org.junit.jupiter.api.Test;
5 import org.junit.jupiter.api.extension.ExtendWith;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.test.context.junit.jupiter.SpringExtension;
8 import reactor.core.publisher.Mono;
10 import java.util.UUID;
12 import static pl.rzrz.assertj.reactor.Assertions.assertThat;
15 @ExtendWith(SpringExtension.class)
16 public class ChatHomeTestBase
23 @DisplayName("Assert chatroom is delivered, if it exists")
24 void testGetExistingChatroom()
27 UUID chatRoomId = UUID.fromString("5c73531c-6fc4-426c-adcb-afc5c140a0f7");
30 Mono<ChatRoom> mono = chatHome.getChatRoom(chatRoomId);
33 assertThat(mono).emitsCount(1);
37 @DisplayName("Assert UnknownChatroomException is thrown, if chatroom does not exist")
38 void testGetNonExistentChatroom()
41 UUID chatRoomId = UUID.fromString("7f59ec77-832e-4a17-8d22-55ef46242c17");
44 Mono<ChatRoom> mono = chatHome.getChatRoom(chatRoomId);
47 assertThat(mono).sendsError(e ->
49 assertThat(e).isInstanceOf(UnknownChatroomException.class);
50 UnknownChatroomException unknownChatroomException = (UnknownChatroomException) e;
51 assertThat(unknownChatroomException.getChatroomId()).isEqualTo(chatRoomId);