Remove Tabs, per Jococo
[aaf/authz.git] / auth / auth-batch / src / test / java / org / onap / aaf / auth / batch / helpers / test / JU_ExpireRange.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 package org.onap.aaf.auth.batch.helpers.test;
22
23 import static org.junit.Assert.*;
24
25 import java.util.Date;
26 import java.util.GregorianCalendar;
27 import java.util.Set;
28
29 import org.junit.Test;
30 import org.onap.aaf.auth.batch.helpers.ExpireRange;
31 import org.onap.aaf.cadi.PropAccess;
32
33 public class JU_ExpireRange {
34     @Test
35     public void test() {
36         ExpireRange expRange = new ExpireRange(new PropAccess());
37         Date now = expRange.now();
38         
39         Set<String> names=expRange.names();
40         assertTrue(names.contains("OneMonth"));
41         assertTrue(names.contains("OneWeek"));
42         assertTrue(names.contains("Delete"));
43         assertFalse(names.contains(null));
44         assertFalse(names.contains("bogus"));
45         
46         ExpireRange.Range r;
47         GregorianCalendar gc = new GregorianCalendar();
48         String[] all = new String[] {"ur","cred"};
49         
50         // Test 3 weeks prior
51         gc.setTime(now);
52         gc.add(GregorianCalendar.WEEK_OF_MONTH,-3);
53         for(String rs : all) {
54             r = expRange.getRange(rs, gc.getTime());
55             assertNotNull(r);
56             assertEquals("Delete",r.name());
57         }
58         
59         // Test 1 week prior
60         gc.setTime(now);
61         gc.add(GregorianCalendar.WEEK_OF_MONTH,-1);
62         for(String rs : all) {
63             r = expRange.getRange(rs, gc.getTime());
64             assertNull(r);
65         }
66         
67         // Test Today
68         r = expRange.getRange("cred", now);
69         assertNotNull(r);
70     }
71
72 }