-
Notifications
You must be signed in to change notification settings - Fork 8
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
* fix: 중복으로 실행되는 Mock Data 설정 수정 - MockScheduler initialDelay 추가 - CommandLineAppStartupRunner MockScheduler 의존 제거 * refactor: Mock 아티스트, 학교 생성 로직 분리 * test: 테스트 코드 개선 - 일부 테스트 로직 간결하게 변경 - 트랜잭션 제거 * feat: 도메인 엔티티를 반환하는 MockGenerator 구현 * refactor: Mock 생성 로직 MockGenerator를 사용하도록 리팩터링 * refactor: 패키지 위치 정리, MockDataServiceIntegrationTest 검증 로직 정리 * refactor: 사용하지 않는 클래스 제거 * refactor: 어플리케이션 실행마다 축제 생성 방지 * refactor: 클래스, 메서드 명 명확하게 변경 * fix: 스케줄러 TimeUnit 수정 * feat: MockDataStartupInitializer 트랜잭션 적용하여 원자성 보장 * chore: 메서드명 수정 * chore: 학교 이름 뒤 추가하는 인덱스 제거 * refactor: 축제 생성 시 이름 "테코대학교 20770630 축제" 와 같은 포맷으로 변경 * test: given-when-then 잘못된 위치 수정 * chore: MockStageArtistsGenerator Javadoc 추가 * feat: MockFestivalDurationGenerator 추가 * refactor: 비즈니스 로직에 사용되는 변수 도메인으로 이동 및 MockFestivalDurationGenerator 사용하도록 변경 * feat: StageArtist notNull 검증 추가 - stageId, artistId
- Loading branch information
1 parent
7a9ada4
commit 4f6db52
Showing
27 changed files
with
695 additions
and
650 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
backend/src/main/java/com/festago/festival/domain/FestivalDuration.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,47 @@ | ||
package com.festago.festival.domain; | ||
|
||
import com.festago.common.exception.BadRequestException; | ||
import com.festago.common.exception.ErrorCode; | ||
import com.festago.common.util.Validator; | ||
import jakarta.persistence.Embeddable; | ||
import java.time.LocalDate; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Embeddable | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class FestivalDuration { | ||
|
||
private LocalDate startDate; | ||
private LocalDate endDate; | ||
|
||
public FestivalDuration(LocalDate startDate, LocalDate endDate) { | ||
validate(startDate, endDate); | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
} | ||
|
||
private void validate(LocalDate startDate, LocalDate endDate) { | ||
Validator.notNull(startDate, "startDate"); | ||
Validator.notNull(endDate, "endDate"); | ||
if (startDate.isAfter(endDate)) { | ||
throw new BadRequestException(ErrorCode.INVALID_FESTIVAL_DURATION); | ||
} | ||
} | ||
|
||
public boolean isBeforeStartDate(LocalDate date) { | ||
return startDate.isBefore(date); | ||
} | ||
|
||
public boolean isNotInDuration(LocalDate date) { | ||
return date.isBefore(startDate) || date.isAfter(endDate); | ||
} | ||
|
||
public LocalDate getStartDate() { | ||
return startDate; | ||
} | ||
|
||
public LocalDate getEndDate() { | ||
return endDate; | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
backend/src/main/java/com/festago/mock/CommandLineAppStartupRunner.java
This file was deleted.
Oops, something went wrong.
13 changes: 7 additions & 6 deletions
13
.../java/com/festago/mock/MockScheduler.java → ...estago/mock/MockDataInitialScheduler.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,21 +1,22 @@ | ||
package com.festago.mock; | ||
|
||
import com.festago.mock.application.MockDataService; | ||
import java.util.concurrent.TimeUnit; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Profile("dev") | ||
@Profile({"dev"}) | ||
@Component | ||
@RequiredArgsConstructor | ||
public class MockScheduler { | ||
public class MockDataInitialScheduler { | ||
|
||
private static final long SCHEDULER_CYCLE = 7; | ||
private static final long DAYS_OF_WEEK = 7L; | ||
private final MockDataService mockDataService; | ||
|
||
@Scheduled(fixedDelay = SCHEDULER_CYCLE, timeUnit = TimeUnit.DAYS) | ||
public void run() { | ||
mockDataService.makeMockFestivals((int) SCHEDULER_CYCLE); | ||
@Scheduled(initialDelay = DAYS_OF_WEEK, fixedDelay = DAYS_OF_WEEK, timeUnit = TimeUnit.DAYS) | ||
public void createMockFestivals() { | ||
mockDataService.makeMockFestivals(); | ||
} | ||
} |
216 changes: 0 additions & 216 deletions
216
backend/src/main/java/com/festago/mock/MockDataService.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
backend/src/main/java/com/festago/mock/MockDataStartupInitializer.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,29 @@ | ||
package com.festago.mock; | ||
|
||
import com.festago.mock.application.MockDataService; | ||
import com.festago.mock.repository.ForMockSchoolRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Profile({"dev"}) | ||
@Component | ||
@RequiredArgsConstructor | ||
public class MockDataStartupInitializer { | ||
|
||
private final ForMockSchoolRepository forMockSchoolRepository; | ||
private final MockDataService mockDataService; | ||
|
||
@Transactional | ||
@EventListener(ApplicationReadyEvent.class) | ||
public void initialize() { | ||
if (forMockSchoolRepository.count() == 0) { | ||
mockDataService.makeMockArtists(); | ||
mockDataService.makeMockSchools(); | ||
mockDataService.makeMockFestivals(); | ||
} | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
backend/src/main/java/com/festago/mock/MockFestivalDateGenerator.java
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
backend/src/main/java/com/festago/mock/RandomMockFestivalDateGenerator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.