From 3bd0a6a0bcd1cec006500c60de20eb0904697263 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Tue, 21 Mar 2017 13:38:21 +0100 Subject: HONEYCOMB-348: include dump params in entity key Change-Id: I18b2ea3c897c467740f19bf346d13240aac458ac Signed-off-by: Marek Gradzki --- .../util/read/cache/DumpCacheManagerTest.java | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java') diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java index 74aef67d0..dfdcd089b 100644 --- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java +++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java @@ -80,7 +80,7 @@ public class DumpCacheManagerTest { @Test public void testCaching() throws ReadFailedException { final IpDetailsReplyDump stage1Data = new IpDetailsReplyDump(); - final String key = cacheKeyFactory.createKey(identifier); + final String key = cacheKeyFactory.createKey(identifier, NO_PARAMS); // executor cant return null data @@ -134,14 +134,14 @@ public class DumpCacheManagerTest { @Test public void testSameKeyDifferentTypes() throws ReadFailedException { final DumpCacheManager stringManager = - new DumpCacheManager.DumpCacheManagerBuilder() - .withExecutor((InstanceIdentifier, Void) -> "value") - .acceptOnly(String.class) - .build(); + new DumpCacheManager.DumpCacheManagerBuilder() + .withExecutor((InstanceIdentifier, Void) -> "value") + .acceptOnly(String.class) + .build(); final DumpCacheManager intManager = new DumpCacheManager.DumpCacheManagerBuilder() - .acceptOnly(Integer.class) - .withExecutor((InstanceIdentifier, Void) -> 3).build(); + .acceptOnly(Integer.class) + .withExecutor((InstanceIdentifier, Void) -> 3).build(); final Optional stringDump = stringManager.getDump(identifier, cache, NO_PARAMS); final Optional integerDump = intManager.getDump(identifier, cache, NO_PARAMS); @@ -153,6 +153,21 @@ public class DumpCacheManagerTest { } + @Test + public void testCachingWithDifferentParams() throws ReadFailedException { + final DumpCacheManager manager = + new DumpCacheManager.DumpCacheManagerBuilder() + .withExecutor((iid, param) -> param) + .acceptOnly(Integer.class) + .build(); + + final Optional dump1 = manager.getDump(identifier, cache, 1); + final Optional dump2 = manager.getDump(identifier, cache, 2); + + assertEquals(1, dump1.get().intValue()); + assertEquals(2, dump2.get().intValue()); + } + private EntityDumpPostProcessingFunction createPostProcessor() { return ipDetailsReplyDump -> { IpDetailsReplyDump modified = new IpDetailsReplyDump(); -- cgit 1.2.3-korg