c4b341fd57bcd3425a48c84d85c9a446a3041b65
[sdc/sdc-workflow-designer.git] /
1 /**
2  * Copyright (c) 2018 ZTE Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the Apache License, Version 2.0
5  * and the Eclipse Public License v1.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     ZTE - initial API and implementation and/or initial documentation
11  */
12 package org.onap.sdc.workflowdesigner.utils;
13
14 import static org.junit.Assert.*;
15
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.onap.sdc.workflowdesigner.resources.entity.I18nString;
20
21 /**
22  *
23  */
24 public class JsonUtilsTest {
25
26   /**
27    * @throws java.lang.Exception
28    */
29   @Before
30   public void setUp() throws Exception {}
31
32   /**
33    * @throws java.lang.Exception
34    */
35   @After
36   public void tearDown() throws Exception {}
37
38   /**
39    * Test method for {@link org.onap.sdc.workflowdesigner.utils.JsonUtils#fromJson(java.lang.String, java.lang.Class)}.
40    */
41   @Test
42   public void testFromJson() {
43     String i18n = "{\"en_US\":\"Service Task\",\"zh_CN\":\"Service Task\"}";
44     I18nString i18nString = JsonUtils.fromJson(i18n, I18nString.class);
45     assertNotNull(i18nString);
46   }
47
48   /**
49    * Test method for {@link org.onap.sdc.workflowdesigner.utils.JsonUtils#toJson(java.lang.Object)}.
50    */
51   @Test
52   public void testToJson() {
53     I18nString  i18nString = new I18nString("Service Task", "Service Task");
54     String i18n = JsonUtils.toJson(i18nString);
55     String expect = "{\"en_US\":\"Service Task\",\"zh_CN\":\"Service Task\"}";
56     assertEquals(expect, i18n);
57   }
58
59 }