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 @@ -7,19 +7,22 @@
@Data
public class SubscriableCompanyResponse {
private final Long companyId;
private final String companyName;
private final String companyImageUrl;
private final Boolean isSubscribed;

@Builder
public SubscriableCompanyResponse(Long companyId, String companyImageUrl, Boolean isSubscribed) {
public SubscriableCompanyResponse(Long companyId, String companyName, String companyImageUrl, Boolean isSubscribed) {
this.companyId = companyId;
this.companyName = companyName;
this.companyImageUrl = companyImageUrl;
this.isSubscribed = isSubscribed;
}

public static SubscriableCompanyResponse create(Company company) {
return SubscriableCompanyResponse.builder()
.companyId(company.getId())
.companyName(company.getName().getCompanyName())
.companyImageUrl(company.getOfficialImageUrl().getUrl())
.isSubscribed(false)
.build();
Expand All @@ -28,6 +31,7 @@ public static SubscriableCompanyResponse create(Company company) {
public static SubscriableCompanyResponse createWithIsSubscribed(Company company, Boolean isSubscribed) {
return SubscriableCompanyResponse.builder()
.companyId(company.getId())
.companyName(company.getName().getCompanyName())
.companyImageUrl(company.getOfficialImageUrl().getUrl())
.isSubscribed(isSubscribed)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void unsubscribe() throws Exception {
@DisplayName("구독 가능한 기업 목록을 조회한다.")
void getSubscriptions() throws Exception {
// given
SubscriableCompanyResponse response = new SubscriableCompanyResponse(1L,
SubscriableCompanyResponse response = new SubscriableCompanyResponse(1L, "트이다",
"https://www.teuida.net/public/src/img/teuida_logo.png", true);
given(memberSubscriptionService.getSubscribableCompany(any(), anyLong(), any()))
.willReturn(new SliceImpl<>(List.of(response), PageRequest.of(0, 20), false));
Expand All @@ -95,6 +95,7 @@ void getSubscriptions() throws Exception {
.andExpect(jsonPath("$.data").isNotEmpty())
.andExpect(jsonPath("$.data.content").isArray())
.andExpect(jsonPath("$.data.content.[0].companyId").isNumber())
.andExpect(jsonPath("$.data.content.[0].companyName").isString())
.andExpect(jsonPath("$.data.content.[0].companyImageUrl").isString())
.andExpect(jsonPath("$.data.content.[0].isSubscribed").isBoolean())
.andExpect(jsonPath("$.data.pageable").isNotEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void unsubscribeSubscriptionException() throws Exception {
@DisplayName("구독 가능한 기업 목록을 조회한다.")
void getSubscriptions() throws Exception {
// given
SubscriableCompanyResponse response = new SubscriableCompanyResponse(1L,
SubscriableCompanyResponse response = new SubscriableCompanyResponse(1L, "트이다",
"https://www.teuida.net/public/src/img/teuida_logo.png", true);
given(memberSubscriptionService.getSubscribableCompany(any(), anyLong(), any()))
.willReturn(new SliceImpl<>(List.of(response), PageRequest.of(0, 20), false));
Expand Down Expand Up @@ -247,6 +247,7 @@ void getSubscriptions() throws Exception {

fieldWithPath("data.content").type(ARRAY).description("구독 가능한 기업 목록 메인 배열"),
fieldWithPath("data.content[].companyId").type(NUMBER).description("기업 아이디"),
fieldWithPath("data.content[].companyName").type(STRING).description("기업명"),
fieldWithPath("data.content[].companyImageUrl").type(STRING).description("기업 로고 이미지 url"),
fieldWithPath("data.content[].isSubscribed").type(JsonFieldType.BOOLEAN)
.description("회원의 구독 여부"),
Expand Down