Skip to content

Commit

Permalink
🐛 테스트 빌드 실패 해결 (#146)
Browse files Browse the repository at this point in the history
* 🐛 테스트 빌드 실패 해결

* ♻️ 유실물 추천 테스트 assert 조건 추가
  • Loading branch information
semi-cloud authored Aug 16, 2023
1 parent 0e65e6a commit 967b015
Showing 1 changed file with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package backend.team.ahachul_backend.api.lost.application.service

import backend.team.ahachul_backend.api.lost.adapter.web.`in`.dto.CreateLostPostDto
import backend.team.ahachul_backend.api.lost.adapter.web.`in`.dto.GetLostPostDto
import backend.team.ahachul_backend.api.lost.adapter.web.out.LostPostRepository
import backend.team.ahachul_backend.api.lost.application.port.`in`.LostPostUseCase
import backend.team.ahachul_backend.api.lost.application.service.command.CreateLostPostCommand
import backend.team.ahachul_backend.api.lost.application.service.command.SearchLostPostCommand
import backend.team.ahachul_backend.api.lost.application.service.command.UpdateLostPostCommand
import backend.team.ahachul_backend.api.lost.domain.entity.LostPostEntity
import backend.team.ahachul_backend.api.lost.domain.model.LostPostType
import backend.team.ahachul_backend.api.lost.domain.model.LostStatus
import backend.team.ahachul_backend.api.lost.domain.model.LostType
Expand Down Expand Up @@ -150,7 +153,7 @@ class LostPostServiceTest(

assertThat(entity.title).isEqualTo("지갑")
assertThat(entity.content).isEqualTo("내용")
assertThat(entity.lostType).isEqualTo(LostType.LOST)
assertThat(entity.lostType).isEqualTo(LostType.ACQUIRE)
assertThat(entity.type).isEqualTo(LostPostType.CREATED)
}

Expand Down Expand Up @@ -238,27 +241,53 @@ class LostPostServiceTest(
.hasMessage(ResponseCode.INVALID_AUTH.message)
}

@Test
@DisplayName("같은 카테고리의 유실물을 추천해야 한다.")
fun getSameCategoryRecommendLostPost() {
// given
val lostPostIds: MutableList<Long> = mutableListOf()

for(i: Int in 1.. 8) {
val createCommand = createLostPostCommand(subwayLine!!.id, "유실물$i", "휴대폰")
lostPostIds.add(lostPostUseCase.createLostPost(createCommand).id)
}

for(i: Int in 1.. 4) {
val createCommand = createLostPostCommand(subwayLine!!.id, "유실물$i", "지갑")
lostPostUseCase.createLostPost(createCommand)
}

// when
val response = lostPostUseCase.getLostPost(lostPostIds[0])
val recommendPosts = response.recommendPosts
assertThat(recommendPosts.map { it.id }.toSet().size).isEqualTo(12)
assertThat(recommendPosts.map { it.id }.containsAll(lostPostIds))
}


@Test
@DisplayName("추천되는 유실물에는 중복이 없어야 한다.")
fun getRecommendLostPost() {
// given
var lostPostId: Long = 0

for(i: Int in 1.. 8) {
val createCommand = createLostPostCommand(subwayLine!!.id, "유실물$i", "휴대폰")
lostPostUseCase.createLostPost(createCommand)
lostPostId = lostPostUseCase.createLostPost(createCommand).id
}

for(i: Int in 1.. 3) {
val createCommand = createLostPostCommand(subwayLine!!.id, "유실물$i", "지갑")
lostPostUseCase.createLostPost(createCommand)
}

for(i: Int in 1.. 3) {
for(i: Int in 1.. 2) {
val createCommand = createLostPostCommand(subwayLine!!.id, "유실물$i", "컴퓨터")
lostPostUseCase.createLostPost(createCommand)
}

// when
val response = lostPostUseCase.getLostPost(1)
val response = lostPostUseCase.getLostPost(lostPostId)
val recommendPosts = response.recommendPosts
assertThat(recommendPosts.map { it.id }.toSet().size).isEqualTo(12)
}
Expand Down

0 comments on commit 967b015

Please sign in to comment.