diff --git a/src/main/java/com/younghun/hibusgo/controller/AccountController.java b/src/main/java/com/younghun/hibusgo/controller/AccountController.java
index 576ab28..e0f1900 100644
--- a/src/main/java/com/younghun/hibusgo/controller/AccountController.java
+++ b/src/main/java/com/younghun/hibusgo/controller/AccountController.java
@@ -18,9 +18,7 @@
import com.younghun.hibusgo.dto.AccountDto;
import com.younghun.hibusgo.dto.PasswordDto;
import com.younghun.hibusgo.dto.PaymentDto;
-import com.younghun.hibusgo.dto.PaymentMeansDto;
import com.younghun.hibusgo.dto.ProfileDto;
-import com.younghun.hibusgo.dto.ReservationDto;
import com.younghun.hibusgo.service.AccountService;
import com.younghun.hibusgo.service.LoginService;
import com.younghun.hibusgo.service.MileageService;
diff --git a/src/main/java/com/younghun/hibusgo/mapper/AccountMapper.java b/src/main/java/com/younghun/hibusgo/mapper/AccountMapper.java
index eb8ff8e..2e40eb8 100644
--- a/src/main/java/com/younghun/hibusgo/mapper/AccountMapper.java
+++ b/src/main/java/com/younghun/hibusgo/mapper/AccountMapper.java
@@ -5,7 +5,6 @@
@Mapper
public interface AccountMapper {
-
Account findById(long id);
void addAccount(Account account);
diff --git a/src/main/resources/mapper/account.xml b/src/main/resources/mapper/account.xml
index c105cfb..ca25634 100644
--- a/src/main/resources/mapper/account.xml
+++ b/src/main/resources/mapper/account.xml
@@ -101,4 +101,8 @@
AND status != 'DELETE'
+
+ DELETE FROM account;
+
+
diff --git a/src/main/resources/mapper/charge.xml b/src/main/resources/mapper/charge.xml
index 6468502..f8609b9 100644
--- a/src/main/resources/mapper/charge.xml
+++ b/src/main/resources/mapper/charge.xml
@@ -62,13 +62,5 @@
AND status != 'DELETE'
-
- UPDATE charge
- SET status = 'DELETE'
- AND updated_at = NOW()
- WHERE id = #{id}
- AND status != 'DELETE'
-
-
diff --git a/src/test/java/com/younghun/hibusgo/controller/AccountControllerTest.java b/src/test/java/com/younghun/hibusgo/controller/AccountControllerTest.java
deleted file mode 100644
index 488639d..0000000
--- a/src/test/java/com/younghun/hibusgo/controller/AccountControllerTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.younghun.hibusgo.controller;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.younghun.hibusgo.domain.Account;
-import com.younghun.hibusgo.dto.AccountDto;
-import com.younghun.hibusgo.service.AccountService;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.MediaType;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.transaction.annotation.Transactional;
-
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-
-/*
- * @SpringBootTest - 통합테스트 환경을 제공하는 spring-boot-test 어노테이션. 실제 구동되는 어플리케이션과 동일한 어플리케이션 컨텍스트를 제공함.
- * 대신 어플리케이션의 설정을 모두 로드하기 때문에 성능, 속도면에서 느리다. 제공되는 의존성 : JUnit, Spring Test, Spring Boot Test, AssertJ,
- *
- * @AutoConfigureMockMvc - Mock 테스트 시 필요한 의존성을 제공. Service에서 호출하는 Bean을 주입해준다. 간단히 컨트롤러 클래스만 테스트 하고
- * 싶다면 Mockup Test를 사용할 수 있는데 service 객체에 @MockBean 어노테이션을 적용 하는 것으로 이 어노테이션을 대체할 수 있다.
- *
- * 단위 테스트 : 개발 단계에서 각 모듈(기능)이나 어플케이션에 있는 개별적인 코드 단위가 예상대로 작동하는지 수행하는 테스트
- * 각각 함수를 한 가지의 일만 수행 하도록 작성 해야 한다.
- *
- * 단위 테스트 작성 방법
- * 1. 버그를 찾는다.
- * 2. 버그를 고쳤을 때 통과 할 만한 테스트 작성
- * 3. 테스트를 통과할 때 까지 코드를 수정
- *
- * 현재 변화하는 코드에 대해 테스트 만 작성, 가능한 모든 시나리오의 테스트를 작성하지 않는다.
- *
- * 통합 테스트 : 단위 테스트가 끝난 후 각 모듈(기능)을 통합 하는 과정에서 모듈간 호환성 문제가 없는지 수행하는 테스트
- */
-
-@SpringBootTest
-@AutoConfigureMockMvc
-@Transactional
-class AccountControllerTest {
-
- @Autowired
- MockMvc mockMvc;
- @Autowired
- AccountService accountService;
-
- @Autowired
- ObjectMapper objectMapper;
-
- @DisplayName("회원 가입 처리 - 입력값 오류")
- @Test
- void addAccount_with_wrong_input() throws Exception {
- AccountDto accountDto = AccountDto.builder()
- .userId("abcd1234")
- .password("1")
- .name("younghun")
- .phoneNumber("010-1234-5678")
- .build();
-
- Account account = accountDto.toEntity();
-
- String json = objectMapper.writeValueAsString(account);
-
- mockMvc.perform(post("/accounts/signUp")
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .content(json)
- .accept(MediaType.APPLICATION_JSON_VALUE))
- .andDo(print())
- .andExpect(status().isBadRequest());
- }
-
- @DisplayName("회원 가입 처리 - 입력값 정상")
- @Test
- void addAccount_with_correct_input() throws Exception {
- AccountDto accountDto = AccountDto.builder()
- .userId("abcd123455")
- .password("dudgns1234!")
- .name("younghun")
- .phoneNumber("010-1234-5678")
- .build();
-
- Account account = accountDto.toEntity();
-
- String json = objectMapper.writeValueAsString(account);
-
- mockMvc.perform(post("/accounts/signUp")
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .content(json)
- .accept(MediaType.APPLICATION_JSON_VALUE))
- .andDo(print())
- .andExpect(status().isCreated());
- }
-
- @DisplayName("회원 삭제 처리 - 입력값 정상")
- @Test
- void deleteAccount_with_correct_input() throws Exception {
- String id = "abcd1234";
-
- mockMvc.perform(delete("/accounts/" + id)
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .accept(MediaType.APPLICATION_JSON_VALUE))
- .andDo(print())
- .andExpect(status().isNoContent());
- }
-
-}
\ No newline at end of file
diff --git a/src/test/java/com/younghun/hibusgo/service/AccountServiceTest.java b/src/test/java/com/younghun/hibusgo/service/AccountServiceTest.java
new file mode 100644
index 0000000..7b853e3
--- /dev/null
+++ b/src/test/java/com/younghun/hibusgo/service/AccountServiceTest.java
@@ -0,0 +1,138 @@
+package com.younghun.hibusgo.service;
+
+import com.younghun.hibusgo.aop.LoginCheck.UserLevel;
+import com.younghun.hibusgo.domain.Account;
+import com.younghun.hibusgo.domain.DataStatus;
+import com.younghun.hibusgo.mapper.AccountMapper;
+import java.util.Optional;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
+
+@ExtendWith(MockitoExtension.class)
+class AccountServiceTest {
+
+ @InjectMocks
+ private AccountService accountService;
+
+ @Mock
+ private AccountMapper accountMapper;
+
+ @Mock
+ private PasswordEncoder passwordEncoder;
+
+ Account account;
+
+ final String userId = "whdudgns2654@gmail.com";
+ final String password = "younghun123!";
+
+ @BeforeEach
+ public void setUp() {
+ account = Account.builder()
+ .userId("whdudgns2654@gmail.com")
+ .password("younghun123!")
+ .name("younghun")
+ .phoneNumber("010-6769-5355")
+ .status(DataStatus.DEFAULT)
+ .userLevel(UserLevel.USER)
+ .build();
+ }
+
+ @Test
+ public void 아이디로_회원_조회() throws Exception {
+ //given
+ given(accountMapper.findById(1L)).willReturn(account);
+
+ //when
+ final Account addedAccount = accountService.findById(1L);
+
+ //then
+ assertEquals(account.getId(), addedAccount.getId());
+ }
+
+ @Test
+ public void 아이디로_회원_존재_확인() throws Exception {
+ //given
+ given(accountMapper.existsById(1L)).willReturn(true);
+
+ //when
+ final boolean existsById = accountService.existsById(1L);
+
+ //then
+ assertTrue(existsById);
+ }
+
+ @Test
+ public void 회원_추가() throws Exception{
+ //when
+ accountService.addAccount(account);
+
+ //then
+ then(accountMapper)
+ .should()
+ .addAccount(any(Account.class));
+
+ }
+
+ @Test
+ public void 아이디_비밀번호로_회원_조회() throws Exception{
+ //given
+ String encodePassword = passwordEncoder.encode(password);
+ given(accountMapper.findByUserIdAndPassword(userId, encodePassword))
+ .willReturn(account);
+
+ //when
+ final Optional addedAccount = accountService.findByUserIdAndPassword(userId, password);
+
+ //then
+ assertEquals(userId, addedAccount.get().getUserId());
+ }
+
+ @Test
+ public void 회원_삭제() throws Exception{
+ //when
+ accountService.deleteAccount(1L);
+
+ //then
+ then(accountMapper)
+ .should()
+ .deleteAccount(anyLong());
+ }
+
+ @Test
+ public void 비밀번호_수정() throws Exception{
+ //given
+ String encodePassword = passwordEncoder.encode(password);
+
+ //when
+ accountService.updatePassword(1L, password);
+
+ //then
+ then(accountMapper)
+ .should()
+ .updatePassword(1L, encodePassword);
+ }
+
+ @Test
+ public void 회원정보_수정() throws Exception{
+ //when
+ accountService.updateAccountInfo(account);
+
+ //then
+ then(accountMapper)
+ .should()
+ .updateAccountInfo(account);
+ }
+
+}
\ No newline at end of file