class WatchExample {

  private static final Logger logger = LoggerFactory.getLogger(WatchExample.class);

  @SuppressWarnings("java:S1604")
  public static void main(String[] args) {<FILL_FUNCTION_BODY>}

  private static Watch newConfigMapWatch(KubernetesClient client) {
    return client.configMaps().watch(new Watcher<ConfigMap>() {
      @Override
      public void eventReceived(Action action, ConfigMap resource) {
        logger.info("Watch event received {}: {}", action.name(), resource.getMetadata().getName());
      }

      @Override
      public void onClose(WatcherException e) {
        logger.error("Watch error received: {}", e.getMessage(), e);
      }

      @Override
      public void onClose() {
        logger.info("Watch gracefully closed");
      }
    });
  }

}

    try (
        KubernetesClient client = new KubernetesClientBuilder().build();
        Watch ignored = newConfigMapWatch(client)) {
      final String namespace = Optional.ofNullable(client.getNamespace()).orElse("default");
      final String name = "watch-config-map-test-" + generateId();
      final ConfigMap cm = client.configMaps().inNamespace(namespace).resource(new ConfigMapBuilder()
          .withNewMetadata().withName(name).endMetadata()
          .build())
          .createOrReplace();
      client.configMaps().inNamespace(namespace).withName(name)
          .patch(new ConfigMapBuilder().withNewMetadata().withName(name).endMetadata().addToData("key", "value").build());
      //noinspection Convert2Lambda
      client.configMaps().inNamespace(namespace).withName(name).edit(new Visitor<ObjectMetaBuilder>() {
        @Override
        public void visit(ObjectMetaBuilder omb) {
          omb.addToAnnotations("annotation", "value");
        }
      });
      client.configMaps().resource(cm).delete();
    } catch (Exception e) {
      logger.error("Global Error: {}", e.getMessage(), e);
    }
  
<no_super_class>