From c86ab44bb10562aa4c3e553eecaa2325d050fb2e Mon Sep 17 00:00:00 2001 From: shrek2000 Date: Wed, 21 Mar 2018 13:26:35 +0200 Subject: Json Serialization should hide "empty". Json serialization of java collections exposes the isEmpty function as an attribute. This issue was discussed in the design review of Interface operations. Issue-ID: SDC-1150 Change-Id: I09e214f5631b73d60825732c4db8bbf85469c824 Signed-off-by: shrek2000 --- .../sdc/be/servlets/RepresentationUtilsTest.java | 99 +++++++++++++--------- 1 file changed, 60 insertions(+), 39 deletions(-) (limited to 'catalog-be/src/test/java/org/openecomp') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java index f82fdfc1ef..63e76700df 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java @@ -1,46 +1,67 @@ package org.openecomp.sdc.be.servlets; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; import org.apache.tinkerpop.gremlin.structure.T; import org.junit.Test; import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.Operation; + +public class RepresentationUtilsTest { + + private RepresentationUtils createTestSubject() { + return new RepresentationUtils(); + } + + + @Test + public void testConvertJsonToArtifactDefinitionForUpdate() throws Exception { + String content = ""; + Class clazz = null; + ArtifactDefinition result; + + // default test + result = RepresentationUtils.convertJsonToArtifactDefinitionForUpdate(content, clazz); + } + + + @Test + public void testToRepresentation() throws Exception { + T elementToRepresent = null; + Object result; + + // default test + result = RepresentationUtils.toRepresentation(elementToRepresent); + } + + + + + @Test + public void testConvertJsonToArtifactDefinition() throws Exception { + String content = ""; + Class clazz = null; + ArtifactDefinition result; + + // default test + result = RepresentationUtils.convertJsonToArtifactDefinition(content, clazz); + } -public class RepresentationUtilsTest { - - private RepresentationUtils createTestSubject() { - return new RepresentationUtils(); - } - - - @Test - public void testConvertJsonToArtifactDefinitionForUpdate() throws Exception { - String content = ""; - Class clazz = null; - ArtifactDefinition result; - - // default test - result = RepresentationUtils.convertJsonToArtifactDefinitionForUpdate(content, clazz); - } - - - @Test - public void testToRepresentation() throws Exception { - T elementToRepresent = null; - Object result; - - // default test - result = RepresentationUtils.toRepresentation(elementToRepresent); - } - - - - - @Test - public void testConvertJsonToArtifactDefinition() throws Exception { - String content = ""; - Class clazz = null; - ArtifactDefinition result; - - // default test - result = RepresentationUtils.convertJsonToArtifactDefinition(content, clazz); - } + @Test + public void checkIsEmptyFiltering() throws Exception { + HashMap op = new HashMap<>(); + Operation opValue = new Operation(); + opValue.setName("eee"); + opValue.setDescription("ccc"); + op.put("Bla", opValue); + Object result = RepresentationUtils.toRepresentation(op); + assertNotNull(result); + assertTrue(result.toString(), result.toString().contains("empty")); + result = RepresentationUtils.toFilteredRepresentation(op); + assertNotNull(result); + assertFalse(result.toString(), result.toString().contains("empty")); + } } \ No newline at end of file -- cgit 1.2.3-korg