package bio.terra.workspace.app.configuration.external;

import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * WSM Applications are clients of WSM that create a special class of resources: application-owned
 * resources. Being a configured WSM application gives the client control over the lifecycle and
 * configuration of their resources. Workspace users do not have control the way they would for
 * user-created resources. WSM application in this context refers to some piece of middleware that
 * may or may not interact with what a user would call an application.
 */
@Configuration
@EnableConfigurationProperties
@ConfigurationProperties(prefix = "workspace.application")
public class WsmApplicationConfiguration {
  public static class App {
    private String name;
    private String description;
    private String serviceAccount;
    private String state;

    public String getName() {
      return name;
    }

    public void setName(String name) {
      this.name = name;
    }

    public String getDescription() {
      return description;
    }

    public void setDescription(String description) {
      this.description = description;
    }

    public String getServiceAccount() {
      return serviceAccount;
    }

    public void setServiceAccount(String serviceAccount) {
      this.serviceAccount = serviceAccount;
    }

    public String getState() {
      return state;
    }

    public void setState(String state) {
      this.state = state;
    }
  }

  // Configurations by name
  Map<String, App> configurations;

  public Map<String, App> getConfigurations() {
    return configurations;
  }

  public void setConfigurations(Map<String, App> configurations) {
    this.configurations = configurations;
  }
}

@@ -67,19 +67,76 @@
 va.util.
-Map
+Collections;%0Aimport java.util.Map;%0Aimport java.util.Optional
 ;%0Aimport
@@ -1853,30 +1853,82 @@
  return 
-configurations
+Optional.ofNullable(configurations).orElse(Collections.emptyMap())
 ;%0A  %7D%0A%0A 

Return empty application map from config instead of null (#581)