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====================================================
21 package org.onap.aaf.auth.batch.helpers.test;
23 import static org.junit.Assert.*;
25 import java.util.GregorianCalendar;
28 import org.junit.Test;
29 import org.onap.aaf.auth.batch.helpers.ExpireRange;
30 import org.onap.aaf.cadi.PropAccess;
32 public class JU_ExpireRange {
35 ExpireRange expRange = new ExpireRange(new PropAccess());
37 Set<String> names=expRange.names();
38 assertTrue(names.contains("OneMonth"));
39 assertTrue(names.contains("CredOneWeek"));
40 assertTrue(names.contains("Delete"));
41 assertFalse(names.contains(null));
42 assertFalse(names.contains("bogus"));
45 GregorianCalendar gc = new GregorianCalendar();
46 String[] all = new String[] {"ur","cred"};
49 gc.setTime(expRange.now);
50 gc.add(GregorianCalendar.WEEK_OF_MONTH,-3);
51 for(String rs : all) {
52 r = expRange.getRange(rs, gc.getTime());
54 assertEquals("Delete",r.name());
55 assertFalse(r.shouldContact(null));
59 gc.setTime(expRange.now);
60 gc.add(GregorianCalendar.WEEK_OF_MONTH,-1);
61 for(String rs : all) {
62 r = expRange.getRange(rs, gc.getTime());
67 r = expRange.getRange("cred", expRange.now);