Skip to content

Commit

Permalink
Test: Calendar, Schedule, Scheduleinfo Fixture 생성
Browse files Browse the repository at this point in the history
Resolves: #38
  • Loading branch information
jiwon83 committed Nov 9, 2024
1 parent 42ec4e4 commit 85a1f70
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.wypl.wyplcore;

import com.wypl.jpacalendardomain.calendar.domain.Calendar;

import lombok.Getter;

@Getter
public enum CalendarFixture {

PRIVATE_CALENDAR("개인 달력", "개인 달력입니다.", 1L, false),
GROUP_CALENDAR1("와플 그룹 달력", "와플 화이팅", 2L, true),
GROUP_CALENDAR2("CS 스터디 그룹 달력", "CS 재밋다!", 3L, true);

private final String name;
private final String description;
private final Long ownerId;
private final Boolean isShared;

CalendarFixture(String name, String description, Long ownerId, Boolean isShared) {
this.name = name;
this.description = description;
this.ownerId = ownerId;
this.isShared = isShared;
}

public Calendar toEntity() {
return Calendar.builder()
.name(this.name)
.description(this.description)
.ownerId(this.ownerId)
.isShared(this.isShared)
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.wypl.wyplcore;

import java.time.LocalDate;
import java.time.LocalDateTime;
import com.wypl.jpacalendardomain.calendar.data.RepetitionCycle;
import com.wypl.jpacalendardomain.calendar.domain.Schedule;
import com.wypl.jpacalendardomain.calendar.domain.ScheduleInfo;


import lombok.Getter;

@Getter
public enum ScheduleFixture {

DAILY_SCHEDULE(
"일일 일정",
"매일 반복되는 일정입니다.",
LocalDateTime.of(2024, 10, 20, 9, 0),
LocalDateTime.of(2024, 10, 20, 10, 0),
LocalDate.of(2024, 10, 20),
LocalDate.of(2024, 12, 31),
RepetitionCycle.DAY,
null,
null
),
WEEKLY_SCHEDULE(
"주간 일정",
"매주 월,수,금에 반복되는 일정입니다.",
LocalDateTime.of(2024, 10, 20, 14, 0),
LocalDateTime.of(2024, 10, 20, 15, 0),
LocalDate.of(2024, 10, 20),
LocalDate.of(2025, 1, 1),
RepetitionCycle.WEEK,
((1 << 1) | (1 << 3) | (1 << 5)), // 월, 수, 금 반복
1 // 매주 반복
),
WEEKLY_SCHEDULE_WITHOUT_DAY_OF_WEEK(
"2주 마다 반복되는 일정",
"2주 마다 반복되는 일정입니다.",
LocalDateTime.of(2024, 10, 20, 14, 0),
LocalDateTime.of(2024, 10, 21, 14, 0),
LocalDate.of(2024, 10, 20),
LocalDate.of(2025, 1, 1),
RepetitionCycle.WEEK,
null, // 월, 수, 금 반복
2 // 매주 반복
),
MONTHLY_SCHEDULE(
"월간 일정",
"매달 첫째 주 화요일에 반복되는 일정입니다.",
LocalDateTime.of(2024, 10, 20, 10, 0),
LocalDateTime.of(2024, 10, 20, 11, 0),
LocalDate.of(2024, 10, 20),
LocalDate.of(2025, 2, 1),
RepetitionCycle.MONTH,
2, // 화요일
1 // 매월 반복
);

private final String title;
private final String description;
private final LocalDateTime startDateTime;
private final LocalDateTime endDateTime;
private final LocalDate repetitionStartDate;
private final LocalDate repetitionEndDate;
private final RepetitionCycle repetitionCycle;
private final Integer dayOfWeek;
private final Integer weekInterval;

ScheduleFixture(String title, String description, LocalDateTime startDateTime, LocalDateTime endDateTime,
LocalDate repetitionStartDate, LocalDate repetitionEndDate, RepetitionCycle repetitionCycle,
Integer dayOfWeek, Integer weekInterval) {
this.title = title;
this.description = description;
this.startDateTime = startDateTime;
this.endDateTime = endDateTime;
this.repetitionStartDate = repetitionStartDate;
this.repetitionEndDate = repetitionEndDate;
this.repetitionCycle = repetitionCycle;
this.dayOfWeek = dayOfWeek;
this.weekInterval = weekInterval;
}

public Schedule toEntity(ScheduleInfo scheduleInfo) {
return Schedule.builder()
.scheduleInfo(scheduleInfo)
.title(this.title)
.description(this.description)
.startDateTime(this.startDateTime)
.endDateTime(this.endDateTime)
.repetitionStartDate(this.repetitionStartDate)
.repetitionEndDate(this.repetitionEndDate)
.repetitionCycle(this.repetitionCycle)
.dayOfWeek(this.dayOfWeek)
.weekInterval(this.weekInterval)
.build();
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.wypl.wyplcore;

import java.util.Collections;

import com.wypl.jpacalendardomain.calendar.domain.Calendar;
import com.wypl.jpacalendardomain.calendar.domain.ScheduleInfo;

import lombok.Getter;

@Getter
public enum ScheduleInfoFixture {

PRIVATE_SCHEDULE_INFO(1L),
GROUP_SCHEDULE_INFO_1(2L),
GROUP_SCHEDULE_INFO_2( 3L);

private final Long creatorId;

ScheduleInfoFixture(Long creatorId) {
this.creatorId = creatorId;
}

public ScheduleInfo toEntity(Calendar calendar) {
return ScheduleInfo.builder()
.calendar(calendar)
.creatorId(this.creatorId)
.build();
}

}

0 comments on commit 85a1f70

Please sign in to comment.