-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test : 호스트 테스트 최적화 * test : 호스트 유저 테스트 작성 * test : HostRole 테스트 작성 * test : Host vo 테스트 수정
- Loading branch information
Showing
8 changed files
with
150 additions
and
23 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
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
42 changes: 42 additions & 0 deletions
42
DuDoong-Domain/src/test/java/band/gosrock/domain/domains/host/domain/HostProfileTest.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,42 @@ | ||
package band.gosrock.domain.domains.host.domain; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class HostProfileTest { | ||
|
||
@Mock Host host; | ||
|
||
HostProfile hostProfile; | ||
|
||
@BeforeEach | ||
void setup() { | ||
hostProfile = HostProfile.builder().build(); | ||
} | ||
|
||
@Test | ||
void 호스트_프로필_업데이트_테스트() { | ||
// given | ||
final HostProfile newHostProfile = | ||
HostProfile.builder() | ||
.name("테스트") | ||
.contactEmail("[email protected]") | ||
.contactNumber("010-0000-0000") | ||
.introduce("123") | ||
.profileImageKey("key") | ||
.build(); | ||
// when | ||
hostProfile.updateProfile(newHostProfile); | ||
// then | ||
assertEquals(hostProfile.getProfileImage(), newHostProfile.getProfileImage()); | ||
assertEquals(hostProfile.getContactEmail(), newHostProfile.getContactEmail()); | ||
assertEquals(hostProfile.getContactNumber(), newHostProfile.getContactNumber()); | ||
assertEquals(hostProfile.getIntroduce(), newHostProfile.getIntroduce()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
DuDoong-Domain/src/test/java/band/gosrock/domain/domains/host/domain/HostRoleTest.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,24 @@ | ||
package band.gosrock.domain.domains.host.domain; | ||
|
||
import static band.gosrock.domain.domains.host.domain.HostRole.*; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class HostRoleTest { | ||
|
||
@Test | ||
void ENUM_값에_해당하지_않으면_NULL_반환해야한다() { | ||
// given | ||
// when | ||
// then | ||
assertEquals(HostRole.fromHostRole("MASTER"), MASTER); | ||
assertEquals(HostRole.fromHostRole("MANAGER"), MANAGER); | ||
assertEquals(HostRole.fromHostRole("GUEST"), GUEST); | ||
assertNull(HostRole.fromHostRole("NOT_PROVIDED")); | ||
} | ||
} |
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
54 changes: 54 additions & 0 deletions
54
DuDoong-Domain/src/test/java/band/gosrock/domain/domains/host/domain/HostUserTest.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,54 @@ | ||
package band.gosrock.domain.domains.host.domain; | ||
|
||
import static band.gosrock.domain.domains.host.domain.HostRole.MANAGER; | ||
import static band.gosrock.domain.domains.host.domain.HostRole.MASTER; | ||
import static java.lang.Boolean.TRUE; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import band.gosrock.domain.domains.host.exception.AlreadyJoinedHostException; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class HostUserTest { | ||
|
||
@Mock Host host; | ||
HostUser hostUser; | ||
|
||
@BeforeEach | ||
void setup() { | ||
hostUser = HostUser.builder().host(host).role(MASTER).build(); | ||
} | ||
|
||
@Test | ||
void 호스트유저_권한변경_테스트() { | ||
// given | ||
final HostRole role = MANAGER; | ||
// when | ||
hostUser.setHostRole(role); | ||
// then | ||
assertEquals(hostUser.getRole(), role); | ||
} | ||
|
||
@Test | ||
void 호스트유저_초대수락으로_활성화_테스트() { | ||
// given | ||
// when | ||
hostUser.activate(); | ||
// then | ||
assertEquals(hostUser.getActive(), TRUE); | ||
} | ||
|
||
@Test | ||
void 호스트유저_초대_중복수락은_불가능하다() { | ||
// given | ||
// when | ||
hostUser.activate(); | ||
// then | ||
assertThrows(AlreadyJoinedHostException.class, () -> hostUser.activate()); | ||
} | ||
} |