[AAF-21] Initial code import
[aaf/cadi.git] / aaf / src / test / java / com / att / aaf / content / JU_Content.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aai\r
4  * * ===========================================================================\r
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * * Copyright © 2017 Amdocs\r
7  * * ===========================================================================\r
8  * * Licensed under the Apache License, Version 2.0 (the "License");\r
9  * * you may not use this file except in compliance with the License.\r
10  * * You may obtain a copy of the License at\r
11  * * \r
12  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
13  * * \r
14  *  * Unless required by applicable law or agreed to in writing, software\r
15  * * distributed under the License is distributed on an "AS IS" BASIS,\r
16  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * * See the License for the specific language governing permissions and\r
18  * * limitations under the License.\r
19  * * ============LICENSE_END====================================================\r
20  * *\r
21  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
22  * *\r
23  ******************************************************************************/\r
24 package com.att.aaf.content;\r
25 \r
26 import java.io.StringReader;\r
27 \r
28 import org.junit.AfterClass;\r
29 import org.junit.BeforeClass;\r
30 import org.junit.Test;\r
31 \r
32 import aaf.v2_0.Error;\r
33 \r
34 import com.att.rosetta.env.RosettaDF;\r
35 import com.att.rosetta.env.RosettaData;\r
36 import com.att.rosetta.env.RosettaEnv;\r
37 \r
38 public class JU_Content {\r
39 \r
40         @BeforeClass\r
41         public static void setUpBeforeClass() throws Exception {\r
42         }\r
43 \r
44         @AfterClass\r
45         public static void tearDownAfterClass() throws Exception {\r
46         }\r
47 \r
48 \r
49         @Test\r
50         public void parseErrorJSON() throws Exception {\r
51                 final String msg = "{\"messageId\":\"SVC2000\",\"text\":\"Select which cred to delete (or 0 to delete all):" +\r
52                         "1) %1" +\r
53                         "2) %2" +\r
54                         "3) %3" +\r
55                         "4) %4" +\r
56                         "Run same command again with chosen entry as last parameter\"," +\r
57                         "\"variables\":[" +\r
58                         "\"m55555@jr583u.cred.test.com 1 Wed Oct 08 11:48:08 CDT 2014\"," +\r
59                         "\"m55555@jr583u.cred.test.com 1 Thu Oct 09 12:54:46 CDT 2014\"," +\r
60                         "\"m55555@jr583u.cred.test.com 1 Tue Jan 06 05:00:00 CST 2015\"," +\r
61                         "\"m55555@jr583u.cred.test.com 1 Wed Jan 07 05:00:00 CST 2015\"]}";\r
62                 \r
63                 Error err = new Error();\r
64                 err.setText("Hello");\r
65                 err.getVariables().add("I'm a teapot");\r
66                 err.setMessageId("12");\r
67                 \r
68                 \r
69 //              System.out.println(msg);\r
70                 RosettaEnv env = new RosettaEnv();\r
71                 RosettaDF<aaf.v2_0.Error> errDF = env.newDataFactory(aaf.v2_0.Error.class);\r
72                 errDF.in(RosettaData.TYPE.JSON);\r
73                 errDF.out(RosettaData.TYPE.JSON);\r
74                 RosettaData<Error> data = errDF.newData();\r
75                 data.load(err);\r
76                 System.out.println(data.asString());\r
77                 \r
78                 data.load(new StringReader(msg));\r
79                 err = data.asObject();\r
80                 System.out.println(err.getText());\r
81         }\r
82                 \r
83 \r
84 }\r