Skip to content

Commit

Permalink
[KAN-104] 음식점 통합테스트 추가 - 오늘의픽 API 테스트 코드 + 리뷰 테스트 코드 비활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkyoungdeok committed May 28, 2024
1 parent 90e16d9 commit 71492f4
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,44 @@ class RecommendRestaurantControllerTest(
// then
actualResult.data!!.restaurants.size shouldBe 3
}

it("when no restaurant saved in redis should recommended 5 restaurants") {
// given
val restaurantIds = (1..5).map { i ->
val restaurant = restaurantRepository.save(
RestaurantUtil.generateRestaurantEntity(
name = "restaurant$i"
)
)

restaurant.id
}

val key = "RECOMMENDATION:0"
redisTemplate.opsForValue().set(key, restaurantIds.joinToString(","))

// when
val result = mockMvc.perform(
MockMvcRequestBuilders.get(baseUrl)
).also {
println(it.andReturn().response.contentAsString)
}
.andExpect(MockMvcResultMatchers.status().isOk)
.andExpect(MockMvcResultMatchers.jsonPath("$.result").value("SUCCESS"))
.andReturn()

val responseContent = result.response.getContentAsString(Charset.forName("UTF-8"))
val responseType =
object : TypeReference<CommonResponse<RecommendRestaurantResponse>>() {}
val actualResult: CommonResponse<RecommendRestaurantResponse> =
objectMapper.readValue(
responseContent,
responseType
)

// then
actualResult.data!!.restaurants.size shouldBe 5
}
}
}
}

0 comments on commit 71492f4

Please sign in to comment.