1 package de.juplo.kafka.chat.backend.domain;
3 import org.junit.jupiter.api.DisplayName;
4 import org.junit.jupiter.api.Test;
5 import reactor.core.publisher.Mono;
6 import reactor.util.retry.Retry;
8 import java.time.Duration;
11 import static pl.rzrz.assertj.reactor.Assertions.assertThat;
14 public abstract class ChatHomeWithShardsTest extends ChatHomeTest
16 public static final int NUM_SHARDS = 10;
17 public static final int OWNED_SHARD = 2;
18 public static final int NOT_OWNED_SHARD = 0;
22 @DisplayName("Assert ShardNotOwnedException is thrown, if the shard for the chatroom is not owned")
23 void testGetChatroomForNotOwnedShard()
26 UUID chatRoomId = UUID.fromString("4e7246a6-29ae-43ea-b56f-669c3481ac19");
29 Mono<ChatRoomData> mono = Mono
30 .defer(() -> chatHome.getChatRoomData(chatRoomId))
31 .log("testGetChatroomForNotOwnedShard")
33 .backoff(5, Duration.ofSeconds(1))
34 .filter(throwable -> throwable instanceof LoadInProgressException));
37 assertThat(mono).sendsError(e ->
39 assertThat(e).isInstanceOf(ShardNotOwnedException.class);
40 ShardNotOwnedException shardNotOwnedException = (ShardNotOwnedException) e;
41 assertThat(shardNotOwnedException.getShard()).isEqualTo(NOT_OWNED_SHARD);