Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no skin image 버그 해결 #168

Merged
merged 9 commits into from
Nov 28, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ private void validateNickname(String nickname) {

private Member signUp(Long socialId) {
Member member = MemberMapper.toMember(socialId);
Member savedMember = memberRepository.save(member);
saveMyEgg(savedMember);

return memberRepository.save(member);
return savedMember;
}

private void saveMyEgg(Member member) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/moabam/api/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public void changeIntro(String intro) {

public void changeProfileUri(String newProfileUri) {
this.profileImage = requireNonNullElse(newProfileUri, profileImage);
this.profileImage = requireNonNullElse(newProfileUri, profileImage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅋㅋ

}

public void changeDefaultSkintUrl(Item item) throws NotFoundException {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/moabam/global/common/util/BaseImageUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class BaseImageUrl {
public static final String DEFAULT_NIGHT_AWAKE_SKIN_URL = "";
public static final String DEFAULT_NIGHT_SLEEP_SKIN_URL = "";

public static final String DEFAULT_MORNING_EGG_URL = "moabam/skins/오목눈이/기본/오목눈이알.png";
public static final String DEFAULT_NIGHT_EGG_URL = "moabam/skins/부엉이/기본/부엉이알.png";
public static final String MEMBER_PROFILE_URL = "moabam/default/기본회원프로필.png";
public static final String DEFAULT_MORNING_EGG_URL = "moabam/skins/omok/default/egg.png";
public static final String DEFAULT_NIGHT_EGG_URL = "moabam/skins/owl/default/egg.png";
public static final String MEMBER_PROFILE_URL = "moabam/default/member-profile.png";
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ void signUp_success() {
given(member.getId()).willReturn(1L);
willReturn(member)
.given(memberRepository).save(any(Member.class));
willReturn(List.of(ItemFixture.morningSantaSkin().build(), ItemFixture.nightMageSkin()))
.given(itemRepository).findAllById(any());

// when
LoginResponse result = memberService.login(authorizationTokenInfoResponse);
Expand Down Expand Up @@ -213,5 +215,4 @@ void modify_success_test(@WithMember AuthMember authMember) {
() -> assertThat(member.getProfileImage()).isEqualTo("/main")
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
import com.moabam.support.fixture.RoomFixture;
import com.moabam.support.fixture.TokenSaveValueFixture;

import jakarta.persistence.EntityManager;

@Transactional
@SpringBootTest
@AutoConfigureMockMvc
Expand Down Expand Up @@ -128,6 +130,9 @@ class MemberControllerTest extends WithoutFilterSupporter {

Member member;

@Autowired
EntityManager entityManager;

@BeforeAll
void allSetUp() {
restTemplateBuilder = new RestTemplateBuilder()
Expand All @@ -143,6 +148,7 @@ void setUp() {
RestTemplate restTemplate = restTemplateBuilder.build();
ReflectionTestUtils.setField(oAuth2AuthorizationServerRequestService, "restTemplate", restTemplate);
mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
member = entityManager.merge(member);
}

@DisplayName("로그아웃 성공 테스트")
Expand Down Expand Up @@ -270,6 +276,7 @@ void search_my_info_success() throws Exception {

member.changeDefaultSkintUrl(night);
member.changeDefaultSkintUrl(morning);
memberRepository.flush();

// expected
mockMvc.perform(get("/members"))
Expand Down Expand Up @@ -317,6 +324,11 @@ void search_my_info_with_no_badge_success() throws Exception {
Inventory killerInven = InventoryFixture.inventory(member.getId(), killer);
inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven));

member.changeDefaultSkintUrl(night);
member.changeDefaultSkintUrl(morning);

memberRepository.flush();

// expected
mockMvc.perform(get("/members"))
.andExpect(status().isOk())
Expand Down Expand Up @@ -376,6 +388,10 @@ void search_friend_info_success() throws Exception {
memberRepository.flush();
inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven));

friend.changeDefaultSkintUrl(morning);
friend.changeDefaultSkintUrl(night);
memberRepository.flush();

// expected
mockMvc.perform(get("/members/{memberId}", friend.getId()))
.andExpect(status().isOk())
Expand Down