5ef12efeb729498c6d78959386ca095e8f20b0b2
[demos/kafka/chat] /
1 package de.juplo.kafka.chat.backend.persistence.kafka.messages;
2
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.fasterxml.jackson.databind.SerializationFeature;
5 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
6 import org.junit.jupiter.api.BeforeEach;
7 import org.junit.jupiter.api.Test;
8
9 import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
10
11
12 public class CommandCreateChatRoomToTest
13 {
14   final String json = """
15   {
16     "name": "Foo-Room!"
17   }""";
18
19   ObjectMapper mapper;
20
21   @BeforeEach
22   public void setUp()
23   {
24     mapper = new ObjectMapper();
25     mapper.registerModule(new JavaTimeModule());
26     mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
27   }
28
29   @Test
30   public void testDeserialization() throws Exception
31   {
32     CommandCreateChatRoomTo message = mapper.readValue(json, CommandCreateChatRoomTo.class);
33     assertThat(message.getName()).isEqualTo("Foo-Room!");
34   }
35 }