fd6f92018491543fddcf3f91e67b8a5254a583aa
[appc.git] /
1 package org.onap.appc.flow.controller.node;
2
3 import com.fasterxml.jackson.databind.JsonNode;
4 import java.io.IOException;
5 import org.junit.Assert;
6 import org.junit.Test;
7
8 public class JsonValidatorTest {
9
10   @Test
11   public void should_return_json_node_on_valid_json() throws IOException {
12     String json = "{'test': 'OK'}".replaceAll("'", "\"");
13     JsonNode result = JsonValidator.validate(json);
14
15     Assert.assertNotNull(result);
16     Assert.assertTrue(result.has("test"));
17     Assert.assertEquals("OK", result.get("test").asText());
18   }
19
20   @Test
21   public void should_return_null_on_empty_input() throws IOException {
22     String json = "";
23     JsonNode result = JsonValidator.validate(json);
24
25     Assert.assertNull(result);
26   }
27
28   @Test
29   public void should_return_null_on_invalid_input() throws IOException {
30     String json = "{'test': 'OK'".replaceAll("'", "\"");
31     JsonNode result = JsonValidator.validate(json);
32
33     Assert.assertNull(result);
34   }
35
36 }