-
Notifications
You must be signed in to change notification settings - Fork 1
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
b459fcd
commit 6042344
Showing
6 changed files
with
135 additions
and
11 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
6 changes: 5 additions & 1 deletion
6
...c/main/java/org/nexters/jaknaesocore/domain/survey/repository/SurveyBundleRepository.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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
package org.nexters.jaknaesocore.domain.survey.repository; | ||
|
||
import java.util.Optional; | ||
import org.nexters.jaknaesocore.domain.survey.model.SurveyBundle; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface SurveyBundleRepository extends JpaRepository<SurveyBundle, Long> {} | ||
public interface SurveyBundleRepository extends JpaRepository<SurveyBundle, Long> { | ||
|
||
Optional<SurveyBundle> findFirstByIdGreaterThanOrderByIdAsc(final Long id); | ||
} |
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
57 changes: 57 additions & 0 deletions
57
...st/java/org/nexters/jaknaesocore/domain/survey/repository/SurveyBundleRepositoryTest.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,57 @@ | ||
package org.nexters.jaknaesocore.domain.survey.repository; | ||
|
||
import static org.assertj.core.api.BDDAssertions.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.nexters.jaknaesocore.common.support.IntegrationTest; | ||
import org.nexters.jaknaesocore.domain.survey.model.SurveyBundle; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
class SurveyBundleRepositoryTest extends IntegrationTest { | ||
|
||
@Autowired private SurveyBundleRepository surveyBundleRepository; | ||
|
||
@AfterEach | ||
void tearDown() { | ||
surveyBundleRepository.deleteAllInBatch(); | ||
} | ||
|
||
@Test | ||
void 주어진_ID_보다_큰_번들_중_가장_작은_ID를_가진_번들을_찾는다() { | ||
// given | ||
SurveyBundle surveyBundle1 = new SurveyBundle(); | ||
SurveyBundle surveyBundle2 = new SurveyBundle(); | ||
SurveyBundle surveyBundle3 = new SurveyBundle(); | ||
SurveyBundle surveyBundle4 = new SurveyBundle(); | ||
|
||
surveyBundleRepository.saveAll( | ||
List.of(surveyBundle1, surveyBundle2, surveyBundle3, surveyBundle4)); | ||
// when | ||
Optional<SurveyBundle> result = | ||
surveyBundleRepository.findFirstByIdGreaterThanOrderByIdAsc(surveyBundle2.getId()); | ||
// then | ||
then(result) | ||
.hasValueSatisfying( | ||
surveyBundle -> then(surveyBundle.getId()).isEqualTo(surveyBundle3.getId())); | ||
} | ||
|
||
@Test | ||
void 주어진_ID보다_큰_번들이_없으면_빈_값을_반환한다() { | ||
// given | ||
SurveyBundle surveyBundle1 = new SurveyBundle(); | ||
SurveyBundle surveyBundle2 = new SurveyBundle(); | ||
SurveyBundle surveyBundle3 = new SurveyBundle(); | ||
SurveyBundle surveyBundle4 = new SurveyBundle(); | ||
|
||
surveyBundleRepository.saveAll( | ||
List.of(surveyBundle1, surveyBundle2, surveyBundle3, surveyBundle4)); | ||
// when | ||
Optional<SurveyBundle> result = surveyBundleRepository.findFirstByIdGreaterThanOrderByIdAsc(4L); | ||
// then | ||
then(result).isEmpty(); | ||
} | ||
} |
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