AT&T 2.0.19 Code drop, stage 3
[aaf/authz.git] / auth / auth-core / src / test / java / org / onap / aaf / auth / request / test / NSCompare.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
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 package org.onap.aaf.auth.request.test;
23
24 import static junit.framework.Assert.assertEquals;
25 import static junit.framework.Assert.assertTrue;
26
27 import java.util.GregorianCalendar;
28
29 import org.onap.aaf.misc.env.util.Chrono;
30
31 import aaf.v2_0.NsRequest;
32
33 public class NSCompare extends RosettaCompare<NsRequest>  {
34         public NSCompare() {
35                 super(NsRequest.class);
36         }
37         
38         public static NsRequest create() {
39                 NsRequest nsr = new NsRequest();
40                 String in = instance();
41                 nsr.setName("org.osaaf.ns"+in);
42                 nsr.setDescription("Hello World"+in);
43                 nsr.getAdmin().add("Fred"+in);
44                 nsr.getAdmin().add("Barney"+in);
45                 nsr.getResponsible().add("Wilma"+in);
46                 nsr.getResponsible().add("Betty"+in);
47                 nsr.setType("Hello"+in);
48                 GregorianCalendar gc = new GregorianCalendar();
49                 nsr.setStart(Chrono.timeStamp(gc));
50                 gc.add(GregorianCalendar.MONTH, 1);
51                 nsr.setEnd(Chrono.timeStamp(gc));
52                 return nsr;
53         }
54         
55         @Override
56         public void compare(NsRequest t1, NsRequest t2) {
57                 assertEquals(t1.getName(),t2.getName());
58                 assertEquals(t1.getDescription(),t2.getDescription());
59                 for(String s : t1.getAdmin()) {
60                         assertTrue(t2.getAdmin().contains(s));
61                 }
62                 for(String s : t2.getAdmin()) {
63                         assertTrue(t1.getAdmin().contains(s));
64                 }
65                 assertEquals(t1.getType(),t2.getType());
66                 assertEquals(t1.getStart(),t2.getStart());
67                 assertEquals(t1.getEnd(),t2.getEnd());
68         }
69
70
71         @Override
72         public NsRequest newOne() {
73                 return create();
74         }
75 }