Json Serialization should hide "empty".
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / servlets / RepresentationUtilsTest.java
1 package org.openecomp.sdc.be.servlets;
2
3 import static org.junit.Assert.assertFalse;
4 import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertTrue;
6
7 import java.util.HashMap;
8 import org.apache.tinkerpop.gremlin.structure.T;
9 import org.junit.Test;
10 import org.openecomp.sdc.be.model.ArtifactDefinition;
11 import org.openecomp.sdc.be.model.Operation;
12
13 public class RepresentationUtilsTest  {
14
15     private RepresentationUtils createTestSubject() {
16         return new RepresentationUtils();
17     }
18
19
20     @Test
21     public void testConvertJsonToArtifactDefinitionForUpdate() throws Exception {
22         String content = "";
23         Class<ArtifactDefinition> clazz = null;
24         ArtifactDefinition result;
25
26         // default test
27         result = RepresentationUtils.convertJsonToArtifactDefinitionForUpdate(content, clazz);
28     }
29
30
31     @Test
32     public void testToRepresentation() throws Exception {
33         T elementToRepresent = null;
34         Object result;
35
36         // default test
37         result = RepresentationUtils.toRepresentation(elementToRepresent);
38     }
39
40
41
42
43     @Test
44     public void testConvertJsonToArtifactDefinition() throws Exception {
45         String content = "";
46         Class<ArtifactDefinition> clazz = null;
47         ArtifactDefinition result;
48
49         // default test
50         result = RepresentationUtils.convertJsonToArtifactDefinition(content, clazz);
51     }
52
53     @Test
54     public void checkIsEmptyFiltering() throws Exception {
55         HashMap<String, Operation> op = new HashMap<>();
56         Operation opValue = new Operation();
57         opValue.setName("eee");
58         opValue.setDescription("ccc");
59         op.put("Bla", opValue);
60         Object result = RepresentationUtils.toRepresentation(op);
61         assertNotNull(result);
62         assertTrue(result.toString(), result.toString().contains("empty"));
63         result = RepresentationUtils.toFilteredRepresentation(op);
64         assertNotNull(result);
65         assertFalse(result.toString(), result.toString().contains("empty"));
66     }
67 }