Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public record ConfirmClub(
@Size(max = 30)
String description,

@NotBlank
@NotNull
String introduce,

@NotBlank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class AdminWebsiteClubSheetImportService {
private static final int TOPIC_MAX_LENGTH = 20;
private static final int DESCRIPTION_MAX_LENGTH = 30;
private static final int CATEGORY_EMOJI_MAX_LENGTH = 255;
private static final String EMPTY_INTRODUCE = "";
private static final int NAME_COLUMN_INDEX = 0;
private static final int CATEGORY_COLUMN_INDEX = 1;
private static final int CUSTOM_CATEGORY_COLUMN_INDEX = 2;
Expand Down Expand Up @@ -119,7 +120,7 @@ public AdminWebsiteClubSheetImportResponse confirmImport(
.name(name)
.topic(limit(requiredText(club.topic(), "기타"), TOPIC_MAX_LENGTH))
.description(limit(requiredText(club.description(), name), DESCRIPTION_MAX_LENGTH))
.introduce(requiredText(club.introduce(), club.description()))
.introduce(optionalText(club.introduce()))
.categoryEmoji(limit(
requiredText(club.categoryEmoji(), emojiOf(club.clubCategory())),
CATEGORY_EMOJI_MAX_LENGTH
Expand Down Expand Up @@ -166,7 +167,7 @@ private SheetClubImportPlan buildImportPlan(List<RawClubRow> rows) {
category,
topic,
description,
description,
EMPTY_INTRODUCE,
categoryEmoji,
true
));
Expand Down Expand Up @@ -284,6 +285,10 @@ private static String requiredText(String value, String fallback) {
return value == null || value.isBlank() ? fallback : value.trim();
}

private static String optionalText(String value) {
return value == null ? "" : value.trim();
}

private static String limit(String value, int maxLength) {
if (value == null || value.length() <= maxLength) {
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void previewClubsReturnsServiceResponse() {
ClubCategory.ACADEMIC,
"dev",
"dev club",
"dev club",
"",
"IT",
true
)),
Expand Down Expand Up @@ -69,7 +69,7 @@ void confirmImportReturnsServiceResponse() {
ClubCategory.ACADEMIC,
"dev",
"dev club",
"dev club",
"",
"IT",
true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ void previewClubsReadsFixedSheetColumns() throws Exception {
assertThat(preview.clubs().get(1).topic()).isEqualTo("기타");
assertThat(preview.clubs().get(1).categoryEmoji()).isEqualTo("⚽");
assertThat(preview.clubs().get(1).description()).isEqualTo("농구동아리 동아리입니다.");
assertThat(preview.clubs())
.extracting(AdminWebsiteClubSheetImportPreviewResponse.PreviewClub::introduce)
.containsExactly("", "");
assertThat(preview.warnings()).hasSize(3);
}

Expand All @@ -121,7 +124,9 @@ void confirmImportSavesEnabledAndNonDuplicateClubsOnly() {
assertThat(response.warnings()).anyMatch(warning -> warning.contains("농구동아리"));
assertThat(response.warnings()).anyMatch(warning -> warning.contains("BCSD"));
verify(webClubRepository).saveAll(org.mockito.ArgumentMatchers.<List<WebClub>>argThat(savedClubs ->
savedClubs.size() == 1 && savedClubs.getFirst().getName().equals("BCSD")
savedClubs.size() == 1
&& savedClubs.getFirst().getName().equals("BCSD")
&& savedClubs.getFirst().getIntroduce().isEmpty()
));
verifyNoInteractions(googleSheetsService);
}
Expand Down Expand Up @@ -168,7 +173,7 @@ private AdminWebsiteClubSheetImportConfirmRequest.ConfirmClub confirmClub(
category,
"dev",
"dev club",
"dev club",
"",
"IT",
enabled
);
Expand Down
Loading