|
|
@ -49,6 +49,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest { |
|
|
|
paramsMap.add("groupName","cxc test group name"); |
|
|
|
paramsMap.add("groupName","cxc test group name"); |
|
|
|
paramsMap.add("groupType", AlertType.EMAIL.toString()); |
|
|
|
paramsMap.add("groupType", AlertType.EMAIL.toString()); |
|
|
|
paramsMap.add("description","cxc junit 测试告警描述"); |
|
|
|
paramsMap.add("description","cxc junit 测试告警描述"); |
|
|
|
|
|
|
|
paramsMap.add("alertInstanceIds", ""); |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/alert-group/create") |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/alert-group/create") |
|
|
|
.header("sessionId", sessionId) |
|
|
|
.header("sessionId", sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
@ -93,40 +94,41 @@ public class AlertGroupControllerTest extends AbstractControllerTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testUpdateAlertgroup() throws Exception { |
|
|
|
public void testQueryAlertGroupById() throws Exception { |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
paramsMap.add("id","22"); |
|
|
|
paramsMap.add("id","22"); |
|
|
|
paramsMap.add("groupName", "hd test group name"); |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/alert-group/query") |
|
|
|
paramsMap.add("groupType",AlertType.EMAIL.toString()); |
|
|
|
|
|
|
|
paramsMap.add("description","update alter group"); |
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/alert-group/update") |
|
|
|
|
|
|
|
.header("sessionId", sessionId) |
|
|
|
.header("sessionId", sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andReturn(); |
|
|
|
.andReturn(); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Assert.assertTrue(result != null && result.isSuccess()); |
|
|
|
Assert.assertTrue(result != null && result.isStatus(Status.ALERT_GROUP_NOT_EXIST)); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testVerifyGroupName() throws Exception { |
|
|
|
public void testUpdateAlertgroup() throws Exception { |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
paramsMap.add("groupName","hd test group name"); |
|
|
|
paramsMap.add("id","22"); |
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/alert-group/verify-group-name") |
|
|
|
paramsMap.add("groupName", "cxc test group name"); |
|
|
|
|
|
|
|
paramsMap.add("groupType",AlertType.EMAIL.toString()); |
|
|
|
|
|
|
|
paramsMap.add("description","update alter group"); |
|
|
|
|
|
|
|
paramsMap.add("alertInstanceIds", ""); |
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/alert-group/update") |
|
|
|
.header("sessionId", sessionId) |
|
|
|
.header("sessionId", sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andReturn(); |
|
|
|
.andReturn(); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Assert.assertTrue(result != null && result.isStatus(Status.ALERT_GROUP_EXIST)); |
|
|
|
Assert.assertTrue(result != null && result.isStatus(Status.ALERT_GROUP_NOT_EXIST)); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testVerifyGroupNameNotExit() throws Exception { |
|
|
|
public void testVerifyGroupName() throws Exception { |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
paramsMap.add("groupName","cxc test group name"); |
|
|
|
paramsMap.add("groupName","cxc test group name"); |
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/alert-group/verify-group-name") |
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/alert-group/verify-group-name") |
|
|
@ -136,24 +138,22 @@ public class AlertGroupControllerTest extends AbstractControllerTest { |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andReturn(); |
|
|
|
.andReturn(); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Assert.assertTrue(result != null && result.isSuccess()); |
|
|
|
Assert.assertTrue(result != null && result.isStatus(Status.ALERT_GROUP_EXIST)); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testGrantUser() throws Exception { |
|
|
|
public void testVerifyGroupNameNotExit() throws Exception { |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
paramsMap.add("alertgroupId","2"); |
|
|
|
paramsMap.add("groupName","cxc test group name"); |
|
|
|
paramsMap.add("userIds","2"); |
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/alert-group/verify-group-name") |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/alert-group/grant-user") |
|
|
|
|
|
|
|
.header("sessionId", sessionId) |
|
|
|
.header("sessionId", sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andReturn(); |
|
|
|
.andReturn(); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Assert.assertTrue(result != null && result.isSuccess()); |
|
|
|
Assert.assertTrue(result != null && result.isStatus(Status.ALERT_GROUP_EXIST)); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -168,7 +168,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest { |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andReturn(); |
|
|
|
.andReturn(); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Assert.assertTrue(result != null && result.isSuccess()); |
|
|
|
Assert.assertTrue(result != null && result.isStatus(Status.ALERT_GROUP_NOT_EXIST)); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|