-
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.
- Loading branch information
1 parent
1fe411b
commit 3e3da97
Showing
2 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,6 +346,57 @@ class LikeRestaurantControllerTest( | |
} | ||
} | ||
|
||
describe("#getMyLikeRestaurants cartesian product bug test") { | ||
it("when two user like same restaurant should return only one") { | ||
// given | ||
val newUser = userRepository.save( | ||
User( | ||
email = "[email protected]", | ||
profileImageUrl = "test" | ||
) | ||
) | ||
val originalUser = userRepository.findByEmail("[email protected]")!! | ||
|
||
val restaurantEntity = RestaurantUtil.generateRestaurantEntity( | ||
name = "목구멍 율전점" | ||
) | ||
restaurantRepository.save(restaurantEntity) | ||
restaurantLikeRepository.save( | ||
RestaurantLike( | ||
userId = originalUser.id ?: 0, | ||
restaurantId = restaurantEntity.id | ||
) | ||
) | ||
restaurantLikeRepository.save( | ||
RestaurantLike( | ||
userId = newUser.id ?: 0, | ||
restaurantId = restaurantEntity.id | ||
) | ||
) | ||
|
||
// when | ||
val result = mockMvc.perform( | ||
get("$baseUrl/my-like") | ||
).also { | ||
println(it.andReturn().response.contentAsString) | ||
} | ||
.andExpect(status().isOk) | ||
.andExpect(jsonPath("$.result").value("SUCCESS")) | ||
.andReturn() | ||
|
||
val responseContent = result.response.getContentAsString(Charset.forName("UTF-8")) | ||
val responseType = | ||
object : TypeReference<CommonResponse<GetRestaurantsResponse>>() {} | ||
val actualResult: CommonResponse<GetRestaurantsResponse> = objectMapper.readValue( | ||
responseContent, | ||
responseType | ||
) | ||
|
||
// then | ||
actualResult.data!!.restaurants.content.size shouldBe 1 | ||
} | ||
} | ||
|
||
describe("#likeRestaurant basic test") { | ||
it("when like restaurant should success like") { | ||
// given | ||
|