Skip to content

Commit

Permalink
feat: BaseEntity에 Setter 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghwankim-dev committed Oct 18, 2024
1 parent 017d451 commit 1edcdcc
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/co/fineants/api/domain/BaseEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package co.fineants.api.domain.portfolio.domain.entity;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -445,6 +446,10 @@ public Map<Month, Expression> calTotalDividend(PortfolioCalculator calculator, L
}
//== Portfolio 계산 메서드 시작 ==//

public void setCreateAt(LocalDateTime createAt) {
super.setCreateAt(createAt);
}

@Override
public String toString() {
return String.format("Portfolio(id=%d, detail=%s, memberNickname=%s)", id, detail, member.getNickname());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import co.fineants.api.domain.portfolio.domain.dto.response.PortFolioCreateResponse;
import co.fineants.api.domain.portfolio.domain.dto.response.PortFolioItem;
import co.fineants.api.domain.portfolio.domain.dto.response.PortfolioModifyResponse;
import co.fineants.api.domain.portfolio.domain.dto.response.PortfolioNameItem;
import co.fineants.api.domain.portfolio.domain.dto.response.PortfolioNameResponse;
import co.fineants.api.domain.portfolio.domain.dto.response.PortfoliosResponse;
import co.fineants.api.domain.portfolio.domain.entity.Portfolio;
import co.fineants.api.domain.portfolio.service.PortFolioService;
Expand Down Expand Up @@ -200,6 +202,51 @@ void searchMyAllPortfolios() throws Exception {
);
}

@DisplayName("포트폴리오 이름 목록 API")
@Test
void searchMyAllPortfolioNames() throws Exception {
// given
Portfolio portfolio = createPortfolio(createMember());
portfolio.setCreateAt(LocalDateTime.now());
PortfolioNameItem item = PortfolioNameItem.from(portfolio);
given(portFolioService.readMyAllPortfolioNames(anyLong()))
.willReturn(PortfolioNameResponse.from(List.of(item)));

// when & then
mockMvc.perform(get("/api/portfolios/names")
.cookie(createTokenCookies()))
.andExpect(status().isOk())
.andExpect(jsonPath("code").value(equalTo(200)))
.andExpect(jsonPath("status").value(equalTo("OK")))
.andExpect(jsonPath("message").value(equalTo(PortfolioSuccessCode.OK_SEARCH_PORTFOLIO_NAMES.getMessage())))
.andExpect(jsonPath("data.portfolios[0].id").value(equalTo(portfolio.getId().intValue())))
.andExpect(jsonPath("data.portfolios[0].name").value(equalTo("내꿈은 워렌버핏")))
.andExpect(jsonPath("data.portfolios[0].dateCreated").isNotEmpty())
.andDo(
document(
"portfolio-search-names",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("code").type(JsonFieldType.NUMBER)
.description("코드"),
fieldWithPath("status").type(JsonFieldType.STRING)
.description("상태"),
fieldWithPath("message").type(JsonFieldType.STRING)
.description("메시지"),
fieldWithPath("data").type(JsonFieldType.OBJECT)
.description("응답 데이터"),
fieldWithPath("data.portfolios[].id").type(JsonFieldType.NUMBER)
.description("포트폴리오 등록번호"),
fieldWithPath("data.portfolios[].name").type(JsonFieldType.STRING)
.description("포트폴리오 이름"),
fieldWithPath("data.portfolios[].dateCreated").type(JsonFieldType.STRING)
.description("추가일자")
)
)
);
}

@DisplayName("포트폴리오 수정 API")
@Test
void updatePortfolio() throws Exception {
Expand Down

0 comments on commit 1edcdcc

Please sign in to comment.