-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to edit UserEntity & Add User, School entities test code
- Loading branch information
1 parent
5e3b74d
commit 98bfce8
Showing
5 changed files
with
129 additions
and
9 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
66 changes: 66 additions & 0 deletions
66
.../src/test/kotlin/com/bestswlkh0310/graduating/graduatingserver/entity/SchoolEntityTest.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,66 @@ | ||
package com.bestswlkh0310.graduating.graduatingserver.entity | ||
|
||
import com.bestswlkh0310.graduating.graduatingserver.core.school.SchoolEntity | ||
import com.bestswlkh0310.graduating.graduatingserver.core.school.SchoolType | ||
import java.time.LocalDate | ||
|
||
class SchoolEntityTest { | ||
companion object { | ||
val name = "schoolName" | ||
val cityName = "cityName" | ||
val postalCode = "postalCode" | ||
val address = "address" | ||
val addressDetail = "addressDetail" | ||
val phone = "010-0000-0000" | ||
val website = "about:blank" | ||
val createdAt = LocalDate.now() | ||
val anniversary = LocalDate.now() | ||
val code = "code" | ||
val officeCode = "officeCode" | ||
|
||
val highSchool = SchoolEntity( | ||
name = name, | ||
type = SchoolType.HIGH, | ||
cityName = cityName, | ||
postalCode = postalCode, | ||
address = address, | ||
addressDetail = addressDetail, | ||
phone = phone, | ||
website = website, | ||
createdAt = createdAt, | ||
anniversary = anniversary, | ||
code = code, | ||
officeCode = officeCode, | ||
) | ||
|
||
val middleSchool = SchoolEntity( | ||
name = name, | ||
type = SchoolType.MIDDLE, | ||
cityName = cityName, | ||
postalCode = postalCode, | ||
address = address, | ||
addressDetail = addressDetail, | ||
phone = phone, | ||
website = website, | ||
createdAt = createdAt, | ||
anniversary = anniversary, | ||
code = code, | ||
officeCode = officeCode, | ||
) | ||
|
||
val elementarySchool = SchoolEntity( | ||
name = name, | ||
type = SchoolType.ELEMENTARY, | ||
cityName = cityName, | ||
postalCode = postalCode, | ||
address = address, | ||
addressDetail = addressDetail, | ||
phone = phone, | ||
website = website, | ||
createdAt = createdAt, | ||
anniversary = anniversary, | ||
code = code, | ||
officeCode = officeCode, | ||
) | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...er/src/test/kotlin/com/bestswlkh0310/graduating/graduatingserver/entity/UserEntityTest.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,48 @@ | ||
package com.bestswlkh0310.graduating.graduatingserver.entity | ||
|
||
import com.bestswlkh0310.graduating.graduatingserver.core.user.PlatformType | ||
import com.bestswlkh0310.graduating.graduatingserver.core.user.UserEntity | ||
import com.bestswlkh0310.graduating.graduatingserver.core.user.UserRole | ||
import com.bestswlkh0310.graduating.graduatingserver.core.user.UserState | ||
import org.junit.jupiter.api.Test | ||
import java.time.LocalDate | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNull | ||
|
||
class UserEntityTest { | ||
companion object { | ||
val email = "[email protected]" | ||
val platformType = PlatformType.GOOGLE | ||
val user = UserEntity( | ||
email = email, | ||
platformType = platformType, | ||
) | ||
val nickname = "testNickname" | ||
val veryDistantFuture = 1234567891 | ||
val veryDistantPast = 1 | ||
} | ||
|
||
@Test | ||
fun `create user entity`() { | ||
assertEquals(email, user.email) | ||
assertEquals(UserRole.USER, user.role) | ||
assertEquals(platformType, user.platformType) | ||
assertEquals(UserState.PENDING, user.state) | ||
assertNull(user.nickname) | ||
assertNull(user.graduatingYear) | ||
assertNull(user.school) | ||
} | ||
|
||
@Test | ||
fun `active user entity`() { | ||
user.active( | ||
nickname = nickname, | ||
graduatingYear = veryDistantFuture, | ||
school = SchoolEntityTest.highSchool | ||
) | ||
assertEquals(email, user.email) | ||
assertEquals(nickname, user.nickname) | ||
// 년도에 따라 테스크 코드가 달리지는 경우 어떻게 해야 하지 | ||
assertEquals(2027, user.graduatingYear) | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ing-Server/src/test/kotlin/com/bestswlkh0310/graduating/graduatingserver/util/TestUtil.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