@Test public void testPutSingleKey() throws Exception { final String expected = "putSingleValue"; LocalLookupConfig conf = new LocalLookupConfig(); LocalStore localStore = new LocalStore(conf); localStore.put("putSingleKey", expected); Optional<String> value = localStore.get("putSingleKey"); localStore.close(); assertTrue(value.isPresent()); assertEquals(expected, value.get()); }
@Test public void testGetSingleKey() throws Exception { final String expected = "value1"; LocalLookupConfig conf = new LocalLookupConfig(); conf.values = ImmutableMap.of("key1", "value1", "key2", "value2", "key3", "value3"); LocalStore localStore = new LocalStore(conf); Optional<String> value = localStore.get("key1"); localStore.close(); assertTrue(value.isPresent()); assertEquals(expected, value.get()); }
@Test public void testGetMultipleKeys() throws Exception { List<String> keys = ImmutableList.of("key1", "key2", "key3", "key4"); Map<String, Optional<?>> expected = ImmutableMap.of( "key1", Optional.of("value1"), "key2", Optional.of("value2"), "key3", Optional.of("value3"), "key4", Optional.absent()); LocalLookupConfig conf = new LocalLookupConfig(); conf.values = ImmutableMap.of("key1", "value1", "key2", "value2", "key3", "value3"); LocalStore localStore = new LocalStore(conf); Map<String, Optional<String>> values = localStore.get(keys); localStore.close(); assertEquals(keys.size(), values.size()); assertEquals(expected.toString(), values.toString()); }