Skip to content

Commit

Permalink
test: ExerciseProfile jpa 테스트 작성
Browse files Browse the repository at this point in the history
- ExerciseProfile jpa 테스트 작성
  • Loading branch information
devholic22 committed Oct 5, 2024
1 parent 3e7784b commit 2caeeb8
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.flab.eattofit.profile.infrastructure.exerciseprofile;

import com.flab.eattofit.profile.domain.exerciseprofile.ExerciseProfile;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;

import static org.assertj.core.api.Assertions.assertThat;

@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
@SuppressWarnings("NonAsciiCharacters")
@DataJpaTest
class ExerciseProfileJpaRepositoryTest {

@Autowired
private ExerciseProfileJpaRepository exerciseProfileJpaRepository;

@Test
void 회원_운동_정보_프로필을_저장한다() {
// given
Long memberId = 1L;
ExerciseProfile exerciseProfile = ExerciseProfile.createWith("처음", "주 1회", "근비대", "초보자", memberId);

// when
ExerciseProfile savedProfile = exerciseProfileJpaRepository.save(exerciseProfile);

// then
assertThat(savedProfile).usingRecursiveComparison()
.ignoringFields("id")
.isEqualTo(exerciseProfile);
}

@Test
void 회원_운동_정보_프로필이_저장되면_회원_id_조회__존재한다() {
// given
Long memberId = 1L;
ExerciseProfile exerciseProfile = ExerciseProfile.createWith("처음", "주 1회", "근비대", "초보자", memberId);
exerciseProfileJpaRepository.save(exerciseProfile);

// when
boolean find = exerciseProfileJpaRepository.existsByMemberId(memberId);

// then
assertThat(find).isTrue();
}
}

0 comments on commit 2caeeb8

Please sign in to comment.