-
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.
[deploy] 새롭게 반영된 사항 적용해서 배포합니다 (#164)
- Loading branch information
Showing
12 changed files
with
224 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
40 changes: 40 additions & 0 deletions
40
src/main/java/com/ggang/be/api/group/dto/LatestResponse.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,40 @@ | ||
package com.ggang.be.api.group.dto; | ||
|
||
import com.ggang.be.domain.constant.Category; | ||
import com.ggang.be.domain.constant.GroupType; | ||
import com.ggang.be.domain.constant.WeekDate; | ||
import com.ggang.be.domain.group.dto.GroupVo; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record LatestResponse( | ||
long groupId, | ||
Category category, | ||
int coverImg, | ||
int profileImg, | ||
String nickname, | ||
GroupType groupType, | ||
String groupTitle, | ||
WeekDate weekDate, | ||
LocalDate groupDate, | ||
double startTime, | ||
double endTime, | ||
String location | ||
) { | ||
public static LatestResponse fromGroupVo(GroupVo groupVo) { | ||
return new LatestResponse( | ||
groupVo.groupId(), | ||
groupVo.category(), | ||
groupVo.coverImg(), | ||
groupVo.profileImg(), | ||
groupVo.nickname(), | ||
groupVo.groupType(), | ||
groupVo.groupTitle(), | ||
groupVo.weekDate(), | ||
groupVo.groupDate(), | ||
groupVo.startTime(), | ||
groupVo.endTime(), | ||
groupVo.location() | ||
); | ||
} | ||
} |
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
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
63 changes: 63 additions & 0 deletions
63
src/test/java/com/ggang/be/api/school/SearchSchoolFacadeTest.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,63 @@ | ||
package com.ggang.be.api.school; | ||
|
||
import com.ggang.be.api.facade.SearchSchoolFacade; | ||
import com.ggang.be.api.school.dto.SchoolSearchResponse; | ||
import com.ggang.be.api.school.service.SchoolService; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
class SearchSchoolFacadeTest { | ||
|
||
private final SchoolService schoolService = Mockito.mock(SchoolService.class); | ||
private final SearchSchoolFacade searchSchoolFacade = new SearchSchoolFacade(schoolService); | ||
|
||
@DisplayName("검색 키워드로 학교를 검색했을 때 결과를 반환한다.") | ||
@Test | ||
void searchSchool() { | ||
// Given | ||
String keyword = "서울"; | ||
List<String> mockResult = Arrays.asList("서울대학교", "서울시립대학교"); | ||
when(schoolService.searchSchoolContainingKeyword(keyword)).thenReturn(mockResult); | ||
|
||
// When | ||
SchoolSearchResponse response = searchSchoolFacade.searchSchool(keyword); | ||
|
||
// Then | ||
assertThat(response.schoolNames()).containsExactly("서울대학교", "서울시립대학교"); | ||
} | ||
|
||
@DisplayName("검색 키워드가 없는 경우 빈 리스트를 반환한다.") | ||
@Test | ||
void searchSchoolNoResult() { | ||
// Given | ||
String keyword = "없는학교"; | ||
when(schoolService.searchSchoolContainingKeyword(keyword)).thenReturn(Collections.emptyList()); | ||
|
||
// When | ||
SchoolSearchResponse response = searchSchoolFacade.searchSchool(keyword); | ||
|
||
// Then | ||
assertThat(response.schoolNames()).isEmpty(); | ||
} | ||
|
||
@DisplayName("검색 키워드가 null인 경우 빈 리스트를 반환한다.") | ||
@Test | ||
void searchSchoolNullKeyword() { | ||
// Given | ||
when(schoolService.searchSchoolContainingKeyword(null)).thenReturn(Collections.emptyList()); | ||
|
||
// When | ||
SchoolSearchResponse response = searchSchoolFacade.searchSchool(null); | ||
|
||
// Then | ||
assertThat(response.schoolNames()).isEmpty(); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/test/java/com/ggang/be/api/school/SearchSchoolMajorFacadeTest.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,91 @@ | ||
package com.ggang.be.api.school; | ||
|
||
import com.ggang.be.api.common.ResponseError; | ||
import com.ggang.be.api.exception.GongBaekException; | ||
import com.ggang.be.api.facade.SearchSchoolMajorFacade; | ||
import com.ggang.be.api.school.service.SchoolService; | ||
import com.ggang.be.api.schoolMajor.dto.SearchedSchoolMajorResponse; | ||
import com.ggang.be.api.schoolMajor.service.SchoolMajorService; | ||
import com.ggang.be.domain.school.application.School; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
import static org.mockito.Mockito.when; | ||
|
||
class SearchSchoolMajorFacadeTest { | ||
|
||
private final SchoolMajorService schoolMajorService = Mockito.mock(SchoolMajorService.class); | ||
private final SchoolService schoolService = Mockito.mock(SchoolService.class); | ||
private final SearchSchoolMajorFacade searchSchoolMajorFacade = new SearchSchoolMajorFacade(schoolMajorService, schoolService); | ||
|
||
@DisplayName("학교 이름과 학과 키워드로 학과를 검색했을 때 결과를 반환한다.") | ||
@Test | ||
void searchSchoolMajorBySchoolName() { | ||
// Given | ||
String schoolName = "서울대학교"; | ||
String majorKeyword = "컴퓨터"; | ||
School mockSchool = School.builder().id(1L).schoolName("서울대학교").schoolDomain("서울대학교").build(); | ||
List<String> mockMajors = Arrays.asList("컴퓨터공학과", "컴퓨터과학과"); | ||
|
||
when(schoolService.findSchoolByName(schoolName)).thenReturn(mockSchool); | ||
when(schoolMajorService.findSchoolMajorBySchoolAndMajorName(mockSchool.getId(), majorKeyword)).thenReturn(mockMajors); | ||
|
||
// When | ||
SearchedSchoolMajorResponse response = searchSchoolMajorFacade.searchSchoolMajorBySchoolName(schoolName, majorKeyword); | ||
|
||
// Then | ||
assertThat(response.schoolMajors()).containsExactly("컴퓨터공학과", "컴퓨터과학과"); | ||
} | ||
|
||
|
||
@DisplayName("학교 이름이 잘못되었을 경우 예외가 발생하고 'NOT_FOUND' 응답을 반환한다.") | ||
@Test | ||
void searchSchoolMajorByInvalidSchoolName() { | ||
// Given | ||
String invalidSchoolName = "없는학교"; | ||
String majorKeyword = "컴퓨터"; | ||
|
||
when(schoolService.findSchoolByName(invalidSchoolName)).thenThrow(new GongBaekException(ResponseError.NOT_FOUND)); | ||
|
||
// When & Then | ||
assertThatThrownBy(() -> searchSchoolMajorFacade.searchSchoolMajorBySchoolName(invalidSchoolName, majorKeyword)).isInstanceOf(GongBaekException.class).hasMessage(ResponseError.NOT_FOUND.getMessage()); | ||
} | ||
|
||
@DisplayName("학교 이름이 null 일 경우 예외가 발생하고 'NOT_FOUND' 응답을 반환한다.") | ||
@Test | ||
void searchSchoolMajorBySchoolNameNull() { | ||
// Given | ||
String majorKeyword = "컴퓨터"; | ||
|
||
when(schoolService.findSchoolByName(null)).thenThrow(new GongBaekException(ResponseError.NOT_FOUND)); | ||
|
||
// When & Then | ||
assertThatThrownBy(() -> searchSchoolMajorFacade.searchSchoolMajorBySchoolName(null, majorKeyword)).isInstanceOf(GongBaekException.class).hasMessage(ResponseError.NOT_FOUND.getMessage()); | ||
} | ||
|
||
@DisplayName("학과 키워드가 없는 경우 빈 결과를 반환한다.") | ||
@Test | ||
void searchSchoolMajorWithoutKeyword() { | ||
// Given | ||
String schoolName = "서울대학교"; | ||
String emptyKeyword = ""; | ||
School mockSchool = School.builder().id(1L).schoolName("서울대학교").schoolDomain("서울대학교").build(); | ||
|
||
when(schoolService.findSchoolByName(schoolName)).thenReturn(mockSchool); | ||
when(schoolMajorService.findSchoolMajorBySchoolAndMajorName(mockSchool.getId(), emptyKeyword)).thenReturn(Collections.emptyList()); | ||
|
||
// When | ||
SearchedSchoolMajorResponse response = searchSchoolMajorFacade.searchSchoolMajorBySchoolName(schoolName, emptyKeyword); | ||
|
||
// Then | ||
assertThat(response.schoolMajors()).isEmpty(); | ||
} | ||
} | ||
|