Fix for Penetration test _ Session and cookie management
[vid.git] / vid-app-common / src / test / java / org / onap / vid / aai / util / CacheConfigTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.vid.aai.util;
22
23 import org.testng.annotations.Test;
24
25 import static org.testng.AssertJUnit.assertEquals;
26
27 public class CacheConfigTest {
28
29     @Test
30     public void whenDeserializeJson_ValuesReadAsExpected() {
31         CacheConfigProvider cacheConfigProvider = new CacheConfigProviderImpl();
32         CacheConfig cacheConfigA = cacheConfigProvider.getCacheConfig("a");
33         assertEquals(true, cacheConfigA.isActive());
34         assertEquals(6L, cacheConfigA.getExpireAfterWriteHours());
35         assertEquals(9L, cacheConfigA.getRefreshAfterWriteSeconds());
36
37         //entry exist in configuration, but with no values
38         CacheConfig cacheConfigB = cacheConfigProvider.getCacheConfig("b");
39         assertEquals(cacheConfigB.isActive(), CacheConfig.Companion.getDefaultCacheConfig().isActive());
40         assertEquals(cacheConfigB.getExpireAfterWriteHours(), CacheConfig.Companion.getDefaultCacheConfig().getExpireAfterWriteHours());
41         assertEquals(cacheConfigB.getRefreshAfterWriteSeconds(), CacheConfig.Companion.getDefaultCacheConfig().getRefreshAfterWriteSeconds());
42
43
44         //entry doesn't exist in configuration
45         CacheConfig cacheConfigC = cacheConfigProvider.getCacheConfig("c");
46         assertEquals(CacheConfig.Companion.getDefaultCacheConfig(), cacheConfigC);
47
48         CacheConfig cacheConfigD = cacheConfigProvider.getCacheConfig("d");
49         assertEquals(false, cacheConfigD.isActive());
50
51     }
52 }