2 * ============LICENSE_START=======================================================
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
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.vid.aai.util;
23 import org.testng.annotations.Test;
25 import static org.testng.AssertJUnit.assertEquals;
27 public class CacheConfigTest {
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());
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());
44 //entry doesn't exist in configuration
45 CacheConfig cacheConfigC = cacheConfigProvider.getCacheConfig("c");
46 assertEquals(CacheConfig.Companion.getDefaultCacheConfig(), cacheConfigC);
48 CacheConfig cacheConfigD = cacheConfigProvider.getCacheConfig("d");
49 assertEquals(false, cacheConfigD.isActive());