-
Notifications
You must be signed in to change notification settings - Fork 3
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
11 changed files
with
432 additions
and
226 deletions.
There are no files selected for viewing
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
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
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
120 changes: 120 additions & 0 deletions
120
animory/src/test/java/com/daggle/animory/acceptance/AccountTest.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,120 @@ | ||
package com.daggle.animory.acceptance; | ||
|
||
import com.daggle.animory.domain.account.dto.request.AccountLoginDto; | ||
import com.daggle.animory.domain.account.dto.request.EmailValidateDto; | ||
import com.daggle.animory.domain.account.dto.request.ShelterAddressSignUpDto; | ||
import com.daggle.animory.domain.account.dto.request.ShelterSignUpDto; | ||
import com.daggle.animory.domain.shelter.entity.Province; | ||
import com.daggle.animory.testutil.AcceptanceTest; | ||
import com.daggle.animory.testutil.fixture.AccountFixture; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.MediaType; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
|
||
class AccountTest extends AcceptanceTest { | ||
|
||
private final String EMAIL = AccountFixture.EMAIL; | ||
private final String PASSWORD = AccountFixture.PASSWORD; | ||
|
||
@Test | ||
void 이메일_중복_검사() throws Exception { | ||
final EmailValidateDto emailValidateDto = new EmailValidateDto(EMAIL + "1"); | ||
|
||
result = mvc.perform(post("/account/email") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(om.writeValueAsString(emailValidateDto))); | ||
|
||
assertSuccess(); | ||
} | ||
|
||
@Test | ||
void 보호소_회원가입() throws Exception { | ||
final ShelterSignUpDto shelterSignUpDto = ShelterSignUpDto.builder() | ||
.email(EMAIL + "1") | ||
.password(PASSWORD) | ||
.name("테스트 보호소") | ||
.address( | ||
ShelterAddressSignUpDto.builder() | ||
.province(Province.광주) | ||
.city("무슨무슨구") | ||
.roadName("무슨무슨로") | ||
.detail("상세주소 1234-56") | ||
.build() | ||
) | ||
.contact("010-1234-5678") | ||
.build(); | ||
|
||
|
||
result = mvc.perform(post("/account/shelter") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(om.writeValueAsString(shelterSignUpDto))); | ||
|
||
assertSuccess(); | ||
} | ||
|
||
@Test | ||
void 중복된_이메일로_회원가입_불가() throws Exception { | ||
final ShelterSignUpDto shelterSignUpDto = ShelterSignUpDto.builder() | ||
.email(EMAIL) | ||
.password(PASSWORD) | ||
.name("테스트 보호소") | ||
.address( | ||
ShelterAddressSignUpDto.builder() | ||
.province(Province.광주) | ||
.city("무슨무슨구") | ||
.roadName("무슨무슨로") | ||
.detail("상세주소 1234-56") | ||
.build() | ||
) | ||
.contact("010-1234-5678") | ||
.build(); | ||
|
||
|
||
result = mvc.perform(post("/account/shelter") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(om.writeValueAsString(shelterSignUpDto))) | ||
.andExpect(status().isBadRequest()) | ||
.andExpect(jsonPath("$.success").value(false)); | ||
} | ||
|
||
@Test | ||
void 보호소_로그인() throws Exception { | ||
final AccountLoginDto accountLoginDto = AccountLoginDto.builder() | ||
.email(EMAIL) | ||
.password(PASSWORD) | ||
.build(); | ||
|
||
result = mvc.perform(post("/account/login") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(om.writeValueAsString(accountLoginDto))); | ||
|
||
assertSuccess(); | ||
|
||
// header authorization field exists | ||
assertThat( result.andReturn() | ||
.getResponse() | ||
.getHeader("Authorization") ).isNotNull(); | ||
} | ||
|
||
@Test | ||
void 존재하지_않는_계정으로_로그인_실패와_안내문구() throws Exception { | ||
final AccountLoginDto accountLoginDto = AccountLoginDto.builder() | ||
.email(EMAIL + "1") | ||
.password(PASSWORD) | ||
.build(); | ||
|
||
result = mvc.perform(post("/account/login") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(om.writeValueAsString(accountLoginDto))) | ||
.andExpect(status().isBadRequest()) | ||
.andExpect(jsonPath("$.success").value(false)) | ||
.andExpect(jsonPath("$.error.message").value("이메일 또는 비밀번호를 확인해주세요.")); | ||
|
||
} | ||
|
||
} |
206 changes: 0 additions & 206 deletions
206
animory/src/test/java/com/daggle/animory/acceptance/AnimoryAcceptanceTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.