+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package com.att.dao;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Timer;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.att.authz.env.AuthzEnv;\r
-import com.att.authz.env.AuthzTrans;\r
-import com.att.authz.layer.Result;\r
-import com.att.cache.Cache;\r
-import com.att.cache.Cache.Dated;\r
-import com.att.dao.Cached.Getter;\r
-//import com.att.dao.Cached.Refresh;\r
-import com.att.inno.env.Trans;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_Cached {\r
- Cached cached;\r
- @Mock\r
- CIDAO<Trans> ciDaoMock;\r
- @Mock\r
- AuthzEnv authzEnvMock;\r
- @Mock\r
- CIDAO<AuthzTrans> cidaoATMock;\r
- \r
- String name = "nameString";\r
- \r
- @Before\r
- public void setUp(){\r
- cached = new Cached(ciDaoMock, name, 0);\r
- }\r
- \r
- @Test(expected=ArithmeticException.class)\r
- public void testCachedIdx(){\r
- int Result = cached.cacheIdx("1234567890"); \r
- }\r
- \r
- @Test(expected=ArithmeticException.class)\r
- public void testInvalidate(){\r
- int Res = cached.invalidate(name);\r
- }\r
- \r
- @SuppressWarnings("static-access")\r
- @Test\r
- public void testStopTimer(){\r
- cached.stopTimer();\r
- assertTrue(true);\r
- }\r
-\r
- @SuppressWarnings("static-access")\r
- @Test\r
- public void testStartRefresh(){\r
- cached.startRefresh(authzEnvMock, cidaoATMock);\r
- assertTrue(true);\r
- }\r
-// @Mock\r
-// Trans transMock;\r
-// @Mock\r
-// Getter<DAO> getterMock;\r
-// \r
-// @Test\r
-// public void testGet(){\r
-// cached.get(transMock, name, getterMock);\r
-// fail("not implemented");\r
-// }\r
-// \r
-// @SuppressWarnings("unchecked")\r
-// public Result<List<DATA>> get(TRANS trans, String key, Getter<DATA> getter) {\r
-// List<DATA> ld = null;\r
-// Result<List<DATA>> rld = null;\r
-// \r
-// int cacheIdx = cacheIdx(key);\r
-// Map<String, Dated> map = ((Map<String,Dated>)cache[cacheIdx]);\r
-// \r
-// // Check for saved element in cache\r
-// Dated cached = map.get(key);\r
-// // Note: These Segment Timestamps are kept up to date with DB\r
-// Date dbStamp = info.get(trans, name,cacheIdx);\r
-// \r
-// // Check for cache Entry and whether it is still good (a good Cache Entry is same or after DBEntry, so we use "before" syntax)\r
-// if(cached!=null && dbStamp.before(cached.timestamp)) {\r
-// ld = (List<DATA>)cached.data;\r
-// rld = Result.ok(ld);\r
-// } else {\r
-// rld = getter.get();\r
-// if(rld.isOK()) { // only store valid lists\r
-// map.put(key, new Dated(rld.value)); // successful item found gets put in cache\r
-//// } else if(rld.status == Result.ERR_Backend){\r
-//// map.remove(key);\r
-// }\r
-// }\r
-// return rld;\r
-// }\r
-}\r