-
Notifications
You must be signed in to change notification settings - Fork 53.6k
Expand file tree
/
Copy pathTransactionRoutingIntegrationTest.java
More file actions
38 lines (27 loc) · 1.06 KB
/
TransactionRoutingIntegrationTest.java
File metadata and controls
38 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.baeldung.rwrouting;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@ActiveProfiles("rwrouting")
@SpringBootTest(classes = RwRoutingApplication.class)
class TransactionRoutingIntegrationTest {
@Autowired
OrderService orderService;
@Test
void whenSaveAndReadWithReadWrite_thenFindsOrder() {
Order saved = orderService.save(new Order("laptop"));
List<Order> result = orderService.findAllReadWrite();
assertThat(result).anyMatch(o -> o.getId()
.equals(saved.getId()));
}
@Test
void whenSaveAndReadWithReadOnly_thenOrderNotFound() {
Order saved = orderService.save(new Order("keyboard"));
List<Order> result = orderService.findAllReadOnly();
assertThat(result).noneMatch(o -> o.getId()
.equals(saved.getId()));
}
}