Add test coverage for core server components: annotation scanning, routing, rate limiting, CORS, and JSON handling
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package dev.coph.nextusweb.server.json;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tools.jackson.databind.JsonNode;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class JsonMapperTest {
|
||||
|
||||
@Test
|
||||
void mapperIsAvailable() {
|
||||
assertNotNull(JsonMapper.MAPPER);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapperRoundTripsSimpleValues() {
|
||||
var node = JsonMapper.MAPPER.valueToTree(java.util.Map.of("a", 1));
|
||||
assertTrue(node.isObject());
|
||||
assertEquals(1, node.get("a").asInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapperReadsTree() {
|
||||
JsonNode n = JsonMapper.MAPPER.readTree("{\"k\":\"v\"}");
|
||||
assertTrue(n.has("k"));
|
||||
assertNotNull(n.get("k"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapperSerializesToBytes() {
|
||||
byte[] bytes = JsonMapper.MAPPER.writeValueAsBytes(java.util.Map.of("a", "b"));
|
||||
String s = new String(bytes, java.nio.charset.StandardCharsets.UTF_8);
|
||||
assertTrue(s.contains("\"a\""));
|
||||
assertTrue(s.contains("\"b\""));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user