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 static junit.framework.Assert.assertEquals;
25 import static junit.framework.Assert.assertTrue;
27 import java.util.GregorianCalendar;
29 import org.onap.aaf.misc.env.util.Chrono;
31 import aaf.v2_0.NsAttribRequest;
32 import aaf.v2_0.NsAttribRequest.Attrib;
34 public class NSAttribCompare extends RosettaCompare<NsAttribRequest> {
35 public NSAttribCompare() {
36 super(NsAttribRequest.class);
39 public static NsAttribRequest create() {
40 NsAttribRequest nar = new NsAttribRequest();
41 String in = instance();
43 nar.setNs("org.osaaf.ns"+in);
44 Attrib attrib = new Attrib();
46 attrib.setValue("v"+instance());
47 nar.getAttrib().add(attrib);
48 attrib = new Attrib();
49 attrib.setKey("scamp");
50 attrib.setValue("v"+instance());
51 nar.getAttrib().add(attrib);
52 GregorianCalendar gc = new GregorianCalendar();
53 nar.setStart(Chrono.timeStamp(gc));
54 gc.add(GregorianCalendar.MONTH, 1);
55 nar.setEnd(Chrono.timeStamp(gc));
60 public void compare(NsAttribRequest t1, NsAttribRequest t2) {
61 assertEquals(t1.getNs(),t2.getNs());
62 for (Attrib a1 : t1.getAttrib()) {
64 for (Attrib a2 : t2.getAttrib()) {
65 if (a1.getKey().equals(a2.getKey()) &&
66 a1.getValue().equals(a2.getValue())) {
71 assertTrue("a2 Attribs in a1",ok);
73 for (Attrib a2 : t2.getAttrib()) {
75 for (Attrib a1 : t1.getAttrib()) {
76 if (a1.getKey().equals(a2.getKey()) &&
77 a1.getValue().equals(a2.getValue())) {
82 assertTrue("a2 Attribs in a1",ok);
84 assertEquals(t1.getStart(),t2.getStart());
85 assertEquals(t1.getEnd(),t2.getEnd());
90 public NsAttribRequest newOne() {