@Test void testGetProperties_one() { GetValue value = new GetValue(); value.setValue(Base64.getEncoder().encodeToString("hello".getBytes())); when(configSource.client.getKVValue(anyString())).thenReturn(new Response<GetValue>(value, 0L, true, 0L)); configSource.getValue("test"); assertEquals(1, configSource.getProperties().size()); }
@Override public String getValue(String key) { if (key.startsWith(KEY_PREFIX)) { return null; } TimedEntry entry = cache.get(key); if (entry == null || entry.isExpired()) { log.log(Level.FINE, "load {0} from consul", key); GetValue value = null; try { value = getClient().getKVValue(getPrefix() + key).getValue(); } catch (Exception e) { log.log(Level.WARNING, "consul getKVValue failed: {0}", e.getMessage()); if (entry != null) { return entry.getValue(); } } if (value == null) { cache.put(key, new TimedEntry(null)); return null; } String decodedValue = value.getDecodedValue(); cache.put(key, new TimedEntry(decodedValue)); return decodedValue; } return entry.getValue(); }
ConsulConfigSource extends EnabledConfigSource { @Override public String getValue(String key) { if (key.startsWith(KEY_PREFIX)) { return null; } TimedEntry entry = cache.get(key); if (entry == null || entry.isExpired()) { log.log(Level.FINE, "load {0} from consul", key); GetValue value = null; try { value = getClient().getKVValue(getPrefix() + key).getValue(); } catch (Exception e) { log.log(Level.WARNING, "consul getKVValue failed: {0}", e.getMessage()); if (entry != null) { return entry.getValue(); } } if (value == null) { cache.put(key, new TimedEntry(null)); return null; } String decodedValue = value.getDecodedValue(); cache.put(key, new TimedEntry(decodedValue)); return decodedValue; } return entry.getValue(); } }
ConsulConfigSource extends EnabledConfigSource { @Override public String getValue(String key) { if (key.startsWith(KEY_PREFIX)) { return null; } TimedEntry entry = cache.get(key); if (entry == null || entry.isExpired()) { log.log(Level.FINE, "load {0} from consul", key); GetValue value = null; try { value = getClient().getKVValue(getPrefix() + key).getValue(); } catch (Exception e) { log.log(Level.WARNING, "consul getKVValue failed: {0}", e.getMessage()); if (entry != null) { return entry.getValue(); } } if (value == null) { cache.put(key, new TimedEntry(null)); return null; } String decodedValue = value.getDecodedValue(); cache.put(key, new TimedEntry(decodedValue)); return decodedValue; } return entry.getValue(); } ConsulConfigSource();  ConsulConfigSource(ConsulClient client); }
ConsulConfigSource extends EnabledConfigSource { @Override public String getValue(String key) { if (key.startsWith(KEY_PREFIX)) { return null; } TimedEntry entry = cache.get(key); if (entry == null || entry.isExpired()) { log.log(Level.FINE, "load {0} from consul", key); GetValue value = null; try { value = getClient().getKVValue(getPrefix() + key).getValue(); } catch (Exception e) { log.log(Level.WARNING, "consul getKVValue failed: {0}", e.getMessage()); if (entry != null) { return entry.getValue(); } } if (value == null) { cache.put(key, new TimedEntry(null)); return null; } String decodedValue = value.getDecodedValue(); cache.put(key, new TimedEntry(decodedValue)); return decodedValue; } return entry.getValue(); } ConsulConfigSource();  ConsulConfigSource(ConsulClient client); @Override Map<String, String> getPropertiesIfEnabled(); @Override String getValue(String key); @Override String getName(); }
ConsulConfigSource extends EnabledConfigSource { @Override public String getValue(String key) { if (key.startsWith(KEY_PREFIX)) { return null; } TimedEntry entry = cache.get(key); if (entry == null || entry.isExpired()) { log.log(Level.FINE, "load {0} from consul", key); GetValue value = null; try { value = getClient().getKVValue(getPrefix() + key).getValue(); } catch (Exception e) { log.log(Level.WARNING, "consul getKVValue failed: {0}", e.getMessage()); if (entry != null) { return entry.getValue(); } } if (value == null) { cache.put(key, new TimedEntry(null)); return null; } String decodedValue = value.getDecodedValue(); cache.put(key, new TimedEntry(decodedValue)); return decodedValue; } return entry.getValue(); } ConsulConfigSource();  ConsulConfigSource(ConsulClient client); @Override Map<String, String> getPropertiesIfEnabled(); @Override String getValue(String key); @Override String getName();  }