AT&T 2.0.19 Code drop, stage 3
[aaf/authz.git] / auth / auth-core / src / test / java / org / onap / aaf / auth / request / test / RolePermCompare.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
26 import java.util.GregorianCalendar;
27
28 import org.onap.aaf.misc.env.util.Chrono;
29
30 import aaf.v2_0.Pkey;
31 import aaf.v2_0.RolePermRequest;
32
33 public class RolePermCompare extends RosettaCompare<RolePermRequest>  {
34         public RolePermCompare() {
35                 super(RolePermRequest.class);
36         }
37         
38         public static RolePermRequest create() {
39                 RolePermRequest urr = new RolePermRequest();
40                 String in = instance();
41                 urr.setRole("org.osaaf.ns.role"+in);
42                 Pkey pkey = new Pkey();
43                 pkey.setType("org.osaaf.ns.myType"+in);
44                 pkey.setInstance("myInstance"+in);
45                 pkey.setAction("myAction"+in);
46                 urr.setPerm(pkey);
47                 GregorianCalendar gc = new GregorianCalendar();
48                 urr.setStart(Chrono.timeStamp(gc));
49                 gc.add(GregorianCalendar.MONTH, 1);
50                 urr.setEnd(Chrono.timeStamp(gc));
51                 return urr;
52         }
53         
54         @Override
55         public void compare(RolePermRequest t1, RolePermRequest t2) {
56                 assertEquals(t1.getRole(),t2.getRole());
57                 assertEquals(t1.getPerm().getType(),t1.getPerm().getType());
58                 assertEquals(t1.getPerm().getInstance(),t1.getPerm().getInstance());
59                 assertEquals(t1.getPerm().getAction(),t1.getPerm().getAction());
60                 assertEquals(t1.getStart(),t2.getStart());
61                 assertEquals(t1.getEnd(),t2.getEnd());
62         }
63
64
65         @Override
66         public RolePermRequest newOne() {
67                 return create();
68         }
69 }