Skip to content

Commit

Permalink
✨ Feat: 기본 닉네임 세팅 & 응답 words 기본 빈 리스트 할당
Browse files Browse the repository at this point in the history
  • Loading branch information
swa07016 committed Mar 12, 2024
1 parent 3d625cb commit 5ed6b66
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ public class BriefingStatic {
public static final String NICK_NAME_FORMAT = "json";
public static final int NICK_NAME_COUNT = 1;
public static final int NICK_NAME_MAX_LENGTH = 8;

public static final String DEFAULT_NICK_NAME = "하품하는 프로도";
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String getOneRandomNickName(int maxLength) {
private String getOneRandomNickNameWithDetails(int maxLength) {
List<String> nickNameWords = nickNameClient.getNickName(NICK_NAME_FORMAT, NICK_NAME_COUNT, maxLength).getWords();
if (!nickNameWords.isEmpty()) return nickNameWords.get(0);
return "";
return DEFAULT_NICK_NAME;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class NickNameRes {
private List<String> words;
private List<String> words = new ArrayList<>();
private String seed;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.briefinginfra.feign.nickname.hwanmoo.adapter;

import com.example.briefingcommon.common.constant.BriefingStatic;
import com.example.briefinginfra.config.TestConfig;
import com.example.briefinginfra.feign.nickname.hwanmoo.client.NickNameClient;
import com.example.briefinginfra.feign.nickname.hwanmoo.dto.NickNameRes;
Expand All @@ -13,6 +14,7 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.util.ArrayList;
import java.util.Arrays;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -42,4 +44,20 @@ class NickNameGeneratorTest {
assertThat(nickName).isNotNull();
assertThat(nickName).isEqualTo("하품하는 프로도");
}

@Test
@DisplayName("[NickNameGenerator] 랜덤 닉네임 생성 - 빈 리스트 (기본 닉네임)")
void 랜덤_닉네임_생성_기본_닉네임() throws Exception {
// given
NickNameRes mockResponse = new NickNameRes();
when(nickNameClient.getNickName("json", 1, 8)).thenReturn(mockResponse);

// when
String nickName = nickNameGenerator.getOneRandomNickName();

// then
assertThat(nickName).isNotNull();
assertThat(nickName).isEqualTo(BriefingStatic.DEFAULT_NICK_NAME);
}

}

0 comments on commit 5ed6b66

Please sign in to comment.