Skip to content

Commit

Permalink
♻️ :: Test코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
lyutvs committed May 24, 2023
1 parent 214544a commit e79f76c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class InMemorySettingRepository(
}

override fun settingExist(categoryIds: List<UUID>, userId: UUID): Boolean {
return categoryIds.mapNotNull {
findSetting(userId, it)
}.isNotEmpty()
return categoryIds.map { findSetting(userId, it) }.any { it != null }
}

override fun queryActivatedCategory(userId: UUID): List<Category> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ class DetailApiImplTest {
topic = "ALL"
)

val categoryIds = listOf(category.id)

categorySpi.saveCategory(category)

settingSpi.saveAllSetting(category, userId, true)
settingSpi.updateAllSetting(categoryIds, userId, true)

detailSpi.save(category)

Expand Down Expand Up @@ -102,9 +104,11 @@ class DetailApiImplTest {
topic = "ALL"
)

val categoryIds = listOf(category.id)

categorySpi.saveCategory(category)

settingSpi.saveAllSetting(category, userId, false)
settingSpi.updateAllSetting(categoryIds, userId, false)

detailSpi.save(category)

Expand Down Expand Up @@ -135,9 +139,11 @@ class DetailApiImplTest {
topic = "ALL"
)

val categoryIds = listOf(category.id)

categorySpi.saveCategory(category)

settingSpi.saveAllSetting(category, userId, false)
settingSpi.updateAllSetting(categoryIds, userId, false)

detailSpi.save(category)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ class SettingApiImplTest {

settingSpi.saveCategory(category)

settingSpi.saveAllSetting(
category,
val categoryIds = listOf(category.id)


settingSpi.updateAllSetting(
categoryIds,
userId,
true
)
Expand All @@ -39,30 +42,4 @@ class SettingApiImplTest {
assertThat(result.destination).isEqualTo(category.destination)

}

@Test
fun deActivatedCategory() {
val userId = UUID.randomUUID()
val categoryId = UUID.randomUUID()
categorySpi.saveCategory(
Category(categoryId, "Test name", "Test destination", false, "ALL")
)
Assertions.assertThat(settingApi.deActivateCategory(categoryId, userId))
.isEqualTo(201)
Assertions.assertThat(settingApi.deActivateCategory(categoryId, userId))
.isEqualTo(204)
}

@Test
fun activateCategory() {
val userId = UUID.randomUUID()
val categoryId = UUID.randomUUID()
categorySpi.saveCategory(
Category(categoryId, "Test name", "Test destination", false, "ALL")
)
assertThat(settingApi.activateOrDeActivateCategory(categoryId, userId))
.isEqualTo(201)
assertThat(settingApi.activateOrDeActivateCategory(categoryId, userId))
.isEqualTo(204)
}
}

0 comments on commit e79f76c

Please sign in to comment.