2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package org.onap.aaf.auth.request.test;
24 import org.onap.aaf.misc.env.APIException;
25 import org.onap.aaf.misc.env.Data;
26 import org.onap.aaf.misc.env.Data.TYPE;
27 import org.onap.aaf.misc.rosetta.env.RosettaDF;
28 import org.onap.aaf.misc.rosetta.env.RosettaData;
29 import org.onap.aaf.misc.rosetta.env.RosettaEnv;
31 public abstract class RosettaCompare<T> {
32 protected Class<T> cls;
33 private static int count = 0;
35 public RosettaCompare(Class<T> cls) {
39 public void run(RosettaEnv env) throws APIException {
40 RosettaDF<T> nsrDF = env.newDataFactory(cls);
41 compare(nsrDF.newData().option(Data.PRETTY),newOne(),this);
44 private void compare(RosettaData<T> rdt, T t, RosettaCompare<T> comp) throws APIException {
45 //System.out.println("########### Testing " + cls.getName() + " ##############");
46 String s = rdt.load(t).out(TYPE.JSON).asString();
47 //System.out.println(s);
48 T t2 = rdt.in(TYPE.JSON).load(s).asObject();
51 //System.out.println();
53 s = rdt.load(t).out(TYPE.XML).asString();
54 //System.out.println(s);
55 t2 = rdt.in(TYPE.XML).load(s).asObject();
59 public synchronized static String instance() {
63 public abstract void compare(T t1, T t2);
64 public abstract T newOne();