-
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.
Browse files
Browse the repository at this point in the history
[FEAT/#297] 배너 목록 조회 기능 구현
- Loading branch information
Showing
12 changed files
with
299 additions
and
17 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
57 changes: 57 additions & 0 deletions
57
operation-api/src/main/resources/data/insert-get-banners-data.sql
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 @@ | ||
CREATE TABLE if not exists banners ( | ||
id bigserial not null, | ||
created_date timestamp(6), | ||
last_modified_date timestamp(6), | ||
content_type varchar(255) not null, | ||
img_url_mobile varchar(255) not null, | ||
img_url_pc varchar(255) not null, | ||
link varchar(255), | ||
location varchar(255) not null, | ||
end_date date not null, | ||
start_date date not null, | ||
publisher varchar(255) not null, | ||
primary key (id) | ||
); | ||
|
||
DELETE FROM banners; | ||
|
||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2031-06-10', '2031-06-17','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2031-06-01', '2031-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2031-01-01', '2031-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2030-01-01', '2030-12-31','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2030-01-01', '2030-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2030-01-01', '2030-12-31','user'); | ||
|
||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2024-12-01', '2024-12-31','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2024-12-01', '2025-12-01','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2024-01-01', '2025-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2024-06-30', '2025-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2024-06-30', '2025-01-01','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2024-01-01', '2025-01-01','user'); | ||
|
||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2011-06-10', '2011-06-17','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2011-06-01', '2011-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2011-01-01', '2011-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2010-01-01', '2011-12-31','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2010-01-01', '2010-06-30','user'); | ||
INSERT INTO banners (content_type, img_url_mobile, img_url_pc, location, start_date, end_date, publisher) | ||
VALUES ('PRODUCT', '','','PLAYGROUND_COMMUNITY','2010-01-01', '2010-12-31','user'); | ||
|
||
|
77 changes: 77 additions & 0 deletions
77
...ion-api/src/test/java/org/sopt/makers/operation/web/banner/service/BannerServiceTest.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,77 @@ | ||
package org.sopt.makers.operation.web.banner.service; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.sopt.makers.operation.banner.domain.PublishPeriod; | ||
import org.sopt.makers.operation.banner.domain.PublishStatus; | ||
import org.sopt.makers.operation.banner.repository.BannerRepository; | ||
import org.sopt.makers.operation.client.s3.S3Service; | ||
import org.sopt.makers.operation.config.ValueConfig; | ||
import org.sopt.makers.operation.web.banner.dto.response.BannerResponse; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.jdbc.Sql; | ||
|
||
import java.time.LocalDate; | ||
import java.time.Clock; | ||
import java.time.Instant; | ||
import java.time.ZoneId; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.sopt.makers.operation.web.banner.service.BannerService.*; | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("test") | ||
@Sql(scripts = "classpath:data/insert-get-banners-data.sql") | ||
class BannerServiceTest { | ||
private static final Clock TEST_CLOCK = Clock.fixed(Instant.parse("2024-12-28T00:00:00Z"), ZoneId.systemDefault()); | ||
@Autowired | ||
private BannerRepository bannerRepository; | ||
@MockBean | ||
private S3Service s3Service; | ||
@Autowired | ||
private ValueConfig valueConfig; | ||
|
||
private BannerService bannerService; | ||
|
||
@BeforeEach | ||
void setBannerService() { | ||
bannerService = new BannerServiceImpl(bannerRepository, s3Service, valueConfig, TEST_CLOCK); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("argsForGetBanners") | ||
void getBanners( | ||
FilterCriteria givenFilter, | ||
SortCriteria givenSort, | ||
int expectedSize, | ||
PublishStatus expectedStatus | ||
) { | ||
List<BannerResponse.BannerSimple> banners = bannerService.getBanners(givenFilter, givenSort); | ||
|
||
assertThat(banners) | ||
.hasSize(expectedSize) | ||
.extracting(info -> PublishPeriod.builder().startDate(info.startDate()).endDate(info.endDate()).build()) | ||
.allMatch(period -> { | ||
if (givenFilter.equals(FilterCriteria.ALL)) { | ||
return true; | ||
} | ||
return period.getPublishStatus(LocalDate.now(TEST_CLOCK)).equals(expectedStatus); | ||
}); | ||
} | ||
static Stream<Arguments> argsForGetBanners(){ | ||
return Stream.of( | ||
Arguments.of(FilterCriteria.RESERVED, SortCriteria.START_DATE, 6, PublishStatus.RESERVED), | ||
Arguments.of(FilterCriteria.ALL, SortCriteria.START_DATE, 18, null), | ||
Arguments.of(FilterCriteria.IN_PROGRESS, SortCriteria.START_DATE, 6, PublishStatus.IN_PROGRESS), | ||
Arguments.of(FilterCriteria.DONE, SortCriteria.START_DATE, 6, PublishStatus.DONE) | ||
); | ||
} | ||
|
||
} |
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
Oops, something went wrong.