Skip to content

Commit e552efc

Browse files
author
Guilherme Biff Zarelli
committed
Merge remote-tracking branch 'origin/main' into main
2 parents 97034f2 + ea75433 commit e552efc

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

adapter/output/jpa-mysql-repository/pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@
4343
<groupId>${project.groupId}</groupId>
4444
<artifactId>use-case</artifactId>
4545
</dependency>
46+
<dependency>
47+
<groupId>org.junit.jupiter</groupId>
48+
<artifactId>junit-jupiter-api</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-engine</artifactId>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.mockito</groupId>
58+
<artifactId>mockito-core</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.mockito</groupId>
63+
<artifactId>mockito-junit-jupiter</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.assertj</groupId>
68+
<artifactId>assertj-core</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.slf4j</groupId>
73+
<artifactId>slf4j-simple</artifactId>
74+
<scope>test</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.glassfish.jersey.core</groupId>
78+
<artifactId>jersey-common</artifactId>
79+
<scope>test</scope>
80+
</dependency>
4681
</dependencies>
4782

4883
</project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package br.com.helpdev.output.repository.mapper;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import br.com.helpdev.domain.CommunicationChannel;
6+
import br.com.helpdev.domain.Message;
7+
import br.com.helpdev.domain.Recipient;
8+
import br.com.helpdev.domain.vo.MessageBody;
9+
import br.com.helpdev.domain.vo.MessageId;
10+
import br.com.helpdev.domain.vo.Phone;
11+
import br.com.helpdev.output.repository.entity.CommunicationChannelEntity;
12+
import br.com.helpdev.output.repository.entity.MessageEntity;
13+
import br.com.helpdev.output.repository.entity.RecipientEntity;
14+
import org.junit.jupiter.api.Test;
15+
16+
class MessageMapperTest {
17+
18+
private final MessageMapper messageMapper = new MessageMapper();
19+
20+
@Test
21+
void whenDomainHasIdThenMap() {
22+
var message = messageMapper.toDomain(entityBuilder().id(1L).build());
23+
assertThat(message.getId()).get().isEqualTo(MessageId.from(1L));
24+
}
25+
26+
@Test
27+
void whenEntityHasIdThenMap() {
28+
var message = messageMapper.toEntity(domainBuilder().id(MessageId.from(1L)).build());
29+
assertThat(message.getId()).isEqualTo(1L);
30+
}
31+
32+
private MessageEntity.MessageEntityBuilder entityBuilder() {
33+
return MessageEntity.builder()
34+
.channel(CommunicationChannelEntity.EMAIL)
35+
.recipient(RecipientEntity.builder()
36+
.phoneNumber("78924")
37+
.build())
38+
.body("Test");
39+
}
40+
41+
private Message.MessageBuilder domainBuilder() {
42+
return Message.builder()
43+
.channel(CommunicationChannel.WHATSAPP)
44+
.recipient(Recipient.builder()
45+
.phone(Phone.from("78924", "1243243"))
46+
.build())
47+
.body(MessageBody.from("Hello!"));
48+
}
49+
50+
}

0 commit comments

Comments
 (0)