This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7c5df29
commit 8b81372
Showing
16 changed files
with
266 additions
and
11 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
3 changes: 3 additions & 0 deletions
3
...ation/src/main/kotlin/com/studentcenter/weave/application/port/outbound/UserRepository.kt
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package com.studentcenter.weave.application.port.outbound | ||
|
||
import com.studentcenter.weave.domain.entity.User | ||
import java.util.* | ||
|
||
interface UserRepository { | ||
|
||
fun save(user: User) | ||
|
||
fun getById(id: UUID): User | ||
|
||
} |
31 changes: 28 additions & 3 deletions
31
...com/studentcenter/weave/application/service/application/UserRegisterApplicationService.kt
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
7 changes: 7 additions & 0 deletions
7
...in/kotlin/com/studentcenter/weave/application/service/domain/UserAuthInfoDomainService.kt
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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package com.studentcenter.weave.application.service.domain | ||
|
||
import com.studentcenter.weave.domain.entity.User | ||
import com.studentcenter.weave.domain.entity.UserAuthInfo | ||
import com.studentcenter.weave.domain.enum.SocialLoginProvider | ||
import com.studentcenter.weave.support.common.vo.Email | ||
|
||
interface UserAuthInfoDomainService { | ||
|
||
fun findByEmail(email: Email): UserAuthInfo? | ||
|
||
fun create( | ||
user: User, | ||
socialLoginProvider: SocialLoginProvider, | ||
): UserAuthInfo | ||
|
||
} |
19 changes: 18 additions & 1 deletion
19
...n/src/main/kotlin/com/studentcenter/weave/application/service/domain/UserDomainService.kt
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 |
---|---|---|
@@ -1,11 +1,28 @@ | ||
package com.studentcenter.weave.application.service.domain | ||
|
||
import com.studentcenter.weave.domain.entity.User | ||
import java.util.UUID | ||
import com.studentcenter.weave.domain.enum.Gender | ||
import com.studentcenter.weave.domain.enum.Mbti | ||
import com.studentcenter.weave.domain.vo.BirthYear | ||
import com.studentcenter.weave.domain.vo.Nickname | ||
import com.studentcenter.weave.support.common.vo.Email | ||
import com.studentcenter.weave.support.common.vo.Url | ||
import java.util.* | ||
|
||
|
||
interface UserDomainService { | ||
|
||
fun getById(id: UUID): User | ||
|
||
fun create( | ||
nickname: Nickname, | ||
email: Email, | ||
gender: Gender, | ||
mbti: Mbti, | ||
birthYear: BirthYear, | ||
universityId: UUID, | ||
majorId: UUID, | ||
avatar: Url? = null, | ||
): User | ||
|
||
} |
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
35 changes: 33 additions & 2 deletions
35
...n/kotlin/com/studentcenter/weave/application/service/domain/impl/UserDomainServiceImpl.kt
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 |
---|---|---|
@@ -1,14 +1,45 @@ | ||
package com.studentcenter.weave.application.service.domain.impl | ||
|
||
import com.studentcenter.weave.application.port.outbound.UserRepository | ||
import com.studentcenter.weave.application.service.domain.UserDomainService | ||
import com.studentcenter.weave.domain.entity.User | ||
import com.studentcenter.weave.domain.enum.Gender | ||
import com.studentcenter.weave.domain.enum.Mbti | ||
import com.studentcenter.weave.domain.vo.BirthYear | ||
import com.studentcenter.weave.domain.vo.Nickname | ||
import com.studentcenter.weave.support.common.vo.Email | ||
import com.studentcenter.weave.support.common.vo.Url | ||
import org.springframework.stereotype.Service | ||
import java.util.* | ||
|
||
@Service | ||
class UserDomainServiceImpl : UserDomainService { | ||
class UserDomainServiceImpl( | ||
private val userRepository: UserRepository | ||
) : UserDomainService { | ||
|
||
override fun getById(id: UUID): User { | ||
TODO("Not yet implemented") | ||
return userRepository.getById(id) | ||
} | ||
|
||
override fun create( | ||
nickname: Nickname, | ||
email: Email, | ||
gender: Gender, | ||
mbti: Mbti, | ||
birthYear: BirthYear, | ||
universityId: UUID, | ||
majorId: UUID, | ||
avatar: Url?, | ||
): User { | ||
return User.create( | ||
nickname = nickname, | ||
email = email, | ||
gender = gender, | ||
mbti = mbti, | ||
birthYear = birthYear, | ||
universityId = universityId, | ||
majorId = majorId, | ||
avatar = avatar, | ||
).also { userRepository.save(it) } | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...studentcenter/weave/application/service/application/UserRegisterApplicationServiceTest.kt
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,58 @@ | ||
package com.studentcenter.weave.application.service.application | ||
|
||
import com.studentcenter.weave.application.port.inbound.UserRegisterUseCase | ||
import com.studentcenter.weave.application.port.outbound.UserAuthInfoRepositorySpy | ||
import com.studentcenter.weave.application.port.outbound.UserRepositorySpy | ||
import com.studentcenter.weave.application.service.domain.impl.UserAuthInfoDomainServiceImpl | ||
import com.studentcenter.weave.application.service.domain.impl.UserDomainServiceImpl | ||
import com.studentcenter.weave.application.service.util.UserTokenServiceStub | ||
import com.studentcenter.weave.domain.entity.User | ||
import com.studentcenter.weave.domain.entity.UserFixtureFactory | ||
import com.studentcenter.weave.domain.enum.SocialLoginProvider | ||
import io.kotest.core.spec.DisplayName | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.kotest.matchers.types.shouldBeTypeOf | ||
|
||
@DisplayName("UserRegisterApplicationService") | ||
class UserRegisterApplicationServiceTest : DescribeSpec({ | ||
|
||
describe("회원가입 유스케이스") { | ||
|
||
val userRepositorySpy = UserRepositorySpy() | ||
val userAuthInfoRepositorySpy = UserAuthInfoRepositorySpy() | ||
val sut = UserRegisterApplicationService( | ||
userTokenService = UserTokenServiceStub(), | ||
userDomainService = UserDomainServiceImpl(userRepositorySpy), | ||
userAuthInfoDomainService = UserAuthInfoDomainServiceImpl(userAuthInfoRepositorySpy) | ||
) | ||
|
||
context("회원가입 요청이 유효하면") { | ||
|
||
it("해당회원을 생성하고 로그인 토큰을 반환한다") { | ||
// arrange | ||
val user: User = UserFixtureFactory.create() | ||
val socialLoginProvider = SocialLoginProvider.KAKAO | ||
val command = UserRegisterUseCase.Command( | ||
nickname = user.nickname, | ||
email = user.email, | ||
socialLoginProvider = socialLoginProvider, | ||
gender = user.gender, | ||
mbti = user.mbti, | ||
birthYear = user.birthYear, | ||
universityId = user.universityId, | ||
majorId = user.majorId | ||
) | ||
|
||
// act | ||
val result: UserRegisterUseCase.Result = sut.invoke(command) | ||
|
||
// assert | ||
result.shouldBeTypeOf<UserRegisterUseCase.Result.Success>() | ||
result.accessToken.shouldBeTypeOf<String>() | ||
result.refreshToken.shouldBeTypeOf<String>() | ||
} | ||
} | ||
} | ||
|
||
|
||
}) |
40 changes: 40 additions & 0 deletions
40
...tlin/com/studentcenter/weave/application/service/domain/impl/UserDomainServiceImplTest.kt
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,40 @@ | ||
package com.studentcenter.weave.application.service.domain.impl | ||
|
||
import com.studentcenter.weave.application.port.outbound.UserRepositorySpy | ||
import com.studentcenter.weave.domain.entity.User | ||
import com.studentcenter.weave.domain.entity.UserFixtureFactory | ||
import io.kotest.core.spec.DisplayName | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
@DisplayName("UserDomainServiceImpl") | ||
class UserDomainServiceImplTest : DescribeSpec({ | ||
|
||
val userRepositorySpy = UserRepositorySpy() | ||
val sut = UserDomainServiceImpl(userRepositorySpy) | ||
|
||
afterTest { userRepositorySpy.clear() } | ||
|
||
describe("create") { | ||
|
||
it("유저를 생성하고 저장한다") { | ||
// arrange | ||
val userInfo: User = UserFixtureFactory.create() | ||
|
||
// act | ||
val createdUser: User = sut.create( | ||
nickname = userInfo.nickname, | ||
email = userInfo.email, | ||
gender = userInfo.gender, | ||
mbti = userInfo.mbti, | ||
birthYear = userInfo.birthYear, | ||
universityId = userInfo.universityId, | ||
majorId = userInfo.majorId, | ||
avatar = userInfo.avatar, | ||
) | ||
|
||
// assert | ||
userRepositorySpy.findById(createdUser.id) shouldBe createdUser | ||
} | ||
} | ||
}) |
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
27 changes: 27 additions & 0 deletions
27
...estFixtures/kotlin/com/studentcenter/weave/application/port/outbound/UserRepositorySpy.kt
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,27 @@ | ||
package com.studentcenter.weave.application.port.outbound | ||
|
||
import com.studentcenter.weave.domain.entity.User | ||
import java.util.* | ||
import java.util.concurrent.ConcurrentHashMap | ||
|
||
class UserRepositorySpy : UserRepository { | ||
|
||
private val bucket = ConcurrentHashMap<UUID, User>() | ||
|
||
fun findById(id: UUID): User? { | ||
return bucket[id] | ||
} | ||
|
||
override fun save(user: User) { | ||
bucket[user.id] = user | ||
} | ||
|
||
override fun getById(id: UUID): User { | ||
return bucket[id] ?: throw NoSuchElementException() | ||
} | ||
|
||
fun clear() { | ||
bucket.clear() | ||
} | ||
|
||
} |
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
Oops, something went wrong.