test_class.declarator: configSource
test_class.modifier: private
test_class.original_string: private ConsulConfigSource configSource;
test_class.type: ConsulConfigSource
test_class.var_name: configSource
test_class.file: configsource-consul/src/test/java/org/microprofileext/config/source/consul/ConsulConfigSourceTest.java
test_class.identifier: ConsulConfigSourceTest
test_case.body: @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());
      }
test_case.class_method_signature: ConsulConfigSourceTest.testGetProperties_one()
test_case.full_signature: @Test void testGetProperties_one()
test_case.identifier: testGetProperties_one
test_case.invocations: setValue encodeToString getEncoder getBytes thenReturn when getKVValue anyString getValue assertEquals size getProperties
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetProperties_one()
focal_class.declarator: NAME = "ConsulConfigSource"
focal_class.modifier: private static final
focal_class.original_string: private static final String NAME = "ConsulConfigSource";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: KEY_PREFIX = "configsource.consul."
focal_class.modifier: private static final
focal_class.original_string: private static final String KEY_PREFIX = "configsource.consul.";
focal_class.type: String
focal_class.var_name: KEY_PREFIX
focal_class.declarator: KEY_HOST = KEY_PREFIX + "host"
focal_class.modifier: private static final
focal_class.original_string: private static final String KEY_HOST = KEY_PREFIX + "host";
focal_class.type: String
focal_class.var_name: KEY_HOST
focal_class.declarator: DEFAULT_HOST = "localhost"
focal_class.modifier: private static final
focal_class.original_string: private static final String DEFAULT_HOST = "localhost";
focal_class.type: String
focal_class.var_name: DEFAULT_HOST
focal_class.declarator: KEY_VALIDITY = KEY_PREFIX + "validity"
focal_class.modifier: private static final
focal_class.original_string: private static final String KEY_VALIDITY = KEY_PREFIX + "validity";
focal_class.type: String
focal_class.var_name: KEY_VALIDITY
focal_class.declarator: DEFAULT_VALIDITY = 30L
focal_class.modifier: private static final
focal_class.original_string: private static final Long DEFAULT_VALIDITY = 30L;
focal_class.type: Long
focal_class.var_name: DEFAULT_VALIDITY
focal_class.declarator: KEY_CONSUL_PREFIX = KEY_PREFIX + "prefix"
focal_class.modifier: private static final
focal_class.original_string: private static final String KEY_CONSUL_PREFIX = KEY_PREFIX + "prefix";
focal_class.type: String
focal_class.var_name: KEY_CONSUL_PREFIX
focal_class.declarator: substitutor = new StringSubstitutor(s -> getConfig().getOptionalValue(s, String.class).orElse(""))
focal_class.modifier: private final
focal_class.original_string: private final StringSubstitutor substitutor = new StringSubstitutor(s -> getConfig().getOptionalValue(s, String.class).orElse(""));
focal_class.type: StringSubstitutor
focal_class.var_name: substitutor
focal_class.declarator: client = null
focal_class.original_string: ConsulClient client = null;
focal_class.type: ConsulClient
focal_class.var_name: client
focal_class.declarator: validity = null
focal_class.modifier: private
focal_class.original_string: private Long validity = null;
focal_class.type: Long
focal_class.var_name: validity
focal_class.declarator: prefix = null
focal_class.modifier: private
focal_class.original_string: private String prefix = null;
focal_class.type: String
focal_class.var_name: prefix
focal_class.declarator: cache = new ConcurrentHashMap<>()
focal_class.modifier: private final
focal_class.original_string: private final Map<String, TimedEntry> cache = new ConcurrentHashMap<>();
focal_class.type: Map<String, TimedEntry>
focal_class.var_name: cache
focal_class.file: configsource-consul/src/main/java/org/microprofileext/config/source/consul/ConsulConfigSource.java
focal_class.identifier: ConsulConfigSource
focal_class.class_method_signature: ConsulConfigSource.ConsulConfigSource()
focal_class.full_signature: public  ConsulConfigSource()
focal_class.identifier: ConsulConfigSource
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  ConsulConfigSource()
focal_class.class_method_signature: ConsulConfigSource.ConsulConfigSource(ConsulClient client)
focal_class.full_signature: public  ConsulConfigSource(ConsulClient client)
focal_class.identifier: ConsulConfigSource
focal_class.modifiers: public
focal_class.parameters: (ConsulClient client)
focal_class.signature:  ConsulConfigSource(ConsulClient client)
focal_class.class_method_signature: ConsulConfigSource.getPropertiesIfEnabled()
focal_class.full_signature: @Override public Map<String, String> getPropertiesIfEnabled()
focal_class.identifier: getPropertiesIfEnabled
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getPropertiesIfEnabled()
focal_class.class_method_signature: ConsulConfigSource.getValue(String key)
focal_class.full_signature: @Override public String getValue(String key)
focal_class.identifier: getValue
focal_class.modifiers: @Override public
focal_class.parameters: (String key)
focal_class.return: String
focal_class.signature: String getValue(String key)
focal_class.class_method_signature: ConsulConfigSource.getName()
focal_class.full_signature: @Override public String getName()
focal_class.identifier: getName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: ConsulConfigSource.getValidity()
focal_class.full_signature: private Long getValidity()
focal_class.identifier: getValidity
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Long
focal_class.signature: Long getValidity()
focal_class.class_method_signature: ConsulConfigSource.getPrefix()
focal_class.full_signature: private String getPrefix()
focal_class.identifier: getPrefix
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getPrefix()
focal_class.class_method_signature: ConsulConfigSource.getClient()
focal_class.full_signature: private ConsulClient getClient()
focal_class.identifier: getClient
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: ConsulClient
focal_class.signature: ConsulClient getClient()
focal_class.superclass: extends EnabledConfigSource
focal_method.body: @Override
      public String getValue(String key) {
          if (key.startsWith(KEY_PREFIX)) {
              // in case we are about to configure ourselves we simply ignore that key
              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();
          
      }
focal_method.class_method_signature: ConsulConfigSource.getValue(String key)
focal_method.full_signature: @Override public String getValue(String key)
focal_method.identifier: getValue
focal_method.invocations: startsWith get isExpired log getValue getKVValue getClient getPrefix log getMessage getValue put getDecodedValue put getValue
focal_method.modifiers: @Override public
focal_method.parameters: (String key)
focal_method.return: String
focal_method.signature: String getValue(String key)