diff options
Diffstat (limited to 'catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java')
-rw-r--r-- | catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java index 9b6acd6203..4a390d3e0c 100644 --- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java @@ -16,33 +16,41 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ package org.openecomp.sdc.fe.listen; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.io.Serializable; +import org.junit.Assert; import org.junit.Test; import com.fasterxml.jackson.databind.ObjectMapper; - public class MyObjectMapperProviderTest { - private MyObjectMapperProvider createTestSubject() { - return new MyObjectMapperProvider(); + private class AnyModel implements Serializable { + private String field1; + + AnyModel(String field1) { + this.field1 = field1; + } + + public String getField1() { + return field1; + } } - @Test - public void testGetContext() throws Exception { - MyObjectMapperProvider testSubject; - Class<?> type = null; - ObjectMapper result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getContext(type); + public void shouldSerializeItPretty() throws JsonProcessingException { + String prettyJson = "{\n" + + " \"field1\" : \"Field1\"\n" + + "}"; + + ObjectMapper objectMapper = new MyObjectMapperProvider().getContext(MyObjectMapperProviderTest.class); + String serialized = objectMapper.writeValueAsString(new AnyModel("Field1")); + Assert.assertEquals(serialized, prettyJson); } - - - } |