build: test crud
This commit is contained in:
parent
f13c1c87b2
commit
0f90e2f31c
|
@ -1,7 +1,12 @@
|
|||
package io.metersphere.sdk.mapper;
|
||||
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.system.domain.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMapper {
|
||||
UserDTO selectById(String id);
|
||||
|
||||
List<User> findAll();
|
||||
}
|
||||
|
|
|
@ -8,4 +8,9 @@
|
|||
LEFT JOIN user_extend ON user.id = user_extend.id
|
||||
WHERE user.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultType="io.metersphere.system.domain.User">
|
||||
SELECT *
|
||||
FROM user
|
||||
</select>
|
||||
</mapper>
|
|
@ -6,8 +6,6 @@ import io.metersphere.sdk.util.BeanUtils;
|
|||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserExtend;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.IterableUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jdbc.core.JdbcAggregateTemplate;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -41,9 +39,6 @@ public class UserService {
|
|||
}
|
||||
|
||||
public List<User> list() {
|
||||
|
||||
PageRequest pageable = PageRequest.of(2, 5);
|
||||
Iterable<User> users = jdbcAggregateTemplate.findAll(User.class, pageable);
|
||||
return IterableUtils.toList(users);
|
||||
return userMapper.findAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
|
@ -13,7 +13,6 @@ import org.springframework.http.MediaType;
|
|||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
|
||||
|
@ -30,8 +29,7 @@ public class UserControllerTests {
|
|||
mockMvc.perform(MockMvcRequestBuilders.get("/user/list-all"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
// .andExpect(jsonPath("$.person.name").value("Jason"))
|
||||
.andDo(print());
|
||||
.andExpect(jsonPath("$.data[0].name").value("admin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue