|
|
@@ -8,7 +8,6 @@ import com.ruoyi.framework.web.exception.GlobalExceptionHandler;
|
|
|
import com.ruoyi.system.domain.InfoUser;
|
|
|
import com.ruoyi.system.domain.PosStore;
|
|
|
import com.ruoyi.system.service.IPosStoreService;
|
|
|
-import com.ruoyi.system.utils.JwtUtil;
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
@@ -69,24 +68,22 @@ class PosStoreControllerTest {
|
|
|
.thenThrow(new ServiceException("账号状态未审核"));
|
|
|
|
|
|
mockMvc.perform(post("/chanting/store/addmendian")
|
|
|
- .header("token", tokenFor(101L))
|
|
|
.contentType(APPLICATION_JSON)
|
|
|
- .content(objectMapper.writeValueAsString(newStore(999L))))
|
|
|
+ .content(objectMapper.writeValueAsString(newStore(101L))))
|
|
|
.andExpect(jsonPath("$.code").value(500))
|
|
|
.andExpect(jsonPath("$.msg").value("账号状态未审核"));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void auditedMerchantCreatesStoreOwnedByTokenUser() throws Exception {
|
|
|
+ void auditedMerchantCreatesStoreOwnedByRequestBodyUser() throws Exception {
|
|
|
when(userService.checkUserStatus(101L)).thenReturn(auditedMerchant(101L));
|
|
|
PosStore saved = newStore(101L);
|
|
|
saved.setId(9);
|
|
|
when(posStoreService.getOne(any())).thenReturn(saved);
|
|
|
|
|
|
mockMvc.perform(post("/chanting/store/addmendian")
|
|
|
- .header("token", tokenFor(101L))
|
|
|
.contentType(APPLICATION_JSON)
|
|
|
- .content(objectMapper.writeValueAsString(newStore(999L))))
|
|
|
+ .content(objectMapper.writeValueAsString(newStore(101L))))
|
|
|
.andExpect(jsonPath("$.code").value(200));
|
|
|
|
|
|
ArgumentCaptor<PosStore> captor = ArgumentCaptor.forClass(PosStore.class);
|
|
|
@@ -103,7 +100,6 @@ class PosStoreControllerTest {
|
|
|
when(posStoreService.getById(9)).thenReturn(existing);
|
|
|
|
|
|
mockMvc.perform(post("/chanting/store/addmendian")
|
|
|
- .header("token", tokenFor(101L))
|
|
|
.contentType(APPLICATION_JSON)
|
|
|
.content(objectMapper.writeValueAsString(existing)))
|
|
|
.andExpect(jsonPath("$.code").value(200));
|
|
|
@@ -123,8 +119,4 @@ class PosStoreControllerTest {
|
|
|
user.setAuditStatus("1");
|
|
|
return user;
|
|
|
}
|
|
|
-
|
|
|
- private static String tokenFor(Long userId) {
|
|
|
- return JwtUtil.setToken(String.valueOf(userId), "merchant");
|
|
|
- }
|
|
|
}
|