Skip to content

Commit

Permalink
Test : Activity 생성 테스트를 위한 FakeRepository 및 테스트 코드 추가
Browse files Browse the repository at this point in the history
- 활동 Repository 를 분리하여 FakeActivityRepository를 작성
- FakeActivityRepository를 활용한 Activity 생성 로직의 단위 테스트 코드 작성
  • Loading branch information
hyeonda02 committed Dec 27, 2024
1 parent e8fdc67 commit 0c18ca5
Show file tree
Hide file tree
Showing 41 changed files with 882 additions and 123 deletions.
4 changes: 2 additions & 2 deletions src/main/java/umc/kkijuk/server/career/domain/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public void setSummary(String summary) {

@Builder
public Activity(Long memberId, String name, String alias, Boolean unknown,
LocalDate startdate, LocalDate enddate, String organizer,
LocalDate startDate, LocalDate endDate, String organizer,
String role, int teamSize, int contribution,
Boolean isTeam) {
super(memberId, name, alias, unknown, startdate, enddate);
super(memberId, name, alias, unknown, startDate, endDate);
this.organizer = organizer;
this.role = role;
this.teamSize = teamSize;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/umc/kkijuk/server/career/domain/CareerEtc.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import jakarta.persistence.*;
import lombok.*;
import umc.kkijuk.server.detail.domain.BaseCareerDetail;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static Activity toAvtivity(Member requestMember, ActivityReqDto activityR
.name(activityReqDto.getName())
.alias(activityReqDto.getAlias())
.unknown(activityReqDto.getUnknown())
.startdate(activityReqDto.getStartdate())
.enddate(activityReqDto.getEnddate())
.startDate(activityReqDto.getStartdate())
.endDate(activityReqDto.getEnddate())
.organizer(activityReqDto.getOrganizer())
.role(activityReqDto.getRole())
.contribution(activityReqDto.getContribution())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.Activity;

import java.util.List;

public interface ActivityJpaRepository extends JpaRepository<Activity, Long> {
List<Activity> findByMemberId(Long memberId);
List<Activity> findByMemberIdAndNameContaining(Long memberId, String keyword);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.Activity;

import java.util.List;
import java.util.Optional;

public interface ActivityRepository extends JpaRepository<Activity, Long> {
public interface ActivityRepository {
List<Activity> findByMemberId(Long memberId);
List<Activity> findByMemberIdAndNameContaining(Long memberId, String keyword);
Activity save(Activity activity);

Optional<Activity> findById(Long activityId);

void delete(Activity activity);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package umc.kkijuk.server.career.repository;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import umc.kkijuk.server.career.domain.Activity;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class ActivityRepositoryImpl implements ActivityRepository{
private final ActivityJpaRepository activityJpaRepository;
@Override
public List<Activity> findByMemberId(Long memberId) {
return activityJpaRepository.findByMemberId(memberId);
}
@Override
public List<Activity> findByMemberIdAndNameContaining(Long memberId, String keyword) {
return activityJpaRepository.findByMemberIdAndNameContaining(memberId,keyword);
}
@Override
public Activity save(Activity activity) {
return activityJpaRepository.save(activity);
}
@Override
public Optional<Activity> findById(Long activityId) {
return activityJpaRepository.findById(activityId);
}

@Override
public void delete(Activity activity) {
activityJpaRepository.delete(activity);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.CareerEtc;

import java.util.List;

public interface CareerEtcJpaRepository extends JpaRepository<CareerEtc,Long> {
List<CareerEtc> findByMemberId(Long memberId);

List<CareerEtc> findByMemberIdAndNameContaining(Long id, String keyword);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.CareerEtc;

import java.util.List;
import java.util.Optional;

public interface CareerEtcRepository extends JpaRepository<CareerEtc,Long> {
public interface CareerEtcRepository {
List<CareerEtc> findByMemberId(Long memberId);

List<CareerEtc> findByMemberIdAndNameContaining(Long id, String keyword);

CareerEtc save(CareerEtc etc);

Optional<CareerEtc> findById(Long etcId);

void delete(CareerEtc etc);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package umc.kkijuk.server.career.repository;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import umc.kkijuk.server.career.domain.CareerEtc;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class CareerEtcRepositoryImpl implements CareerEtcRepository{
private final CareerEtcJpaRepository careerEtcJpaRepository;
@Override
public List<CareerEtc> findByMemberId(Long memberId) {
return careerEtcJpaRepository.findByMemberId(memberId);
}

@Override
public List<CareerEtc> findByMemberIdAndNameContaining(Long id, String keyword) {
return careerEtcJpaRepository.findByMemberIdAndNameContaining(id, keyword);
}
@Override
public CareerEtc save(CareerEtc etc) {
return careerEtcJpaRepository.save(etc);
}
@Override
public Optional<CareerEtc> findById(Long etcId) {
return careerEtcJpaRepository.findById(etcId);
}
@Override
public void delete(CareerEtc etc) {
careerEtcJpaRepository.delete(etc);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.Circle;

import java.util.List;

public interface CircleJpaRepository extends JpaRepository<Circle, Long> {
List<Circle> findByMemberId(Long memberId);
List<Circle> findByMemberIdAndNameContaining(Long memberId, String keyword);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.Circle;

import java.util.List;
import java.util.Optional;

public interface CircleRepository extends JpaRepository<Circle, Long> {
public interface CircleRepository {
List<Circle> findByMemberId(Long memberId);
List<Circle> findByMemberIdAndNameContaining(Long memberId, String keyword);

Circle save(Circle circle);

Optional<Circle> findById(Long circleId);

void delete(Circle circle);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package umc.kkijuk.server.career.repository;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import umc.kkijuk.server.career.domain.Circle;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class CircleRepositoryImpl implements CircleRepository{
private final CircleJpaRepository circleJpaRepository;
@Override
public List<Circle> findByMemberId(Long memberId) {
return circleJpaRepository.findByMemberId(memberId);
}

@Override
public List<Circle> findByMemberIdAndNameContaining(Long memberId, String keyword) {
return circleJpaRepository.findByMemberIdAndNameContaining(memberId,keyword);
}

@Override
public Circle save(Circle circle) {
return circleJpaRepository.save(circle);
}

@Override
public Optional<Circle> findById(Long circleId) {
return circleJpaRepository.findById(circleId);
}

@Override
public void delete(Circle circle) {
circleJpaRepository.delete(circle);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.Competition;

import java.util.List;

public interface CompetitionJpaRepository extends JpaRepository<Competition, Long> {
List<Competition> findByMemberId(Long memberId);
List<Competition> findByMemberIdAndNameContaining(Long memberId, String keyword);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.Competition;

import java.util.List;
import java.util.Optional;

public interface CompetitionRepository extends JpaRepository<Competition, Long> {
public interface CompetitionRepository {
List<Competition> findByMemberId(Long memberId);
List<Competition> findByMemberIdAndNameContaining(Long memberId, String keyword);

Competition save(Competition competition);

Optional<Competition> findById(Long competitionId);

void delete(Competition comp);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package umc.kkijuk.server.career.repository;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import umc.kkijuk.server.career.domain.Competition;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class CompetitionRepositoryImpl implements CompetitionRepository{
private final CompetitionJpaRepository competitionJpaRepository;
@Override
public List<Competition> findByMemberId(Long memberId) {
return competitionJpaRepository.findByMemberId(memberId);
}
@Override
public List<Competition> findByMemberIdAndNameContaining(Long memberId, String keyword) {
return competitionJpaRepository.findByMemberIdAndNameContaining(memberId,keyword);
}

@Override
public Competition save(Competition competition) {
return competitionJpaRepository.save(competition);
}

@Override
public Optional<Competition> findById(Long competitionId) {
return competitionJpaRepository.findById(competitionId);
}

@Override
public void delete(Competition comp) {
competitionJpaRepository.delete(comp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.EduCareer;

import java.util.List;

public interface EduCareerJpaRepository extends JpaRepository<EduCareer,Long> {
List<EduCareer> findByMemberId(Long memberId);
List<EduCareer> findByMemberIdAndNameContaining(Long memberId, String keyword);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.EduCareer;

import java.util.List;
import java.util.Optional;

public interface EduCareerRepository extends JpaRepository<EduCareer,Long> {
public interface EduCareerRepository {
List<EduCareer> findByMemberId(Long memberId);
List<EduCareer> findByMemberIdAndNameContaining(Long memberId, String keyword);

EduCareer save(EduCareer edu);

Optional<EduCareer> findById(Long educareerId);

void delete(EduCareer eduCareer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package umc.kkijuk.server.career.repository;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import umc.kkijuk.server.career.domain.EduCareer;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class EduCareerRepositoryImpl implements EduCareerRepository{
private final EduCareerJpaRepository eduCareerJpaRepository;
@Override
public List<EduCareer> findByMemberId(Long memberId) {
return eduCareerJpaRepository.findByMemberId(memberId);
}

@Override
public List<EduCareer> findByMemberIdAndNameContaining(Long memberId, String keyword) {
return eduCareerJpaRepository.findByMemberIdAndNameContaining(memberId,keyword);
}

@Override
public EduCareer save(EduCareer edu) {
return eduCareerJpaRepository.save(edu);
}

@Override
public Optional<EduCareer> findById(Long educareerId) {
return eduCareerJpaRepository.findById(educareerId);
}

@Override
public void delete(EduCareer eduCareer) {
eduCareerJpaRepository.delete(eduCareer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package umc.kkijuk.server.career.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.career.domain.Employment;

import java.util.List;

public interface EmploymentJpaRepository extends JpaRepository<Employment,Long> {
List<Employment> findByMemberId(Long memberId);
List<Employment> findByMemberIdAndNameContaining(Long memberId, String keyword);
}
Loading

0 comments on commit 0c18ca5

Please sign in to comment.