test_class.declarator: ITEM_NAME = "itemName"
test_class.modifier: private static final
test_class.original_string: private static final String ITEM_NAME = "itemName";
test_class.type: String
test_class.var_name: ITEM_NAME
test_class.declarator: managedProviderRef
test_class.modifier: @SuppressWarnings("rawtypes")
      private @Mock
test_class.original_string: @SuppressWarnings("rawtypes")
      private @Mock ServiceReference managedProviderRef;
test_class.type: ServiceReference
test_class.var_name: managedProviderRef
test_class.declarator: bundleContext
test_class.modifier: private @Mock
test_class.original_string: private @Mock BundleContext bundleContext;
test_class.type: BundleContext
test_class.var_name: bundleContext
test_class.declarator: managedProvider
test_class.modifier: private @Mock
test_class.original_string: private @Mock ManagedMetadataProvider managedProvider;
test_class.type: ManagedMetadataProvider
test_class.var_name: managedProvider
test_class.declarator: metadataRegistry
test_class.modifier: private @Mock
test_class.original_string: private @Mock MetadataRegistryImpl metadataRegistry;
test_class.type: MetadataRegistryImpl
test_class.var_name: metadataRegistry
test_class.declarator: commandDescriptionProvider
test_class.modifier: private
test_class.original_string: private MetadataCommandDescriptionProvider commandDescriptionProvider;
test_class.type: MetadataCommandDescriptionProvider
test_class.var_name: commandDescriptionProvider
test_class.declarator: providerTracker
test_class.modifier: private
test_class.original_string: private ServiceListener providerTracker;
test_class.type: ServiceListener
test_class.var_name: providerTracker
test_class.file: bundles/org.openhab.core/src/test/java/org/openhab/core/internal/items/MetadataCommandDescriptionProviderTest.java
test_class.identifier: MetadataCommandDescriptionProviderTest
test_case.body: @Test
      public void testEmptyConfig() throws Exception {
          MetadataKey metadataKey = new MetadataKey("commandDescription", ITEM_NAME);
          // Map<String, Object> metadataConfig = new HashMap<>();
          Metadata metadata = new Metadata(metadataKey, "N/A", null);
  
          metadataRegistry.added(managedProvider, metadata);
          CommandDescription commandDescription = commandDescriptionProvider.getCommandDescription(ITEM_NAME, null);
          assertNull(commandDescription);
      }
test_case.class_method_signature: MetadataCommandDescriptionProviderTest.testEmptyConfig()
test_case.full_signature: @Test public void testEmptyConfig()
test_case.identifier: testEmptyConfig
test_case.invocations: added getCommandDescription assertNull
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEmptyConfig()
focal_class.declarator: logger = LoggerFactory.getLogger(MetadataCommandDescriptionProvider.class)
focal_class.modifier: private final
focal_class.original_string: private final Logger logger = LoggerFactory.getLogger(MetadataCommandDescriptionProvider.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: COMMANDDESCRIPTION_METADATA_NAMESPACE = "commandDescription"
focal_class.modifier: public static final
focal_class.original_string: public static final String COMMANDDESCRIPTION_METADATA_NAMESPACE = "commandDescription";
focal_class.type: String
focal_class.var_name: COMMANDDESCRIPTION_METADATA_NAMESPACE
focal_class.declarator: metadataRegistry
focal_class.modifier: private
focal_class.original_string: private MetadataRegistry metadataRegistry;
focal_class.type: MetadataRegistry
focal_class.var_name: metadataRegistry
focal_class.file: bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataCommandDescriptionProvider.java
focal_class.identifier: MetadataCommandDescriptionProvider
focal_class.interfaces: implements CommandDescriptionProvider
focal_class.class_method_signature: MetadataCommandDescriptionProvider.MetadataCommandDescriptionProvider(final @Reference MetadataRegistry metadataRegistry,
              Map<String, Object> properties)
focal_class.full_signature: @Activate public  MetadataCommandDescriptionProvider(final @Reference MetadataRegistry metadataRegistry,
              Map<String, Object> properties)
focal_class.identifier: MetadataCommandDescriptionProvider
focal_class.modifiers: @Activate public
focal_class.parameters: (final @Reference MetadataRegistry metadataRegistry,
              Map<String, Object> properties)
focal_class.signature:  MetadataCommandDescriptionProvider(final @Reference MetadataRegistry metadataRegistry,
              Map<String, Object> properties)
focal_class.class_method_signature: MetadataCommandDescriptionProvider.getCommandDescription(String itemName, @Nullable Locale locale)
focal_class.full_signature: @Override public @Nullable CommandDescription getCommandDescription(String itemName, @Nullable Locale locale)
focal_class.identifier: getCommandDescription
focal_class.modifiers: @Override public @Nullable
focal_class.parameters: (String itemName, @Nullable Locale locale)
focal_class.return: CommandDescription
focal_class.signature: CommandDescription getCommandDescription(String itemName, @Nullable Locale locale)
focal_method.body: @Override
      public @Nullable CommandDescription getCommandDescription(String itemName, @Nullable Locale locale) {
          Metadata metadata = metadataRegistry.get(new MetadataKey(COMMANDDESCRIPTION_METADATA_NAMESPACE, itemName));
  
          if (metadata != null) {
              try {
                  CommandDescriptionImpl commandDescription = new CommandDescriptionImpl();
                  if (metadata.getConfiguration().containsKey("options")) {
                      Stream.of(metadata.getConfiguration().get("options").toString().split(",")).forEach(o -> {
                          if (o.contains("=")) {
                              commandDescription.addCommandOption(
                                      new CommandOption(o.split("=")[0].trim(), o.split("=")[1].trim()));
                          } else {
                              commandDescription.addCommandOption(new CommandOption(o.trim(), null));
                          }
                      });
  
                      return commandDescription;
                  }
              } catch (Exception e) {
                  logger.warn("Unable to parse the commandDescription from metadata for item {}, ignoring it", itemName);
                  return null;
              }
          }
  
          return null;
      }
focal_method.class_method_signature: MetadataCommandDescriptionProvider.getCommandDescription(String itemName, @Nullable Locale locale)
focal_method.full_signature: @Override public @Nullable CommandDescription getCommandDescription(String itemName, @Nullable Locale locale)
focal_method.identifier: getCommandDescription
focal_method.invocations: get containsKey getConfiguration forEach of split toString get getConfiguration contains addCommandOption trim split trim split addCommandOption trim warn
focal_method.modifiers: @Override public @Nullable
focal_method.parameters: (String itemName, @Nullable Locale locale)
focal_method.return: CommandDescription
focal_method.signature: CommandDescription getCommandDescription(String itemName, @Nullable Locale locale)