mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-13 23:06:54 +10:00
Merge pull request #887 from minwoo-jung/issue-762
[#762] change result data format for searching user
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.navercorp.pinpoint.web.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -85,7 +87,9 @@ public class UserController {
|
||||
public Object getUser(@RequestParam(value="userId", required=false) String userId, @RequestParam(value="userName", required=false) String userName, @RequestParam(value="department", required=false) String department) {
|
||||
try {
|
||||
if(userId != null) {
|
||||
return userService.selectUserByUserId(userId);
|
||||
List<User> users = new ArrayList<User>(1);
|
||||
users.add(userService.selectUserByUserId(userId));
|
||||
return users;
|
||||
} else if (userName != null) {
|
||||
return userService.selectUserByUserName(userName);
|
||||
} else if (department != null) {
|
||||
|
||||
@@ -103,7 +103,17 @@ public class UserControllerTest {
|
||||
.andExpect(jsonPath("$[0]", hasKey("email")))
|
||||
.andReturn();
|
||||
|
||||
MvcResult andReturn = this.mockMvc.perform(get("/user.pinpoint?userName=" + USER_NAME).contentType(MediaType.APPLICATION_JSON))
|
||||
this.mockMvc.perform(get("/user.pinpoint?userName=" + USER_NAME).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType("application/json;charset=UTF-8"))
|
||||
.andExpect(jsonPath("$[0]", hasKey("userId")))
|
||||
.andExpect(jsonPath("$[0]", hasKey("name")))
|
||||
.andExpect(jsonPath("$[0]", hasKey("department")))
|
||||
.andExpect(jsonPath("$[0]", hasKey("phoneNumber")))
|
||||
.andExpect(jsonPath("$[0]", hasKey("email")))
|
||||
.andReturn();
|
||||
|
||||
this.mockMvc.perform(get("/user.pinpoint?userId=" + USER_ID).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType("application/json;charset=UTF-8"))
|
||||
.andExpect(jsonPath("$[0]", hasKey("userId")))
|
||||
@@ -112,7 +122,6 @@ public class UserControllerTest {
|
||||
.andExpect(jsonPath("$[0]", hasKey("phoneNumber")))
|
||||
.andExpect(jsonPath("$[0]", hasKey("email")))
|
||||
.andReturn();
|
||||
System.out.println(andReturn.getResponse().getContentAsString());
|
||||
|
||||
this.mockMvc.perform(get("/user.pinpoint?department=" + USER_DEPARTMENT).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
|
||||
Reference in New Issue
Block a user