-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
BE/exceed/src/test/java/com/gaebaljip/exceed/member/UpdateWeightIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.gaebaljip.exceed.member; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
|
||
import com.gaebaljip.exceed.common.IntegrationTest; | ||
import com.gaebaljip.exceed.common.WithMockUser; | ||
import com.gaebaljip.exceed.dto.request.UpdateWeightRequest; | ||
import com.gaebaljip.exceed.member.adapter.out.persistence.MemberEntity; | ||
import com.gaebaljip.exceed.member.adapter.out.persistence.MemberRepository; | ||
|
||
public class UpdateWeightIntegrationTest extends IntegrationTest { | ||
@Autowired private MemberRepository memberRepository; | ||
|
||
@Test | ||
@DisplayName("몸무게 수정 성공") | ||
@WithMockUser(memberId = 1L) | ||
void when_updateWeight_expected_success() throws Exception { | ||
// given | ||
Long memberId = 1L; | ||
UpdateWeightRequest updateWeightRequest = | ||
UpdateWeightRequest.builder().weight(50.0).targetWeight(70.5).build(); | ||
|
||
// when | ||
ResultActions resultActions = | ||
mockMvc.perform( | ||
patch("/v1/members/weight") | ||
.content(om.writeValueAsString(updateWeightRequest)) | ||
.contentType(MediaType.APPLICATION_JSON)); | ||
MemberEntity member = memberRepository.findById(memberId).get(); | ||
|
||
// then | ||
resultActions.andExpectAll(status().isOk()); | ||
assertAll( | ||
() -> assertEquals(updateWeightRequest.weight(), member.getWeight()), | ||
() -> assertEquals(updateWeightRequest.targetWeight(), member.getTargetWeight())); | ||
} | ||
} |