-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
280fd5b
commit 3d900f1
Showing
6 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
backend/src/test/java/wooteco/prolog/session/domain/repository/SessionRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package wooteco.prolog.session.domain.repository; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.google.common.collect.Lists; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import wooteco.prolog.session.domain.Session; | ||
import wooteco.support.utils.RepositoryTest; | ||
|
||
@RepositoryTest | ||
class SessionRepositoryTest { | ||
|
||
@Autowired | ||
private SessionRepository sessionRepository; | ||
|
||
@Test | ||
void findAllOrderByIdDesc() { | ||
sessionRepository.save(new Session("name1")); | ||
sessionRepository.save(new Session("name2")); | ||
|
||
List<Session> sessions = sessionRepository.findAllByOrderByIdDesc(); | ||
|
||
assertThat(sessions.get(0).getName()).isEqualTo("name2"); | ||
assertThat(sessions.get(1).getName()).isEqualTo("name1"); | ||
} | ||
|
||
@Test | ||
void findAllByIdInOrderByIdDesc() { | ||
Session session1 = sessionRepository.save(new Session("name1")); | ||
Session session2 = sessionRepository.save(new Session("name2")); | ||
Session session3 = sessionRepository.save(new Session("name3")); | ||
Session session4 = sessionRepository.save(new Session("name4")); | ||
|
||
List<Session> sessions = sessionRepository.findAllByIdInOrderByIdDesc( | ||
Lists.newArrayList(session4.getId(), session2.getId())); | ||
|
||
assertThat(sessions.get(0).getName()).isEqualTo("name4"); | ||
assertThat(sessions.get(1).getName()).isEqualTo("name2"); | ||
} | ||
} |