Skip to content

Commit

Permalink
[MOA-485] 연락처에 중복된 번호 존재 시 처리 (#104)
Browse files Browse the repository at this point in the history
* MOA-485: 연락처에 동일한 번호 정보가 존재하는 경우에 대한 인수테스트 작성

* MOA-485: 연락처에 동일한 번호 정보가 존재하는 경우 처리
  • Loading branch information
shin-mallang committed Mar 1, 2024
1 parent 29ada0f commit 371b742
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
24 changes: 24 additions & 0 deletions api/src/test/java/moa/acceptance/freind/FriendAcceptanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ class 연락처_동기화_API {
// then
assertStatus(response, OK);
}

@Test
void 연락처에_동일한_번호가_존재하면_둘_중_아무거나_하나의_이름으로_추가된다() {
// given
말랑_token = login(말랑);
var request = new SyncContactRequest(
new ContactRequest("주예스", "010-2222-2222"),
new ContactRequest("주노", "010-2222-2222"),
new ContactRequest("주예스", "010-2222-2222")
);

// when
연락처_동기화(말랑_token, request);

// then
var response = 내_친구_목록_조회_요청(말랑_token);
List<FriendResponse> result = response.as(new TypeRef<>() {
});
assertThat(result)
.hasSize(1)
.element(0)
.extracting(FriendResponse::customNickname)
.isIn("주노", "주예스");
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface DiscordWebHookApiClient {
* https://discord.com/developers/docs/resources/webhook
*/
@PostExchange(url = "/webhooks/{webhookId}/{webhookToken}", contentType = APPLICATION_JSON_VALUE)
Void sendMessage(
void sendMessage(
@PathVariable("webhookId") String webhookId,
@PathVariable("webhookToken") String webhookToken,
@RequestBody DiscordSendMessageRequest request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ public record ContactInfo(

public Map<String, String> phoneAndNameMap() {
return contactList.stream()
.collect(toMap(ContactInfo::phoneNumber, ContactInfo::name));

.collect(toMap(
ContactInfo::phoneNumber,
ContactInfo::name,
(order, recent) -> recent
));
}

public List<String> phones() {
Expand Down

0 comments on commit 371b742

Please sign in to comment.