File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
3-1-3-author-book/src/test/java/com/bobocode
3-2-2-photo-comment-dao/src/test/java/com/bobocode Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 5
5
import com .bobocode .util .EntityManagerUtil ;
6
6
import org .apache .commons .lang3 .RandomStringUtils ;
7
7
import org .hibernate .Session ;
8
+ import org .hibernate .exception .ConstraintViolationException ;
8
9
import org .junit .jupiter .api .*;
9
10
10
11
import jakarta .persistence .*;
15
16
import java .util .stream .Collectors ;
16
17
import java .util .stream .Stream ;
17
18
19
+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
18
20
import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
19
21
import static org .assertj .core .api .AssertionsForClassTypes .assertThatExceptionOfType ;
20
22
import static org .assertj .core .api .AssertionsForInterfaceTypes .assertThat ;
@@ -66,8 +68,8 @@ void saveBookWithDuplicateIsbn() {
66
68
Book bookWithDuplicateIsbn = createRandomBook ();
67
69
bookWithDuplicateIsbn .setIsbn (book .getIsbn ());
68
70
69
- assertThatExceptionOfType ( RollbackException . class ). isThrownBy (() ->
70
- emUtil . performWithinTx ( entityManager -> entityManager . persist ( bookWithDuplicateIsbn )) );
71
+ assertThatThrownBy (() -> emUtil . performWithinTx ( entityManager -> entityManager . persist ( bookWithDuplicateIsbn )))
72
+ . isInstanceOfAny ( RollbackException . class , ConstraintViolationException . class );
71
73
}
72
74
73
75
@ Test
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ void saveNewComments() {
234
234
235
235
@ Test
236
236
@ Order (16 )
237
- @ DisplayName ("Add a new comment " )
237
+ @ DisplayName ("Add new comments " )
238
238
void addNewComments () {
239
239
Photo photo = createRandomPhoto ();
240
240
emUtil .performWithinTx (entityManager -> entityManager .persist (photo ));
You can’t perform that action at this time.
0 commit comments