From 5e92d558090c87ae3e1fdea0afee6c291fd50cb5 Mon Sep 17 00:00:00 2001 From: Seung-Wan Jeong Date: Fri, 10 Jun 2022 01:01:22 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20ParametrizedTest=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20(ios-h/airbnb#39)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccommodationRepositoryTest.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/BE/src/test/java/org/team4/airbnb/accommodation/AccommodationRepositoryTest.java b/BE/src/test/java/org/team4/airbnb/accommodation/AccommodationRepositoryTest.java index 70e35b09a..74ac238be 100644 --- a/BE/src/test/java/org/team4/airbnb/accommodation/AccommodationRepositoryTest.java +++ b/BE/src/test/java/org/team4/airbnb/accommodation/AccommodationRepositoryTest.java @@ -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; @@ -21,21 +27,27 @@ @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) class AccommodationRepositoryTest { - private static final Set 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 sampleIds) { List 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 provideSampleIds() { + return Stream.of( + Arguments.of(Set.of(3L, 4L, 5L)), + Arguments.of(Set.of(1L, 5L, 8L, 10L)) + ); } }