/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.ocelotds.core;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;

/**
 *
 * @author hhfrancois
 */
public class UpdatedCacheManagerTest {
	
	/**
	 * Test of receiveCacheRemoveEvent method, of class UpdatedCacheManager.
	 */
	@Test
	public void testReceiveCacheRemoveEvent() {
		System.out.println("receiveCacheRemoveEvent");
		String cachekey = UUID.randomUUID().toString();
		Map<String, Long> map = new HashMap<>();
		Date now = new Date();
		map.put(cachekey, now.getTime());
		UpdatedCacheManager instance = new UpdatedCacheManager();
		instance.receiveCacheRemoveEvent(cachekey);
		Collection<String> result = instance.getOutDatedCache(map);
		assertThat(result).contains(cachekey);
	}
}

@@ -519,14 +519,53 @@
 %0A%09%0D%0A
+%09private static long DELAY = 1000;%0D%0A%09%0D%0A
 %09/**%0D%0A
-
 %09 * 
@@ -670,31 +670,24 @@
 test
-ReceiveCacheRemoveEvent
+GetOutDatedCache
 () %7B
@@ -710,39 +710,32 @@
 rintln(%22
-receiveCacheRemoveEvent
+getOutDatedCache
 %22);%0D%0A%09%09S
@@ -885,16 +885,22 @@
 etTime()
+-DELAY
 );%0D%0A%09%09Up
@@ -1066,16 +1066,16 @@
 (map);%0D%0A
-
 %09%09assert
@@ -1111,12 +1111,582 @@
 y);%0D%0A%09%7D%0D
+%0A%0D%0A%09/**%0D%0A%09 * Test of receiveCacheRemoveEvent method, of class UpdatedCacheManager.%0D%0A%09 */%0D%0A%09@Test%0D%0A%09public void testGetNoOutDatedCache() %7B%0D%0A%09%09System.out.println(%22getNoOutDatedCache%22);%0D%0A%09%09String cachekey = UUID.randomUUID().toString();%0D%0A%09%09Map%3CString, Long%3E map = new HashMap%3C%3E();%0D%0A%09%09Date now = new Date();%0D%0A%09%09map.put(cachekey, now.getTime()+DELAY);%0D%0A%09%09UpdatedCacheManager instance = new UpdatedCacheManager();%0D%0A%09%09instance.receiveCacheRemoveEvent(cachekey);%0D%0A%09%09Collection%3CString%3E result = instance.getOutDatedCache(map);%0D%0A%09%09assertThat(result).doesNotContain(cachekey);%0D%0A%09%7D%0D
 %0A%7D%0D%0A

improve test