1 /*******************************************************************************
2 * ============LICENSE_START====================================================
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
11 * * http://www.apache.org/licenses/LICENSE-2.0
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====================================================
21 ******************************************************************************/
22 package org.onap.aaf.content;
24 import java.io.StringReader;
26 import org.junit.AfterClass;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
29 import org.onap.aaf.misc.rosetta.env.RosettaDF;
30 import org.onap.aaf.misc.rosetta.env.RosettaData;
31 import org.onap.aaf.misc.rosetta.env.RosettaEnv;
33 import aaf.v2_0.Error;
35 public class JU_Content {
38 public static void setUpBeforeClass() throws Exception {
42 public static void tearDownAfterClass() throws Exception {
47 public void parseErrorJSON() throws Exception {
48 final String msg = "{\"messageId\":\"SVC2000\",\"text\":\"Select which cred to delete (or 0 to delete all):" +
53 "Run same command again with chosen entry as last parameter\"," +
55 "\"m55555@jr583u.cred.test.com 1 Wed Oct 08 11:48:08 CDT 2014\"," +
56 "\"m55555@jr583u.cred.test.com 1 Thu Oct 09 12:54:46 CDT 2014\"," +
57 "\"m55555@jr583u.cred.test.com 1 Tue Jan 06 05:00:00 CST 2015\"," +
58 "\"m55555@jr583u.cred.test.com 1 Wed Jan 07 05:00:00 CST 2015\"]}";
60 Error err = new Error();
62 err.getVariables().add("I'm a teapot");
63 err.setMessageId("12");
66 // System.out.println(msg);
67 RosettaEnv env = new RosettaEnv();
68 RosettaDF<aaf.v2_0.Error> errDF = env.newDataFactory(aaf.v2_0.Error.class);
69 errDF.in(RosettaData.TYPE.JSON);
70 errDF.out(RosettaData.TYPE.JSON);
71 RosettaData<Error> data = errDF.newData();
73 System.out.println(data.asString());
75 data.load(new StringReader(msg));
76 err = data.asObject();
77 System.out.println(err.getText());