55
66import com .wooteco .wiki .global .exception .ErrorCode ;
77import com .wooteco .wiki .global .exception .WikiException ;
8+ import com .wooteco .wiki .history .domain .History ;
9+ import com .wooteco .wiki .history .repository .HistoryRepository ;
810import com .wooteco .wiki .organizationdocument .domain .OrganizationDocument ;
911import com .wooteco .wiki .organizationdocument .dto .request .OrganizationDocumentCreateRequest ;
1012import com .wooteco .wiki .organizationdocument .dto .request .OrganizationDocumentUpdateRequest ;
1416import com .wooteco .wiki .organizationevent .domain .OrganizationEvent ;
1517import com .wooteco .wiki .organizationevent .fixture .OrganizationEventFixture ;
1618import com .wooteco .wiki .organizationevent .repository .OrganizationEventRepository ;
19+ import java .util .List ;
1720import java .util .UUID ;
1821import org .assertj .core .api .Assertions ;
1922import org .junit .jupiter .api .DisplayName ;
2023import org .junit .jupiter .api .Nested ;
2124import org .junit .jupiter .api .Test ;
2225import org .springframework .beans .factory .annotation .Autowired ;
2326import org .springframework .boot .test .context .SpringBootTest ;
27+ import org .springframework .data .domain .Page ;
28+ import org .springframework .data .domain .Pageable ;
2429import org .springframework .test .annotation .DirtiesContext ;
2530
2631@ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .NONE )
@@ -36,6 +41,9 @@ class OrganizationCrewDocumentServiceTest {
3641 @ Autowired
3742 private OrganizationEventRepository organizationEventRepository ;
3843
44+ @ Autowired
45+ private HistoryRepository historyRepository ;
46+
3947 @ DisplayName ("조직 문서를 수정할 때" )
4048 @ Nested
4149 class Update {
@@ -61,11 +69,20 @@ void updateOrganizationDocument_success_byValidData() {
6169 organizationDocument .getUuid ()).orElseThrow ();
6270
6371 // then
72+ Page <History > histories = historyRepository .findAllByDocumentId (organizationDocument .getId (), Pageable .ofSize (1 ));
73+
6474 assertSoftly (softly -> {
6575 softly .assertThat (foundOrganizationDocument .getTitle ()).isEqualTo (updateTitle );
6676 softly .assertThat (foundOrganizationDocument .getContents ()).isEqualTo (updateContents );
6777 softly .assertThat (foundOrganizationDocument .getWriter ()).isEqualTo (updateWriter );
6878 softly .assertThat (foundOrganizationDocument .getDocumentBytes ()).isEqualTo (updateDocumentBytes );
79+ softly .assertThat (histories .hasContent ()).isTrue ();
80+
81+ History first = histories .getContent ().get (0 );
82+ softly .assertThat (first .getTitle ()).isEqualTo (updateTitle );
83+ softly .assertThat (first .getContents ()).isEqualTo (updateContents );
84+ softly .assertThat (first .getWriter ()).isEqualTo (updateWriter );
85+ softly .assertThat (first .getDocumentBytes ()).isEqualTo (updateDocumentBytes );
6986 });
7087 }
7188 }
0 commit comments