Skip to content

Commit

Permalink
refactor: ParametrizedTest 적용 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
astraum committed Jun 9, 2022
1 parent 4227aac commit 5e92d55
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -21,21 +27,27 @@
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class AccommodationRepositoryTest {

private static final Set<Long> SAMPLE_IDS = Set.of(3L, 4L, 5L);

@Autowired
AccommodationRepository accommodationRepository;

Logger logger = LoggerFactory.getLogger(AccommodationRepositoryTest.class);

@Test
@ParameterizedTest
@MethodSource("provideSampleIds")
@DisplayName("숙소 Id 목록으로 사진이 포함된 숙소 목록 검색")
void findAllWithImagesById() {
void findAllWithImagesById(Set<Long> sampleIds) {
List<Accommodation> accommodations = accommodationRepository
.findAllWithImagesByIdIn(SAMPLE_IDS);
.findAllWithImagesByIdIn(sampleIds);

accommodations.forEach(a -> logger.info(a.toString()));

assertThat(accommodations).hasSize(SAMPLE_IDS.size());
assertThat(accommodations).hasSize(sampleIds.size());
}

private static Stream<Arguments> provideSampleIds() {
return Stream.of(
Arguments.of(Set.of(3L, 4L, 5L)),
Arguments.of(Set.of(1L, 5L, 8L, 10L))
);
}
}

0 comments on commit 5e92d55

Please sign in to comment.