This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from f-lab-edu/feature/14
#30 feature/14
- Loading branch information
Showing
2 changed files
with
65 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.delfood.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.delfood.dto.OwnerDTO; | ||
import com.delfood.mapper.OwnerMapper; | ||
import com.delfood.utils.SHA256Util; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class OwnerServiceTest { | ||
|
||
@InjectMocks // 의존성 주입이 필요한 mock에 설정, @Mock으로 등록된 객체를 주입시켜준다. | ||
OwnerService service; | ||
|
||
@Mock // mock 생성 | ||
OwnerMapper mapper; | ||
|
||
/** | ||
* 회원가입 성공 테스트. | ||
*/ | ||
@Test | ||
public void signUp_success() { | ||
OwnerDTO ownerInfo = OwnerDTO.builder() | ||
.id("ljy2134") | ||
.password(SHA256Util.encryptSHA256("2134")) | ||
.name("이진영") | ||
.mail("[email protected]") | ||
.tel("010-3333-3333") | ||
.build(); | ||
|
||
given(mapper.insertOwner(ownerInfo)).willReturn(1); | ||
service.signUp(ownerInfo); | ||
} | ||
|
||
/** | ||
* 회원가입 실패 테스트. | ||
*/ | ||
@Test(expected = RuntimeException.class) | ||
public void signUp_fail() { | ||
OwnerDTO ownerInfo = OwnerDTO.builder() | ||
.id("ljy2134") | ||
.password(SHA256Util.encryptSHA256("2134")) | ||
.name("이진영") | ||
.mail("[email protected]") | ||
.tel("010-3333-3333") | ||
.build(); | ||
|
||
given(mapper.insertOwner(ownerInfo)).willReturn(0); | ||
service.signUp(ownerInfo); | ||
} | ||
|
||
} |