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