diff --git a/web/src/test/java/com/navercorp/pinpoint/web/response/AlarmResponseTest.java b/web/src/test/java/com/navercorp/pinpoint/web/response/AlarmResponseTest.java new file mode 100644 index 000000000000..83b833743af0 --- /dev/null +++ b/web/src/test/java/com/navercorp/pinpoint/web/response/AlarmResponseTest.java @@ -0,0 +1,26 @@ +package com.navercorp.pinpoint.web.response; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.TextNode; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class AlarmResponseTest { + private final ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testCreatedMessage() throws JsonProcessingException { + AlarmResponse result = new AlarmResponse("SUCCESS", "12345"); + checkOutput(result); + } + + private void checkOutput(AlarmResponse codeResult) throws JsonProcessingException { + String jsonString = mapper.writeValueAsString(codeResult); + JsonNode jsonNode = mapper.readTree(jsonString); + Assertions.assertEquals(TextNode.valueOf("SUCCESS"), jsonNode.get("result")); + Assertions.assertNull(jsonNode.get("message")); + Assertions.assertEquals(TextNode.valueOf("12345"), jsonNode.get("ruleId")); + } +} diff --git a/web/src/test/java/com/navercorp/pinpoint/web/vo/CodeResultTest.java b/web/src/test/java/com/navercorp/pinpoint/web/response/CodeResultTest.java similarity index 66% rename from web/src/test/java/com/navercorp/pinpoint/web/vo/CodeResultTest.java rename to web/src/test/java/com/navercorp/pinpoint/web/response/CodeResultTest.java index 5f00715ed210..a95bdaa6be05 100644 --- a/web/src/test/java/com/navercorp/pinpoint/web/vo/CodeResultTest.java +++ b/web/src/test/java/com/navercorp/pinpoint/web/response/CodeResultTest.java @@ -1,9 +1,8 @@ -package com.navercorp.pinpoint.web.vo; +package com.navercorp.pinpoint.web.response; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.navercorp.pinpoint.web.response.CodeResult; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; @@ -18,10 +17,18 @@ public class CodeResultTest { @Test public void getMessage_NON_NULL() throws JsonProcessingException { CodeResult result = new CodeResult(1); + checkOutput(result); + } - String jsonString = mapper.writeValueAsString(result); - JsonNode jsonNode = mapper.readTree(jsonString); + @Test + public void getMessage_static() throws JsonProcessingException{ + CodeResult result = CodeResult.ok("test message"); + checkOutput(result); + } + private void checkOutput(CodeResult codeResult) throws JsonProcessingException { + String jsonString = mapper.writeValueAsString(codeResult); + JsonNode jsonNode = mapper.readTree(jsonString); Assertions.assertNotNull(jsonNode.get("code")); Assertions.assertNull(jsonNode.get("result")); } diff --git a/web/src/test/java/com/navercorp/pinpoint/web/response/CreateUserGroupResponseTest.java b/web/src/test/java/com/navercorp/pinpoint/web/response/CreateUserGroupResponseTest.java new file mode 100644 index 000000000000..9cecfba2ddb2 --- /dev/null +++ b/web/src/test/java/com/navercorp/pinpoint/web/response/CreateUserGroupResponseTest.java @@ -0,0 +1,26 @@ +package com.navercorp.pinpoint.web.response; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.TextNode; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CreateUserGroupResponseTest { + private final ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testCreatedMessage() throws JsonProcessingException { + CreateUserGroupResponse result = new CreateUserGroupResponse("SUCCESS", "12345"); + checkOutput(result); + } + + private void checkOutput(CreateUserGroupResponse codeResult) throws JsonProcessingException { + String jsonString = mapper.writeValueAsString(codeResult); + JsonNode jsonNode = mapper.readTree(jsonString); + Assertions.assertEquals(TextNode.valueOf("SUCCESS"), jsonNode.get("result")); + Assertions.assertNull(jsonNode.get("message")); + Assertions.assertEquals(TextNode.valueOf("12345"), jsonNode.get("number")); + } +} diff --git a/web/src/test/java/com/navercorp/pinpoint/web/response/SuccessResponseTest.java b/web/src/test/java/com/navercorp/pinpoint/web/response/SuccessResponseTest.java new file mode 100644 index 000000000000..443dc76d994a --- /dev/null +++ b/web/src/test/java/com/navercorp/pinpoint/web/response/SuccessResponseTest.java @@ -0,0 +1,34 @@ +package com.navercorp.pinpoint.web.response; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.TextNode; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class SuccessResponseTest { + private final ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testStaticOk() throws JsonProcessingException { + Response result = SuccessResponse.ok();; + JsonNode jsonNode = checkOutput(result); + Assertions.assertEquals(TextNode.valueOf("SUCCESS"), jsonNode.get("result")); + Assertions.assertNull(jsonNode.get("message")); + } + + @Test + public void testStaticOkWithMessage() throws JsonProcessingException { + Response result = SuccessResponse.ok("Test Message");; + checkOutput(result); + JsonNode jsonNode = checkOutput(result); + Assertions.assertEquals(TextNode.valueOf("SUCCESS"), jsonNode.get("result")); + Assertions.assertEquals(TextNode.valueOf("Test Message"), jsonNode.get("message")); + } + + private JsonNode checkOutput(Response codeResult) throws JsonProcessingException { + String jsonString = mapper.writeValueAsString(codeResult); + return mapper.readTree(jsonString); + } +} diff --git a/web/src/test/java/com/navercorp/pinpoint/web/response/WebhookResponseTest.java b/web/src/test/java/com/navercorp/pinpoint/web/response/WebhookResponseTest.java new file mode 100644 index 000000000000..09be09b2557a --- /dev/null +++ b/web/src/test/java/com/navercorp/pinpoint/web/response/WebhookResponseTest.java @@ -0,0 +1,28 @@ +package com.navercorp.pinpoint.web.response; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.TextNode; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class WebhookResponseTest { + private final ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testCreatedMessage() throws JsonProcessingException { + WebhookResponse result = new WebhookResponse("SUCCESS", "12345"); + checkOutput(result); + } + + private void checkOutput(WebhookResponse codeResult) throws JsonProcessingException { + String jsonString = mapper.writeValueAsString(codeResult); + JsonNode jsonNode = mapper.readTree(jsonString); + Assertions.assertEquals(TextNode.valueOf("SUCCESS"), jsonNode.get("result")); + Assertions.assertNull(jsonNode.get("message")); + Assertions.assertEquals(TextNode.valueOf("12345"), jsonNode.get("webhookId")); + } + + +} diff --git a/web/src/test/java/com/navercorp/pinpoint/web/response/WebhookSendInfoResponseTest.java b/web/src/test/java/com/navercorp/pinpoint/web/response/WebhookSendInfoResponseTest.java new file mode 100644 index 000000000000..408647916cb6 --- /dev/null +++ b/web/src/test/java/com/navercorp/pinpoint/web/response/WebhookSendInfoResponseTest.java @@ -0,0 +1,28 @@ +package com.navercorp.pinpoint.web.response; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.TextNode; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class WebhookSendInfoResponseTest { + private final ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testCreatedMessage() throws JsonProcessingException { + WebhookSendInfoResponse result = new WebhookSendInfoResponse("SUCCESS", "12345"); + checkOutput(result); + } + + private void checkOutput(WebhookSendInfoResponse codeResult) throws JsonProcessingException { + String jsonString = mapper.writeValueAsString(codeResult); + JsonNode jsonNode = mapper.readTree(jsonString); + Assertions.assertEquals(TextNode.valueOf("SUCCESS"), jsonNode.get("result")); + Assertions.assertNull(jsonNode.get("message")); + Assertions.assertEquals(TextNode.valueOf("12345"), jsonNode.get("webhookSendInfoId")); + } + + +}