1717import org .junit .jupiter .api .Test ;
1818import org .springframework .beans .factory .annotation .Autowired ;
1919import org .springframework .boot .test .context .SpringBootTest ;
20- import org .springframework .data .domain .PageRequest ;
2120import org .springframework .transaction .annotation .Transactional ;
2221
2322import javax .persistence .EntityManager ;
@@ -139,7 +138,6 @@ void setUp() {
139138 @ Test
140139 @ Transactional
141140 void testQueryDsl () {
142- // Querydsl test
143141 final JPAQueryFactory query = new JPAQueryFactory (entityManager );
144142 final List <FollowingPostDto > posts = query
145143 .select (new QFollowingPostDto (
@@ -154,7 +152,7 @@ void testQueryDsl() {
154152 post .imageUrl .as ("imageUrl" ),
155153 post .fileUrl .as ("fileUrl" ),
156154 post .selectedDate ,
157- post .updatedAt .as ("updatedAt " )
155+ post .createdAt .as ("createdAt " )
158156 ))
159157 .from (post )
160158 .leftJoin (follow ).on (follow .user .userId .eq (userId1 ))
@@ -172,19 +170,6 @@ void testQueryDsl() {
172170 () -> assertThat (posts .get (2 ).getContent (), is ("content1" )),
173171 () -> assertThat (posts .get (2 ).getUserId (), is (userId2 ))
174172 );
175-
176- // JpaRepository에 Querydsl 적용 test
177- final List <FollowingPostDto > findByJpaRepo = postRepository .findFollowingPosts (userId1 , PageRequest .of (0 , 10 ));
178-
179- assertAll ("follow한 사용자의 모든 posts in repository" ,
180- () -> assertThat (findByJpaRepo .size (), is (3 )),
181- () -> assertThat (findByJpaRepo .get (0 ).getContent (), is ("content3" )),
182- () -> assertThat (findByJpaRepo .get (0 ).getUserId (), is (userId2 )),
183- () -> assertThat (findByJpaRepo .get (1 ).getContent (), is ("content2" )),
184- () -> assertThat (findByJpaRepo .get (1 ).getUserId (), is (userId3 )),
185- () -> assertThat (findByJpaRepo .get (2 ).getContent (), is ("content1" )),
186- () -> assertThat (findByJpaRepo .get (2 ).getUserId (), is (userId2 ))
187- );
188173 }
189174
190175}
0 commit comments