diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 24f5166d..49145a20 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -1,35 +1,36 @@ name: Gradle Build on: - pull_request: - branches: [dev, master, feature/*, refactor/* ] + pull_request_target: + types: [ opened, reopened, synchronize ] + jobs: build: runs-on: ubuntu-latest environment: build_gradle + permissions: contents: read packages: write steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: '11' - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 - with: - arguments: build - env: - IBAS_DEV_JWT_SECRET_KEY: ${{ secrets.IBAS_DEV_JWT_SECRET_KEY }} - IBAS_DEV_KAKAO_CLIENT_ID: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_ID }} - IBAS_DEV_KAKAO_CLIENT_SECRET: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_SECRET }} - IBAS_DEV_NAVER_CLIENT_ID: ${{ secrets.IBAS_DEV_NAVER_CLIENT_ID }} - IBAS_DEV_NAVER_CLIENT_SECRET: ${{ secrets.IBAS_DEV_NAVER_CLIENT_SECRET }} - IBAS_DEV_GOOGLE_CLIENT_ID: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_ID }} - IBAS_DEV_GOOGLE_CLIENT_SECRET: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_SECRET }} + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew clean build + env: + IBAS_DEV_JWT_SECRET_KEY: ${{ secrets.IBAS_DEV_JWT_SECRET_KEY }} + IBAS_DEV_KAKAO_CLIENT_ID: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_ID }} + IBAS_DEV_KAKAO_CLIENT_SECRET: ${{ secrets.IBAS_DEV_KAKAO_CLIENT_SECRET }} + IBAS_DEV_NAVER_CLIENT_ID: ${{ secrets.IBAS_DEV_NAVER_CLIENT_ID }} + IBAS_DEV_NAVER_CLIENT_SECRET: ${{ secrets.IBAS_DEV_NAVER_CLIENT_SECRET }} + IBAS_DEV_GOOGLE_CLIENT_ID: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_ID }} + IBAS_DEV_GOOGLE_CLIENT_SECRET: ${{ secrets.IBAS_DEV_GOOGLE_CLIENT_SECRET }} diff --git a/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java b/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java index c5b809af..6034c406 100644 --- a/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java +++ b/resource-server/src/main/java/com/inhabas/api/config/SwaggerConfig.java @@ -94,6 +94,17 @@ public GroupedOpenApi getMemberApi() { } + @Bean + public GroupedOpenApi getIBASApi() { + + return GroupedOpenApi + .builder() + .group("IBAS 관련") + .pathsToMatch("/club/**") + .build(); + + } + @Bean @Profile("local") public OpenAPI localOpenAPI() { diff --git a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java index 952c3eed..dbaee3f6 100644 --- a/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java +++ b/resource-server/src/main/java/com/inhabas/api/config/WebSecurityConfig.java @@ -45,7 +45,7 @@ public class WebSecurityConfig { private static final String[] AUTH_WHITELIST_PATH = {"/menu/**", "/menus", "/member/chief", "/error"}; private static final String[] AUTH_WHITELIST_SIGNUP = {"/signUp/schedule", "/signUp/questionnaires", "/signUp/majorInfo"}; - + private static final String[] AUTH_WHITELIST_CLUB = {"/club/histories", "/club/history/**"}; @Order(1) @EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true) @@ -71,6 +71,7 @@ public void configure(AuthenticationManagerBuilder auth) throws Exception { public void configure(WebSecurity web) throws Exception { web.ignoring() .antMatchers(HttpMethod.GET, AUTH_WHITELIST_SIGNUP) + .antMatchers(HttpMethod.GET, AUTH_WHITELIST_CLUB) .antMatchers(AUTH_WHITELIST_SWAGGER) .antMatchers(AUTH_WHITELIST_STATIC) .antMatchers(AUTH_WHITELIST_PATH); @@ -122,6 +123,9 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers("/signUp/check").hasRole(ANONYMOUS.toString()) .antMatchers("/signUp/**").hasRole(SIGNING_UP.toString()) + // 동아리 연혁 수정 + .antMatchers("/club/history/**").hasRole(EXECUTIVES.toString()) + // 그 외 .anyRequest().hasRole(ANONYMOUS.toString()); diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java index e28b5163..67e13702 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/NormalBoard.java @@ -2,7 +2,7 @@ import com.inhabas.api.domain.board.BaseBoard; import com.inhabas.api.domain.board.BoardCannotModifiableException; -import com.inhabas.api.domain.board.domain.valueObject.Contents; +import com.inhabas.api.domain.board.domain.valueObject.Content; import com.inhabas.api.domain.board.domain.valueObject.Title; import com.inhabas.api.domain.comment.domain.Comment; import com.inhabas.api.domain.file.BoardFile; @@ -39,7 +39,7 @@ public class NormalBoard extends BaseBoard { @Embedded - protected Contents contents; + protected Content content; @OneToMany(mappedBy = "parentBoard", cascade = CascadeType.ALL, orphanRemoval = true) protected List comments = new ArrayList<>(); @@ -52,14 +52,14 @@ public class NormalBoard extends BaseBoard { public NormalBoard(String title, String contents) { this.title = new Title(title); - this.contents = new Contents(contents); + this.content = new Content(contents); } /* getter */ - public String getContents() { - return contents.getValue(); + public String getContent() { + return content.getValue(); } public Set getFiles() { @@ -92,7 +92,7 @@ public void modify(String title, String contents, StudentId loginMember) { } this.title = new Title(title); - this.contents = new Contents(contents); + this.content = new Content(contents); } public boolean cannotModifiableBy(StudentId loginMember) { diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Contents.java b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java similarity index 70% rename from resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Contents.java rename to resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java index 76782d0a..7549f7ad 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Contents.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Content.java @@ -1,26 +1,28 @@ package com.inhabas.api.domain.board.domain.valueObject; + import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; + import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Transient; import java.util.Objects; @Embeddable -public class Contents { +public class Content { - @Column(name = "contents", columnDefinition = "MEDIUMTEXT", nullable = false) + @Column(name = "CONTENT", columnDefinition = "MEDIUMTEXT", nullable = false) private String value; @Transient private final int MAX_SIZE = 2 << 24 - 1; //16MB - public Contents() {} + public Content() {} - public Contents(String value) { + public Content(String value) { if (validate(value)) this.value = value; else - throw new IllegalArgumentException(); + throw new InvalidInputException(); } private boolean validate(Object value) { diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java index 20608769..d22f6391 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/domain/valueObject/Title.java @@ -1,5 +1,7 @@ package com.inhabas.api.domain.board.domain.valueObject; +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; + import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Transient; @@ -8,7 +10,7 @@ @Embeddable public class Title { - @Column(name = "title", length = 100, nullable = false) + @Column(name = "TITLE", length = 100, nullable = false) private String value; @Transient @@ -20,7 +22,7 @@ public Title(String value) { if (validate(value)) this.value = value; else - throw new IllegalArgumentException(); + throw new InvalidInputException(); } private boolean validate(Object value) { diff --git a/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java index a7cb8fc9..bdbcc8d8 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryImpl.java @@ -26,7 +26,7 @@ public Page findAllByMenuId(MenuId menuId, Pageable pageable) { List results = queryFactory.select(Projections.constructor(BoardDto.class, normalBoard.id, normalBoard.title.value, - Expressions.asString("").as("contents"), + Expressions.asString("").as("content"), member.name.value, normalBoard.menuId, normalBoard.dateCreated, @@ -60,7 +60,7 @@ public Optional findDtoById(Integer id) { BoardDto target = queryFactory.select(Projections.constructor(BoardDto.class, Expressions.asNumber(id).as("id"), normalBoard.title.value, - normalBoard.contents.value, + normalBoard.content.value, member.name.value, normalBoard.menuId, normalBoard.dateCreated, diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java new file mode 100644 index 00000000..c7113aa9 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/domain/entity/ClubHistory.java @@ -0,0 +1,60 @@ +package com.inhabas.api.domain.club.domain.entity; + +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +import java.time.LocalDateTime; + +@Entity +@Table(name = "CLUB_HISTORY") +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@EntityListeners(AuditingEntityListener.class) +public class ClubHistory { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "USER_ID", foreignKey = @ForeignKey(name = "FK_MEMBER_OF_CLUB_HISTORY")) + private Member member; + + @Embedded + private Title title; + + @Embedded + private Content content; + + @Column(name = "DATE_HISTORY", nullable = false, columnDefinition = "DATETIME(0)") + private LocalDateTime dateHistory; + + @CreatedDate + @Column(name = "DATE_CREATED", nullable = false, updatable = false, insertable = false, columnDefinition = "DATETIME(0) DEFAULT CURRENT_TIMESTAMP") + private LocalDateTime dateCreated; + + @Builder + public ClubHistory(Member member, Title title, Content content, LocalDateTime dateHistory) { + this.member = member; + this.title = title; + this.content = content; + this.dateHistory = dateHistory; + } + + public void updateClubHistory(Member member, SaveClubHistoryDto saveClubHistoryDto) { + this.member = member; + this.title = new Title(saveClubHistoryDto.getTitle()); + this.content = new Content(saveClubHistoryDto.getContent()); + this.dateHistory = saveClubHistoryDto.getDateHistory(); + } + +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java new file mode 100644 index 00000000..e0660267 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/ClubHistoryDto.java @@ -0,0 +1,53 @@ +package com.inhabas.api.domain.club.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.inhabas.api.domain.club.domain.entity.ClubHistory; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor +public class ClubHistoryDto { + + @NotNull + @Positive + private Long id; + + @NotNull + private String title; + + @NotNull + private String content; + + @NotNull + @Positive + private Long writerId; + + @NotNull + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") + @Schema(type = "string", example = "2023-11-01T00:00:00") + private LocalDateTime dateHistory; + + @Builder + public ClubHistoryDto(Long id, String title, String content, Long writerId, LocalDateTime dateHistory) { + this.id = id; + this.title = title; + this.content = content; + this.writerId = writerId; + this.dateHistory = dateHistory; + } + + public ClubHistoryDto(ClubHistory clubHistory) { + this.id = clubHistory.getId(); + this.title = clubHistory.getTitle().getValue(); + this.content = clubHistory.getContent().getValue(); + this.writerId = clubHistory.getMember().getId(); + this.dateHistory = clubHistory.getDateHistory(); + } +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java new file mode 100644 index 00000000..792d6333 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDto.java @@ -0,0 +1,32 @@ +package com.inhabas.api.domain.club.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor +public class SaveClubHistoryDto { + + private String title; + + private String content; + + @NotNull + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") + @Schema(type = "string", example = "2023-11-01T00:00:00") + private LocalDateTime dateHistory; + + @Builder + public SaveClubHistoryDto(String title, String content, LocalDateTime dateHistory) { + this.title = title; + this.content = content; + this.dateHistory = dateHistory; + } + +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java b/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java new file mode 100644 index 00000000..e8f76221 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java @@ -0,0 +1,7 @@ +package com.inhabas.api.domain.club.repository; + +import com.inhabas.api.domain.club.domain.entity.ClubHistory; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ClubHistoryRepository extends JpaRepository { +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java new file mode 100644 index 00000000..4e572f19 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java @@ -0,0 +1,21 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; + +import java.util.List; + +public interface ClubHistoryService { + + Long writeClubHistory(Long memberId, SaveClubHistoryDto saveClubHistoryDto); + + ClubHistoryDto findClubHistory(Long clubHistoryId); + + List getClubHistories(); + + void updateClubHistory(Long memberId, Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto); + + void deleteClubHistory(Long clubHistoryId); + +} + diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java new file mode 100644 index 00000000..7c8b390c --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java @@ -0,0 +1,88 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.auth.domain.error.businessException.NotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.auth.domain.oauth2.member.domain.exception.MemberNotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.domain.entity.ClubHistory; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.repository.ClubHistoryRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class ClubHistoryServiceImpl implements ClubHistoryService { + + private final ClubHistoryRepository clubHistoryRepository; + + private final MemberRepository memberRepository; + + + @Override + @Transactional + public Long writeClubHistory(Long memberId, SaveClubHistoryDto saveClubHistoryDto) { + + Member writer = memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new); + ClubHistory clubHistory = ClubHistory.builder() + .member(writer) + .title(new Title(saveClubHistoryDto.getTitle())) + .content(new Content(saveClubHistoryDto.getContent())) + .dateHistory(saveClubHistoryDto.getDateHistory()) + .build(); + + ClubHistory result = clubHistoryRepository.save(clubHistory); + + return result.getId(); + + } + + @Override + @Transactional(readOnly = true) + public ClubHistoryDto findClubHistory(Long clubHistoryId) { + + ClubHistory clubHistory = clubHistoryRepository.findById(clubHistoryId).orElseThrow(NotFoundException::new); + + return new ClubHistoryDto(clubHistory); + + } + + @Override + @Transactional(readOnly = true) + public List getClubHistories() { + + List clubHistoryList = clubHistoryRepository.findAll(); + + return clubHistoryList.stream() + .map(ClubHistoryDto::new) + .collect(Collectors.toList()); + + } + + @Override + @Transactional + public void updateClubHistory(Long memberId, Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto) { + + ClubHistory clubHistory = clubHistoryRepository.findById(clubHistoryId).orElseThrow(NotFoundException::new); + Member writer = memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new); + + clubHistory.updateClubHistory(writer, saveClubHistoryDto); + + } + + @Override + @Transactional + public void deleteClubHistory(Long clubHistoryId) { + + ClubHistory clubHistory = clubHistoryRepository.findById(clubHistoryId).orElseThrow(NotFoundException::new); + clubHistoryRepository.delete(clubHistory); + + } +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java b/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java index 02e9760f..2fea9fd8 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/comment/domain/valueObject/Contents.java @@ -8,7 +8,7 @@ @Embeddable public class Contents { - @Column(name = "contents", length = 500, nullable = false) + @Column(name = "content", length = 500, nullable = false) private String value; @Transient diff --git a/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java b/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java index 857702c7..f3dc1a65 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/contest/domain/ContestBoard.java @@ -1,7 +1,7 @@ package com.inhabas.api.domain.contest.domain; import com.inhabas.api.domain.board.domain.NormalBoard; -import com.inhabas.api.domain.board.domain.valueObject.Contents; +import com.inhabas.api.domain.board.domain.valueObject.Content; import com.inhabas.api.domain.board.domain.valueObject.Title; import com.inhabas.api.domain.contest.domain.valueObject.Association; import com.inhabas.api.domain.contest.domain.valueObject.Topic; @@ -50,7 +50,7 @@ public String getTopic(){ public ContestBoard(String title, String contents, String association, String topic, LocalDate start, LocalDate deadline){ this.title = new Title(title); - this.contents = new Contents(contents); + this.content = new Content(contents); this.association = new Association(association); this.topic = new Topic(topic); this.start = start; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java index a88b45d6..7ef1a862 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java @@ -34,7 +34,7 @@ public Optional findDtoById(Integer id) { Expressions.asNumber(id).as("id"), member.name.value, contestBoard.title.value, - contestBoard.contents.value, + contestBoard.content.value, contestBoard.association.value, contestBoard.topic.value, contestBoard.start, diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteAnswersException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteAnswersException.java similarity index 83% rename from resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteAnswersException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteAnswersException.java index 25465348..58f4c6e0 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteAnswersException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteAnswersException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUp.domain.exception; +package com.inhabas.api.domain.signUp.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteProfileException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteProfileException.java similarity index 83% rename from resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteProfileException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteProfileException.java index e82e3657..5e5ff406 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/domain/exception/NotWriteProfileException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/exception/NotWriteProfileException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUp.domain.exception; +package com.inhabas.api.domain.signUp.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java index 95f0524c..fffdee61 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceImpl.java @@ -11,8 +11,8 @@ import com.inhabas.api.auth.domain.oauth2.socialAccount.repository.MemberSocialAccountRepository; import com.inhabas.api.domain.questionnaire.dto.QuestionnaireDto; import com.inhabas.api.domain.questionnaire.usecase.QuestionnaireService; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteAnswersException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteProfileException; +import com.inhabas.api.domain.signUp.exception.NotWriteAnswersException; +import com.inhabas.api.domain.signUp.exception.NotWriteProfileException; import com.inhabas.api.domain.signUp.dto.AnswerDto; import com.inhabas.api.domain.signUp.dto.SignUpDto; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpScheduler; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java index 16886c1a..c18ced88 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpSchedule.java @@ -1,7 +1,7 @@ package com.inhabas.api.domain.signUpSchedule.domain.entity; import com.inhabas.api.auth.domain.error.ErrorCode; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/InvalidDateException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/InvalidDateException.java similarity index 81% rename from resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/InvalidDateException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/InvalidDateException.java index 0c66a22a..aa32cf46 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/InvalidDateException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/InvalidDateException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUpSchedule.domain.exception; +package com.inhabas.api.domain.signUpSchedule.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/SignUpNotAvailableException.java b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/SignUpNotAvailableException.java similarity index 82% rename from resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/SignUpNotAvailableException.java rename to resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/SignUpNotAvailableException.java index 5d2bf112..0e099a29 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/domain/exception/SignUpNotAvailableException.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/signUpSchedule/exception/SignUpNotAvailableException.java @@ -1,4 +1,4 @@ -package com.inhabas.api.domain.signUpSchedule.domain.exception; +package com.inhabas.api.domain.signUpSchedule.exception; import com.inhabas.api.auth.domain.error.ErrorCode; import com.inhabas.api.auth.domain.error.businessException.BusinessException; diff --git a/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java new file mode 100644 index 00000000..2df13fbb --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java @@ -0,0 +1,148 @@ +package com.inhabas.api.web; + +import com.inhabas.api.auth.domain.error.ErrorResponse; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.usecase.ClubHistoryService; +import com.inhabas.api.web.argumentResolver.Authenticated; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import javax.validation.Valid; +import java.net.URI; +import java.util.List; + +@Tag(name = "동아리 소개", description = "동아리 소개 관련") +@RestController +@RequiredArgsConstructor +public class ClubHistoryController { + + private final ClubHistoryService clubHistoryService; + + @Operation(summary = "동아리 연혁 조회", + description = "동아리 연혁 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", content = { @Content( + schema = @Schema(implementation = ClubHistoryDto.class, + type = "array")) }), + }) + @GetMapping("/club/histories") + public ResponseEntity> getClubHistories() { + + List clubHistoryDtoList = clubHistoryService.getClubHistories(); + return ResponseEntity.ok(clubHistoryDtoList); + + } + + @Operation(summary = "동아리 연혁 단일 조회", + description = "동아리 연혁 단일 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", content = { @Content( + schema = @Schema(implementation = ClubHistoryDto.class)) + }), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) + }) + @GetMapping("/club/history/{clubHistoryId}") + public ResponseEntity findClubHistory(@PathVariable Long clubHistoryId) { + + ClubHistoryDto clubHistoryDto = clubHistoryService.findClubHistory(clubHistoryId); + return ResponseEntity.ok(clubHistoryDto); + + } + + @Operation(summary = "동아리 연혁 생성", + description = "동아리 연혁 생성") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "'Location' 헤더에 생성된 리소스의 URI 가 포함됩니다."), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )) + }) + @PostMapping("/club/history") + public ResponseEntity writeClubHistory(@Authenticated Long memberId, @Valid @RequestBody SaveClubHistoryDto saveClubHistoryDto) { + + Long newClubHistoryId = clubHistoryService.writeClubHistory(memberId, saveClubHistoryDto); + URI location = ServletUriComponentsBuilder.fromCurrentRequest() + .path("/club/history/{clubHistoryId}") + .buildAndExpand(newClubHistoryId) + .toUri(); + return ResponseEntity.created(location).build(); + + } + + @Operation(summary = "동아리 연혁 수정", + description = "동아리 연혁 수정") + @ApiResponses(value = { + @ApiResponse(responseCode = "204"), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) + + }) + @PutMapping("/club/history/{clubHistoryId}") + public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, @Authenticated Long memberId, + @Valid @RequestBody SaveClubHistoryDto saveClubHistoryDto) { + + clubHistoryService.updateClubHistory(memberId, clubHistoryId, saveClubHistoryDto); + return ResponseEntity.noContent().build(); + + } + + @Operation(summary = "동아리 연혁 삭제", + description = "동아리 연혁 삭제") + @ApiResponses(value = { + @ApiResponse(responseCode = "204"), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) + }) + @DeleteMapping ("/club/history/{clubHistoryId}") + public ResponseEntity deleteClubHistory(@PathVariable Long clubHistoryId) { + + clubHistoryService.deleteClubHistory(clubHistoryId); + return ResponseEntity.noContent().build(); + + } + +} diff --git a/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java b/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java index 6b35010c..06a57357 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java +++ b/resource-server/src/main/java/com/inhabas/api/web/ExceptionController.java @@ -3,10 +3,10 @@ import com.inhabas.api.auth.domain.error.ErrorResponse; import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; import com.inhabas.api.auth.domain.error.businessException.NotFoundException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteAnswersException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteProfileException; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; -import com.inhabas.api.domain.signUpSchedule.domain.exception.SignUpNotAvailableException; +import com.inhabas.api.domain.signUp.exception.NotWriteAnswersException; +import com.inhabas.api.domain.signUp.exception.NotWriteProfileException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.SignUpNotAvailableException; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java b/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java index 75a8a0c9..d7a693d3 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java +++ b/resource-server/src/main/java/com/inhabas/api/web/interceptor/SignUpControllerInterceptor.java @@ -1,7 +1,7 @@ package com.inhabas.api.web.interceptor; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpAvailabilityChecker; -import com.inhabas.api.domain.signUpSchedule.domain.exception.SignUpNotAvailableException; +import com.inhabas.api.domain.signUpSchedule.exception.SignUpNotAvailableException; import lombok.RequiredArgsConstructor; import org.springframework.web.servlet.HandlerInterceptor; diff --git a/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java b/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java index 88c8217a..f558ba5a 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/BaseEntityTest.java @@ -44,7 +44,7 @@ public void setUp() { // public void createdTimeTest() { // //given // Member member = em.persist(basicMember1()); -// NormalBoard board = new NormalBoard("title", "contents") +// NormalBoard board = new NormalBoard("title", "content") // .writtenBy(member.getId()) // .inMenu(freeBoardMenu.getId()); // @@ -60,13 +60,13 @@ public void setUp() { // public void updatedTimeTest() { // //given // Member member = em.persist(basicMember1()); -// NormalBoard board = new NormalBoard("title", "contents") +// NormalBoard board = new NormalBoard("title", "content") // .writtenBy(member.getId()) // .inMenu(freeBoardMenu.getId()); // em.persist(board); // // //when -// board.modify("title2", "modified contents", member.getId()); +// board.modify("title2", "modified content", member.getId()); // em.merge(board); // em.flush();em.clear(); // diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java new file mode 100644 index 00000000..9ba14e1b --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentTest.java @@ -0,0 +1,48 @@ +package com.inhabas.api.domain.board.domain.valueObject; + +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class BoardContentTest { + + @DisplayName("Content 타입에 게시글 내용을 저장한다.") + @Test + public void Contents_is_OK() { + String contentsString = ".".repeat(16777215); // 16 MB - 1 + + Content content = new Content(contentsString); + + assertThat(content.getValue()).isEqualTo(contentsString); + } + + @DisplayName("Content 타입에 너무 긴 게시글을 저장한다. (16 MB - 1 byte) 이상") + @Test + public void Contents_is_too_long() { + String contentsString = ".".repeat(16777215 + 1); // 16 MB - 1 byte + + //then + assertThatThrownBy(() -> new Content(contentsString)) + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); + } + + @DisplayName("Content 타입에 공백을 저장할 수 없다.") + @Test + public void Contents_is_Empty() { + assertThatThrownBy(() -> new Content("")) + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); + } + + @DisplayName("Content 타입에 null 은 허용 안된다.") + @Test + public void Contents_is_Null() { + assertThatThrownBy(() -> new Content(null)) + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); + } +} diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentsTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentsTest.java deleted file mode 100644 index 1f7bbbbd..00000000 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/BoardContentsTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.inhabas.api.domain.board.domain.valueObject; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class BoardContentsTest { - - @DisplayName("Contents 타입에 게시글 내용을 저장한다.") - @Test - public void Contents_is_OK() { - String contentsString = ".".repeat(16777215); // 16 MB - 1 - - Contents contents = new Contents(contentsString); - - assertThat(contents.getValue()).isEqualTo(contentsString); - } - - @DisplayName("Contents 타입에 너무 긴 게시글을 저장한다. (16 MB - 1 byte) 이상") - @Test - public void Contents_is_too_long() { - String contentsString = ".".repeat(16777215 + 1); // 16 MB - 1 byte - - //then - assertThrows(IllegalArgumentException.class, - () -> new Contents(contentsString)); - } - - @DisplayName("Contents 타입에 공백을 저장할 수 없다.") - @Test - public void Contents_is_Empty() { - assertThrows(IllegalArgumentException.class, - () -> new Contents("")); - } - - @DisplayName("Contents 타입에 null 은 허용 안된다.") - @Test - public void Contents_is_Null() { - assertThrows(IllegalArgumentException.class, - () -> new Contents(null)); - } -} diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java index 1bd498df..f8ed47d8 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/domain/valueObject/TitleTest.java @@ -1,8 +1,9 @@ package com.inhabas.api.domain.board.domain.valueObject; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -28,21 +29,24 @@ public void Title_is_too_long() { String titleString = "지금이문장은10자임".repeat(10); //then - assertThrows(IllegalArgumentException.class, - () -> new Title(titleString)); + assertThatThrownBy(() -> new Title(titleString)) + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } @DisplayName("제목은 null 일 수 없습니다.") @Test public void Title_cannot_be_Null() { - assertThrows(IllegalArgumentException.class, - () -> new Title(null)); + assertThatThrownBy(() -> new Title(null)) + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } @DisplayName("제목은 빈 문자열일 수 없습니다.") @Test public void Title_cannot_be_Blank() { - assertThrows(IllegalArgumentException.class, - () -> new Title("\t")); + assertThatThrownBy(() -> new Title("")) + .isInstanceOf(InvalidInputException.class) + .hasMessage("입력값이 없거나, 타입이 유효하지 않습니다."); } } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java index 223b3f68..9794dceb 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/SaveBoardDtoTest.java @@ -34,7 +34,7 @@ public static void close() { @Test public void SaveBoardDto_is_OK(){ //given - SaveBoardDto saveBoardDto = new SaveBoardDto("title", "contents", new MenuId(1)); + SaveBoardDto saveBoardDto = new SaveBoardDto("title", "content", new MenuId(1)); //when Set> violations = validator.validate(saveBoardDto); @@ -43,7 +43,7 @@ public void SaveBoardDto_is_OK(){ assertTrue(violations.isEmpty()); } - @DisplayName("SaveBoardDto의 contents 필드가 null 이면 validation 실패") + @DisplayName("SaveBoardDto의 content 필드가 null 이면 validation 실패") @Test public void Contents_is_null() { // given diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java index 18732626..2701d64e 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/dto/UpdateBoardDtoTest.java @@ -32,7 +32,7 @@ public static void close() { @Test public void UpdateBoardDto_is_OK() { //given - UpdateBoardDto updateBoardDto = new UpdateBoardDto(1, "title", "contents"); + UpdateBoardDto updateBoardDto = new UpdateBoardDto(1, "title", "content"); // when Set> violations = validator.validate(updateBoardDto); diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java index d1a873b7..f2d60f9e 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/repository/NormalBoardRepositoryTest.java @@ -84,7 +84,7 @@ public class NormalBoardRepositoryTest { // () -> assertThat(saveBoard.getId()).isNotNull(), // () -> assertThat(saveBoard.getDateCreated()).isNotNull(), // () -> assertThat(saveBoard.getTitle()).isEqualTo(FREE_BOARD.getTitle()), -// () -> assertThat(saveBoard.getContents()).isEqualTo(FREE_BOARD.getContents()), +// () -> assertThat(saveBoard.getContent()).isEqualTo(FREE_BOARD.getContent()), // () -> assertThat(saveBoard.getWriterId()).isEqualTo(saveMember.getId()) // ); // } @@ -104,7 +104,7 @@ public class NormalBoardRepositoryTest { // assertAll( // () -> assertThat(find.getId()).isEqualTo(NOTICE_BOARD.getId()), // () -> assertThat(find.getTitle()).isEqualTo(NOTICE_BOARD.getTitle()), -// () -> assertThat(find.getContents()).isEqualTo(NOTICE_BOARD.getContents()), +// () -> assertThat(find.getContent()).isEqualTo(NOTICE_BOARD.getContent()), // () -> assertThat(find.getMenuId()).isEqualTo(NOTICE_BOARD.getMenuId()), // () -> assertThat(find.getWriterName()).isEqualTo(writer.getName()) // ); @@ -123,7 +123,7 @@ public class NormalBoardRepositoryTest { // .orElseThrow(EntityNotFoundException::new); // // //then -// assertThat(findBoard.getContents()).isEqualTo("내용이 수정되었습니다."); +// assertThat(findBoard.getContent()).isEqualTo("내용이 수정되었습니다."); // assertThat(findBoard.getTitle()).isEqualTo("제목이 수정되었습니다."); // } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java b/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java index dbdcf3a4..3dca5bca 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/board/usecase/BoardServiceTest.java @@ -53,8 +53,8 @@ void setUp() { @Test public void createBoard() { //given - SaveBoardDto saveBoardDto = new SaveBoardDto("title", "contents", new MenuId(1)); - NormalBoard normalBoard = new NormalBoard("title", "contents"); + SaveBoardDto saveBoardDto = new SaveBoardDto("title", "content", new MenuId(1)); + NormalBoard normalBoard = new NormalBoard("title", "content"); given(boardRepository.save(any())).willReturn(normalBoard); // when @@ -71,10 +71,10 @@ public void getBoardList() { PageRequest pageable = PageRequest.of(0, 10, Sort.Direction.ASC, "created"); BoardDto boardDto1 = - new BoardDto(1, "title", "contents", "mingyeom", + new BoardDto(1, "title", "content", "mingyeom", new MenuId(1), LocalDateTime.now(), LocalDateTime.now()); BoardDto boardDto2 = - new BoardDto(2, "title", "contents", "minji", + new BoardDto(2, "title", "content", "minji", new MenuId(1), LocalDateTime.now(), LocalDateTime.now()); List results = new ArrayList<>(); @@ -97,7 +97,7 @@ public void getBoardList() { public void getDetailBoard() { //given BoardDto boardDto = - new BoardDto(1, "title", "contents", "김민겸", + new BoardDto(1, "title", "content", "김민겸", new MenuId(1), LocalDateTime.now(), null); given(boardRepository.findDtoById(any())).willReturn(Optional.of(boardDto)); @@ -113,7 +113,7 @@ public void getDetailBoard() { public void deleteBoard() { //given StudentId writer = new StudentId("12201863"); - NormalBoard board = new NormalBoard("Title", "Contents").writtenBy(writer); + NormalBoard board = new NormalBoard("Title", "Content").writtenBy(writer); given(boardRepository.findById(anyInt())).willReturn(Optional.of(board)); doNothing().when(boardRepository).deleteById(any()); @@ -130,8 +130,8 @@ public void updateBoard() { //given StudentId memberId = new StudentId("12201863"); NormalBoard savedNormalBoard = new NormalBoard("Origin Title", - "Origin Contents").writtenBy(memberId); - NormalBoard updatedNormalBoard = new NormalBoard("Title", "Contents").writtenBy( + "Origin Content").writtenBy(memberId); + NormalBoard updatedNormalBoard = new NormalBoard("Title", "Content").writtenBy( memberId); given(boardRepository.findById(anyInt())).willReturn(Optional.of(savedNormalBoard)); @@ -152,7 +152,7 @@ public void failToUpdateBoard() { //given StudentId badUser = new StudentId("44444444"); StudentId originWriter = new StudentId("12201863"); - NormalBoard board = new NormalBoard("Title", "Contents").writtenBy(originWriter); + NormalBoard board = new NormalBoard("Title", "Content").writtenBy(originWriter); given(boardRepository.findById(anyInt())).willReturn(Optional.of(board)); // when @@ -166,7 +166,7 @@ public void failToDeleteBoard() { //given StudentId badUser = new StudentId("44444444"); StudentId originWriter = new StudentId("12201863"); - NormalBoard board = new NormalBoard("Title", "Contents").writtenBy(originWriter); + NormalBoard board = new NormalBoard("Title", "Content").writtenBy(originWriter); given(boardRepository.findById(anyInt())).willReturn(Optional.of(board)); // when diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java new file mode 100644 index 00000000..7af62727 --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/domain/entity/ClubHistoryTest.java @@ -0,0 +1,44 @@ +package com.inhabas.api.domain.club.domain.entity; + +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.member.domain.entity.MemberTest; +import org.junit.jupiter.api.Test; + +import java.time.LocalDateTime; + +import static org.assertj.core.api.Assertions.assertThat; + + +class ClubHistoryTest { + + @Test + void updateClubHistory() { + //given + Member writer = MemberTest.chiefMember(); + ClubHistory clubHistory = ClubHistory.builder() + .member(writer) + .title(new Title("oldTitle")) + .content(new Content("oldContent")) + .dateHistory(LocalDateTime.now()) + .build(); + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("title") + .content("content") + .dateHistory(LocalDateTime.now()) + .build(); + + //when + clubHistory.updateClubHistory(writer, saveClubHistoryDto); + + //then + assertThat(clubHistory) + .extracting(ClubHistory -> clubHistory.getTitle().getValue(), + ClubHistory -> clubHistory.getContent().getValue()) + .containsExactly(saveClubHistoryDto.getTitle(), saveClubHistoryDto.getContent()); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java new file mode 100644 index 00000000..7c6155d6 --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/ClubHistoryDtoTest.java @@ -0,0 +1,73 @@ +package com.inhabas.api.domain.club.dto; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import java.time.LocalDateTime; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +class ClubHistoryDtoTest { + + private static ValidatorFactory validatorFactory; + private static Validator validator; + + @BeforeAll + public static void init() { + validatorFactory = Validation.buildDefaultValidatorFactory(); + validator = validatorFactory.getValidator(); + } + + @AfterAll + public static void close() { + validatorFactory.close(); + } + + @DisplayName("Id, writerId 가 Positive 가 아니면 validation 실패") + @Test + void Positive_Test() { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .id(-1L) + .title("goodTitle") + .content("goodContent") + .writerId(-1L) + .dateHistory(LocalDateTime.now()) + .build(); + + //when + Set> violations = validator.validate(clubHistoryDto); + + //then + assertThat(violations).hasSize(2); + + } + + @DisplayName("Id, writerId, dateHistory 가 null 이면 validation 실패") + @Test + void NotNull_Test() { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .id(null) + .title("goodTitle") + .content("goodContent") + .writerId(null) + .dateHistory(null) + .build(); + + //when + Set> violations = validator.validate(clubHistoryDto); + + //then + assertThat(violations).hasSize(3); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java new file mode 100644 index 00000000..651c2d27 --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/dto/SaveClubHistoryDtoTest.java @@ -0,0 +1,50 @@ +package com.inhabas.api.domain.club.dto; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import java.util.Set; + +class SaveClubHistoryDtoTest { + + private static ValidatorFactory validatorFactory; + private static Validator validator; + + @BeforeAll + public static void init() { + validatorFactory = Validation.buildDefaultValidatorFactory(); + validator = validatorFactory.getValidator(); + } + + @AfterAll + public static void close() { + validatorFactory.close(); + } + + + @DisplayName("dateHistory 가 null 이면 validation 실패") + @Test + void NotNull_Test() { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("goodTitle") + .content("goodContent") + .dateHistory(null) + .build(); + + //when + Set> violations = validator.validate(saveClubHistoryDto); + + //then + Assertions.assertThat(violations.size()).isEqualTo(1); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java new file mode 100644 index 00000000..49ee9b42 --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImplTest.java @@ -0,0 +1,195 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.auth.domain.error.businessException.NotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member; +import com.inhabas.api.auth.domain.oauth2.member.domain.exception.MemberNotFoundException; +import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; +import com.inhabas.api.domain.board.domain.valueObject.Content; +import com.inhabas.api.domain.board.domain.valueObject.Title; +import com.inhabas.api.domain.club.domain.entity.ClubHistory; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.repository.ClubHistoryRepository; +import com.inhabas.api.domain.member.domain.entity.MemberTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.tuple; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; + +@ExtendWith(MockitoExtension.class) +public class ClubHistoryServiceImplTest { + + @InjectMocks + ClubHistoryServiceImpl clubHistoryService; + @Mock + ClubHistoryRepository clubHistoryRepository; + @Mock + MemberRepository memberRepository; + + + @DisplayName("동아리 연혁 생성 성공") + @Test + @Transactional + void writeClubHistory_Success() { + //given + Long memberId = 1L; + Member member = MemberTest.chiefMember(); // 필요한 속성으로 Member 객체 초기화 + SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( + "title", "content", LocalDateTime.now()); + + given(memberRepository.findById(memberId)).willReturn(Optional.of(member)); + given(clubHistoryRepository.save(any(ClubHistory.class))).willAnswer(invocation -> { + ClubHistory savedClubHistory = invocation.getArgument(0); + ReflectionTestUtils.setField(savedClubHistory, "id", 1L); + return savedClubHistory; + }); + + // when + Long resultId = clubHistoryService.writeClubHistory(memberId, saveClubHistoryDto); + + // then + then(memberRepository).should().findById(memberId); + then(clubHistoryRepository).should().save(any(ClubHistory.class)); + assertThat(resultId).isEqualTo(1L); + } + + @DisplayName("동아리 연혁 생성 작성자가 존재하지 않을 시 Member nof found") + @Test + void writeClubHistory_Member_Not_Found() { + //given + SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( + "title", "content", LocalDateTime.now()); + given(memberRepository.findById(any())).willReturn(Optional.empty()); + + // then + assertThatThrownBy(() -> clubHistoryService.writeClubHistory(1L, saveClubHistoryDto)) + .isInstanceOf(MemberNotFoundException.class) + .hasMessage("존재 하지 않는 유저입니다."); + + } + + @DisplayName("동아리 연혁 단일 조회 성공") + @Test + void findClubHistory_Success() { + //given + ClubHistory clubHistory = ClubHistory.builder() + .member(MemberTest.chiefMember()) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryRepository.findById(any())).willReturn(Optional.of(clubHistory)); + + //when + ClubHistoryDto clubHistoryDto = clubHistoryService.findClubHistory(any()); + + //then + then(clubHistoryRepository).should().findById(any()); + assertThat(clubHistoryDto).as("clubHistoryDto's title and content are equal to clubHistory") + .extracting("title", "content") + .containsExactly(clubHistory.getTitle().getValue(), clubHistory.getContent().getValue()); + + } + + @DisplayName("동아리 연혁 단일 조회 id가 존재하지 않으면 NOT_FOUND") + @Test + void findClubHistory_Not_Found() { + //given + given(clubHistoryRepository.findById(any())).willReturn(Optional.empty()); + + //then + assertThatThrownBy(() -> clubHistoryService.findClubHistory(any())) + .isInstanceOf(NotFoundException.class) + .hasMessage("데이터가 존재하지 않습니다."); + + } + + @DisplayName("동아리 연혁 조회 성공") + @Test + void getClubHistories_Success() { + //given + ClubHistory clubHistory = ClubHistory.builder() + .member(MemberTest.chiefMember()) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + List clubHistoryList = List.of(clubHistory); + given(clubHistoryRepository.findAll()).willReturn(clubHistoryList); + + //when + List clubHistoryDtoList = clubHistoryService.getClubHistories(); + + //then + then(clubHistoryRepository).should().findAll(); + assertThat(clubHistoryDtoList) + .hasSize(1) + .extracting("title", "content") + .contains(tuple(clubHistory.getTitle().getValue(), clubHistory.getContent().getValue())); + + } + + @DisplayName("동아리 연혁 수정 성공") + @Test + @Transactional + void updateClubHistory_Success() { + // given + Member member = MemberTest.chiefMember(); + ClubHistory clubHistory = ClubHistory.builder() + .member(member) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + SaveClubHistoryDto saveClubHistoryDto = new SaveClubHistoryDto( + "title", "content", LocalDateTime.now()); + given(clubHistoryRepository.findById(any())).willReturn(Optional.ofNullable(clubHistory)); + given(memberRepository.findById(any())).willReturn(Optional.of(member)); + + // when + clubHistoryService.updateClubHistory(1L, 1L, saveClubHistoryDto); + + // then + then(clubHistoryRepository).should().findById(any()); + then(memberRepository).should().findById(any()); + + } + + @DisplayName("동아리 연혁 삭제 성공") + @Test + @Transactional + void deleteClubHistories_Success() { + //given + ClubHistory clubHistory = ClubHistory.builder() + .member(MemberTest.chiefMember()) + .title(new Title("title")) + .content(new Content("content")) + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryRepository.findById(any())).willReturn(Optional.ofNullable(clubHistory)); + + //when + clubHistoryService.deleteClubHistory(any()); + + //then + then(clubHistoryRepository).should().findById(any()); + then(clubHistoryRepository).should().delete(any()); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentsTest.java b/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentTest.java similarity index 79% rename from resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentsTest.java rename to resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentTest.java index f9f293b3..47a29703 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentsTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/comment/domain/valueObject/CommentContentTest.java @@ -6,9 +6,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -public class CommentContentsTest { +public class CommentContentTest { - @DisplayName("Contents 타입에 내용을 저장한다.") + @DisplayName("Content 타입에 내용을 저장한다.") @Test public void Contents_is_saved_well() { //given @@ -21,7 +21,7 @@ public void Contents_is_saved_well() { assertThat(contents.getValue()).isEqualTo(contentsString); } - @DisplayName("Contents 타입에 너무 긴 내용을 입력한다. 500자 이상") + @DisplayName("Content 타입에 너무 긴 내용을 입력한다. 500자 이상") @Test public void Contents_is_too_long() { //given @@ -33,7 +33,7 @@ public void Contents_is_too_long() { ); } - @DisplayName("Contents 타입에 null 은 안된다.") + @DisplayName("Content 타입에 null 은 안된다.") @Test public void Contents_is_Null() { assertThrows(IllegalArgumentException.class, @@ -41,7 +41,7 @@ public void Contents_is_Null() { ); } - @DisplayName("Contents 타입에 공백댓글은 저장할 수 없다.") + @DisplayName("Content 타입에 공백댓글은 저장할 수 없다.") @Test public void Contents_is_Blank() { assertThrows(IllegalArgumentException.class, diff --git a/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java index 9853189e..3cf84c34 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/comment/repository/CommentRepositoryTest.java @@ -63,7 +63,7 @@ public class CommentRepositoryTest { // em.clear(); // // //then -// assertThat(saveComment.getContents()).isEqualTo("필력 좋다 쓴이야"); +// assertThat(saveComment.getContent()).isEqualTo("필력 좋다 쓴이야"); // assertThat(saveComment.getParentBoard().getId()).isEqualTo(normalBoard.getId()); // } // @@ -81,7 +81,7 @@ public class CommentRepositoryTest { // Comment savedReply = commentRepository.save(reply); // // //then -// assertThat(savedReply.getContents()).isEqualTo("익1 고마워"); +// assertThat(savedReply.getContent()).isEqualTo("익1 고마워"); // assertThat(savedReply.getParentBoard().getId()).isEqualTo(normalBoard.getId()); // assertThat(savedReply.getParentComment().getId()).isEqualTo(comment.getId()); // } @@ -121,19 +121,19 @@ public class CommentRepositoryTest { // assertThat(commentList.size()).isEqualTo(2); // 루트 댓글은 2 개이다. // // // 첫번째 루트 댓글 -// assertThat(commentList.get(0).getContents()).isEqualTo("1) 필력 좋다 쓴이야"); +// assertThat(commentList.get(0).getContent()).isEqualTo("1) 필력 좋다 쓴이야"); // // 첫번째 루트 댓글의 대댓글은 1개 // assertThat(commentList.get(0).getChildren()) // .hasSize(1) -// .extracting(CommentDetailDto::getContents) +// .extracting(CommentDetailDto::getContent) // .contains("1-1) 고마워"); // // // 두번째 루트 댓글 -// assertThat(commentList.get(1).getContents()).isEqualTo("2) 쓴이야 분발하자"); +// assertThat(commentList.get(1).getContent()).isEqualTo("2) 쓴이야 분발하자"); // // 두번째 루트 댓글의 대댓글은 2개 // assertThat(commentList.get(1).getChildren()) // .hasSize(2) -// .extracting(CommentDetailDto::getContents) +// .extracting(CommentDetailDto::getContent) // .containsExactly("2-1) 너 누구야?", "2-2) 나? 김첨지"); // } // @@ -189,12 +189,12 @@ public class CommentRepositoryTest { // // assertThat(all) // .hasSize(3) -// .extracting(Comment::getContents) -// .doesNotContain(reply_2.getContents()) +// .extracting(Comment::getContent) +// .doesNotContain(reply_2.getContent()) // .contains( -// comment.getContents(), -// reply_1.getContents(), -// reply_3.getContents() +// comment.getContent(), +// reply_1.getContent(), +// reply_3.getContent() // ); // // } diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java index 3bc5b1af..7d92d38f 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/SaveContestBoardDtoTest.java @@ -84,7 +84,7 @@ public void InputsAreExceededError() { //given SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto( "title".repeat(20) + ".", - "contents! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", + "content! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", "Assoc".repeat(20) + ".", "topic".repeat(100)+ ".", LocalDate.of(2022, 1, 1), @@ -109,7 +109,7 @@ public void InputsAreExceededError() { @Test public void DeadlineIsOutdatedError() { //given - SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "contents", "association", "topic", + SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 2, 1)); // when diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java index 109d6535..0e76c65e 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/dto/UpdateContestBoardDtoTest.java @@ -86,7 +86,7 @@ public void InputsAreExceededError() { UpdateContestBoardDto updateContestBoardDto = new UpdateContestBoardDto( 1, "title".repeat(20) + ".", - "contents! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", + "content! Cucumber paste has to have a sun-dried, chilled sauerkraut component.", "Assoc".repeat(20) + ".", "topic".repeat(100)+ ".", LocalDate.of(2022, 1, 1), diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java index 34b2e829..7a8c5cbb 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/repository/ContestBoardRepositoryTest.java @@ -69,7 +69,7 @@ public class ContestBoardRepositoryTest { // .id(savedContestBoard.getId()) // .writerName(writer.getName()) // .title(savedContestBoard.getTitle()) -// .contents(savedContestBoard.getContents()) +// .content(savedContestBoard.getContent()) // .association(savedContestBoard.getAssociation()) // .topic(savedContestBoard.getTopic()) // .start(savedContestBoard.getStart()) diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java index b62f92bf..77e76dd1 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contestBoard/usecase/ContestBoardServiceTest.java @@ -52,10 +52,10 @@ public void createContestBoard() { //given StudentId StudentId = new StudentId("12201863"); SaveContestBoardDto saveContestBoardDto = - new SaveContestBoardDto("title", "contents", "association", "topic", + new SaveContestBoardDto("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)); ContestBoard contestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)); given(contestBoardRepository.save(any())).willReturn(contestBoard); @@ -108,7 +108,7 @@ public void getContestBoardList() { public void getDetailBoard() { //given DetailContestBoardDto contestBoardDto = - new DetailContestBoardDto(1, "mingyeom", "title", "contents", + new DetailContestBoardDto(1, "mingyeom", "title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 29), LocalDateTime.now(), null); given(contestBoardRepository.findDtoById(any())).willReturn(Optional.of(contestBoardDto)); @@ -127,7 +127,7 @@ public void deleteContestBoard() { //given StudentId StudentId = new StudentId("12201863"); ContestBoard contestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(StudentId); given(contestBoardRepository.findById(anyInt())).willReturn(Optional.of(contestBoard)); @@ -146,7 +146,7 @@ public void updateContestBoard() { //given StudentId StudentId = new StudentId("12201863"); ContestBoard expectedContestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(StudentId); @@ -171,7 +171,7 @@ public void failToModifyTest() { StudentId badUser = new StudentId("44444444"); StudentId originalWriter = new StudentId("12201863"); ContestBoard expectedContestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(originalWriter); given(contestBoardRepository.findById(any())).willReturn(Optional.of(expectedContestBoard)); @@ -195,7 +195,7 @@ public void failToDeleteTest() { StudentId badUser = new StudentId("44444444"); StudentId StudentId = new StudentId("12201863"); ContestBoard contestBoard = - new ContestBoard("title", "contents", "association", "topic", + new ContestBoard("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1, 26)) .writtenBy(StudentId); given(contestBoardRepository.findById(anyInt())).willReturn(Optional.of(contestBoard)); diff --git a/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java b/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java index 99331dbb..659c66cb 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/signUp/usecase/SignUpServiceTest.java @@ -9,8 +9,8 @@ import com.inhabas.api.auth.domain.oauth2.member.repository.MemberRepository; import com.inhabas.api.auth.domain.oauth2.socialAccount.repository.MemberSocialAccountRepository; import com.inhabas.api.domain.questionnaire.usecase.QuestionnaireService; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteAnswersException; -import com.inhabas.api.domain.signUp.domain.exception.NotWriteProfileException; +import com.inhabas.api.domain.signUp.exception.NotWriteAnswersException; +import com.inhabas.api.domain.signUp.exception.NotWriteProfileException; import com.inhabas.api.domain.signUp.dto.AnswerDto; import com.inhabas.api.domain.signUp.dto.SignUpDto; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpScheduler; diff --git a/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java b/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java index a7bb449c..450f77ce 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/signUpSchedule/domain/entity/SignUpScheduleTest.java @@ -1,6 +1,6 @@ package com.inhabas.api.domain.signUpSchedule.domain.entity; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java index aa7d4351..24534c1d 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/BoardControllerTest.java @@ -57,7 +57,7 @@ public class BoardControllerTest { // @WithMockJwtAuthenticationToken // public void addNewBoard() throws Exception { // //given -// SaveBoardDto saveBoardDto = new SaveBoardDto("This is title", "This is contents", new MenuId(1)); +// SaveBoardDto saveBoardDto = new SaveBoardDto("This is title", "This is content", new MenuId(1)); // given(boardService.write(any(), any(SaveBoardDto.class))).willReturn(1); // // // when @@ -133,7 +133,7 @@ public void getBoardList() throws Exception { public void getBoardDetail() throws Exception{ //given BoardDto boardDto = - new BoardDto(1, "Shown Title", "Shown Contents", "Mingyeom", + new BoardDto(1, "Shown Title", "Shown Content", "Mingyeom", new MenuId(1), LocalDateTime.now(), null); given(boardService.getBoard(anyInt())).willReturn(boardDto); @@ -153,7 +153,7 @@ public void getBoardDetail() throws Exception{ // @WithMockJwtAuthenticationToken // public void TitleIsTooLongError() throws Exception { // //given -// SaveBoardDto saveBoardDto = new SaveBoardDto("title".repeat(20) + ".", "contents", new MenuId(1)); +// SaveBoardDto saveBoardDto = new SaveBoardDto("title".repeat(20) + ".", "content", new MenuId(1)); // // // when // String errorMessage = Objects.requireNonNull( diff --git a/resource-server/src/test/java/com/inhabas/api/web/ClubHistoryControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/ClubHistoryControllerTest.java new file mode 100644 index 00000000..68bdb4fd --- /dev/null +++ b/resource-server/src/test/java/com/inhabas/api/web/ClubHistoryControllerTest.java @@ -0,0 +1,306 @@ +package com.inhabas.api.web; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.inhabas.api.auth.domain.error.businessException.InvalidInputException; +import com.inhabas.api.auth.domain.error.businessException.NotFoundException; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.usecase.ClubHistoryService; +import com.inhabas.testAnnotataion.NoSecureWebMvcTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; +import java.util.List; + +import static com.inhabas.api.auth.domain.error.ErrorCode.INVALID_INPUT_VALUE; +import static com.inhabas.api.auth.domain.error.ErrorCode.NOT_FOUND; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@NoSecureWebMvcTest(ClubHistoryController.class) +public class ClubHistoryControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private ObjectMapper objectMapper; + + @MockBean + private ClubHistoryService clubHistoryService; + + + private String jsonOf(Object response) throws JsonProcessingException { + return objectMapper.writeValueAsString(response); + } + + @DisplayName("동아리 연혁 조회 성공 200") + @Test + void getClubHistories() throws Exception { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .title("title") + .content("content") + .dateHistory(LocalDateTime.now()) + .build(); + List clubHistoryList = List.of(clubHistoryDto); + given(clubHistoryService.getClubHistories()).willReturn(clubHistoryList); + + //when + String response = mvc.perform(get("/club/histories")) + .andExpect(status().isOk()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).isEqualTo(jsonOf(clubHistoryList)); + + } + + @DisplayName("동아리 연혁 단일 조회 성공 200") + @Test + void findClubHistory() throws Exception { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .title("title") + .content("content") + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryService.findClubHistory(any())).willReturn(clubHistoryDto); + + //when + String response = mvc.perform(get("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isOk()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).isEqualTo(jsonOf(clubHistoryDto)); + + } + + @DisplayName("동아리 연혁 단일 조회 데이터가 올바르지 않다면 400") + @Test + void findClubHistory_Invalid_Input() throws Exception { + //given + ClubHistoryDto clubHistoryDto = ClubHistoryDto.builder() + .title("title") + .content("content") + .dateHistory(LocalDateTime.now()) + .build(); + given(clubHistoryService.findClubHistory(any())).willReturn(clubHistoryDto); + + //when + String response = mvc.perform(get("/club/history/{clubHistoryId}", "invalid")) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + @DisplayName("동아리 연혁 단일 조회 해당 id가 없다면 404") + @Test + void findClubHistory_Not_Found() throws Exception { + //given + doThrow(NotFoundException.class).when(clubHistoryService).findClubHistory(any()); + + //when + String response = mvc.perform(get("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isNotFound()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(NOT_FOUND.getMessage()); + + } + + @DisplayName("동아리 연혁 생성 성공 200") + @Test + void writeClubHistories() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("good title") + .content("good content") + .dateHistory(LocalDateTime.parse("2023-11-01T00:00:00")) + .build(); + given(clubHistoryService.writeClubHistory(any(), any())).willReturn(1L); + + //when + String header = mvc.perform(post("/club/history") + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getHeader("Location"); + + //then + System.out.println("header is " + header); + assertThat(header).contains("/club/history/1"); + + } + + @DisplayName("동아리 연혁 생성 데이터가 올바르지 않다면 400") + @Test + void writeClubHistories_Invalid_Input() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doThrow(InvalidInputException.class).when(clubHistoryService).writeClubHistory(any(), any()); + + //when + String response = mvc.perform(post("/club/history") + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + + @DisplayName("동아리 연혁 수정 성공 204") + @Test + void updateClubHistory() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doNothing().when(clubHistoryService).updateClubHistory(any(), any(), any()); + + //when then + mvc.perform(put("/club/history/{clubHistoryId}", 1) + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isNoContent()); + + } + + @DisplayName("동아리 연혁 수정 데이터가 올바르지 않다면 400") + @Test + void updateClubHistory_Invalid_Input() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doThrow(InvalidInputException.class).when(clubHistoryService).updateClubHistory(any(), any(), any()); + + //when + String response = mvc.perform(put("/club/history/{clubHistoryId}", 1L) + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + @DisplayName("동아리 연혁 수정 해당 id가 존재하지 않다면 404") + @Test + void updateClubHistory_Not_Found() throws Exception { + //given + SaveClubHistoryDto saveClubHistoryDto = SaveClubHistoryDto.builder() + .title("meaningless") + .content("meaningless") + .dateHistory(LocalDateTime.now()) + .build(); + doThrow(NotFoundException.class).when(clubHistoryService).updateClubHistory(any(), any(), any()); + + //when + String response = mvc.perform(put("/club/history/{clubHistoryId}", 1L) + .contentType(MediaType.APPLICATION_JSON) + .content(jsonOf(saveClubHistoryDto))) + .andExpect(status().isNotFound()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(NOT_FOUND.getMessage()); + + } + + @DisplayName("동아리 연혁 삭제 성공 204") + @Test + void deleteClubHistory() throws Exception { + //given + doNothing().when(clubHistoryService).deleteClubHistory(any()); + + //when then + mvc.perform(delete("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isNoContent()); + + } + + @DisplayName("동아리 연혁 삭제 데이터가 올바르지 않다면 400") + @Test + void deleteClubHistory_Invalid_Input() throws Exception { + //given + doNothing().when(clubHistoryService).deleteClubHistory(any()); + + //when + String response = mvc.perform(delete("/club/history/{clubHistoryId}", "invalid")) + .andExpect(status().isBadRequest()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(INVALID_INPUT_VALUE.getMessage()); + + } + + @DisplayName("동아리 연혁 삭제 해당 id가 없다면 404") + @Test + void deleteClubHistory_Not_Found() throws Exception { + //given + doThrow(NotFoundException.class).when(clubHistoryService).deleteClubHistory(any()); + + //when + String response = mvc.perform(delete("/club/history/{clubHistoryId}", 1L)) + .andExpect(status().isNotFound()) + .andReturn() + .getResponse() + .getContentAsString(StandardCharsets.UTF_8); + + //then + assertThat(response).contains(NOT_FOUND.getMessage()); + + } + +} \ No newline at end of file diff --git a/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java index 59147d0f..f0b1fdcb 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/CommentControllerTest.java @@ -76,7 +76,7 @@ void getCommentList() throws Exception { // @Test // void createNewComment() throws Exception { // //given -// String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"boardId\":13}"; +// String jsonRequest = "{\"writerId\":12171652,\"content\":\"아싸 1등\",\"boardId\":13}"; // Integer newCommentId = 1; // given(commentService.create(any(), any())).willReturn(newCommentId); // @@ -97,7 +97,7 @@ void getCommentList() throws Exception { // @Test // void createNewReply() throws Exception { // //given -// String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"boardId\":13, \"parentCommentId\":1}"; +// String jsonRequest = "{\"writerId\":12171652,\"content\":\"아싸 1등\",\"boardId\":13, \"parentCommentId\":1}"; // Integer newReplyId = 2; // given(commentService.create(any(), any())).willReturn(newReplyId); // @@ -114,29 +114,29 @@ void getCommentList() throws Exception { // assertThat(responseBody).isEqualTo(String.valueOf(newReplyId)); // } - @DisplayName("500자 이상의 댓글 추가 요청은 유효성 검사 실패 후 400 반환") - @Test - void tryToSaveTooLongContents() throws Exception { - //given - String tooLongContents = "-".repeat(500); - String jsonRequest = String.format("{\"writerId\":12171652,\"contents\":\"%s\",\"boardId\":13}", tooLongContents); - - //when - String errorMessage = mockMvc.perform(post("/comment") - .contentType(MediaType.APPLICATION_JSON) - .content(jsonRequest)) - .andExpect(status().isBadRequest()) - .andReturn() - .getResponse().getContentAsString(); - - assertThat(errorMessage).contains("500자 이하여야 합니다."); - } +// @DisplayName("500자 이상의 댓글 추가 요청은 유효성 검사 실패 후 400 반환") +// @Test +// void tryToSaveTooLongContents() throws Exception { +// //given +// String tooLongContents = "-".repeat(500); +// String jsonRequest = String.format("{\"writerId\":12171652,\"content\":\"%s\",\"boardId\":13}", tooLongContents); +// +// //when +// String errorMessage = mockMvc.perform(post("/comment") +// .contentType(MediaType.APPLICATION_JSON) +// .content(jsonRequest)) +// .andExpect(status().isBadRequest()) +// .andReturn() +// .getResponse().getContentAsString(); +// +// assertThat(errorMessage).contains("500자 이하여야 합니다."); +// } // @DisplayName("정상적인 댓글 수정 요청") // @Test // void updateComment() throws Exception { // //given -// String jsonRequest = "{\"commentId\":1, \"writerId\":12171652,\"contents\":\"1등이 아니네,,,\",\"boardId\":12}"; +// String jsonRequest = "{\"commentId\":1, \"writerId\":12171652,\"content\":\"1등이 아니네,,,\",\"boardId\":12}"; // given(commentService.update(any(), any())).willReturn(1); // // String responseBody = mockMvc.perform(put("/comment") diff --git a/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java index a60b1de2..9c5e3afe 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/ContestBoardControllerTest.java @@ -54,7 +54,7 @@ public class ContestBoardControllerTest { // @WithMockJwtAuthenticationToken // public void addNewContestBoard() throws Exception { // //given -// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "contents", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(9022, 3, 26)); +// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(9022, 3, 26)); // given(contestBoardService.write(any(), any(SaveContestBoardDto.class))).willReturn(1); // // // when @@ -126,7 +126,7 @@ public void getContestBoardList() throws Exception { @Test public void getContestBoardDetail() throws Exception{ //given - DetailContestBoardDto contestBoardDto = new DetailContestBoardDto(1, "mingyeom", "title", "contents", "association","topic", LocalDate.of(2022,1,1), LocalDate.of(2022, 1, 29), LocalDateTime.now(), null); + DetailContestBoardDto contestBoardDto = new DetailContestBoardDto(1, "mingyeom", "title", "content", "association","topic", LocalDate.of(2022,1,1), LocalDate.of(2022, 1, 29), LocalDateTime.now(), null); given(contestBoardService.getBoard(anyInt())).willReturn(contestBoardDto); // when @@ -145,7 +145,7 @@ public void getContestBoardDetail() throws Exception{ // @WithMockJwtAuthenticationToken // public void TitleIsTooLongError() throws Exception { // //given -// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title".repeat(20)+ ".", "contents", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1,26)); +// SaveContestBoardDto saveContestBoardDto = new SaveContestBoardDto("title".repeat(20)+ ".", "content", "association", "topic", LocalDate.of(2022, 1, 1), LocalDate.of(2022, 1,26)); // // // // when diff --git a/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java b/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java index 03934291..af39d64f 100644 --- a/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java +++ b/resource-server/src/test/java/com/inhabas/api/web/SignUpScheduleControllerTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.inhabas.api.auth.domain.error.ErrorCode; -import com.inhabas.api.domain.signUpSchedule.domain.exception.InvalidDateException; +import com.inhabas.api.domain.signUpSchedule.exception.InvalidDateException; import com.inhabas.api.domain.signUpSchedule.dto.SignUpScheduleDto; import com.inhabas.api.domain.signUpSchedule.usecase.SignUpScheduler; import com.inhabas.testAnnotataion.NoSecureWebMvcTest;