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