code: public static Tenant getTenant(ApplicationDefinition appDef) {
          String tenantName = appDef.getTenantName();
          if (Utils.isEmpty(tenantName)) {
              return TenantService.instance().getDefaultTenant();
          }
          TenantDefinition tenantDef = TenantService.instance().getTenantDefinition(tenantName);
          Utils.require(tenantDef != null, "Tenant definition does not exist: %s", tenantName);
          return new Tenant(tenantDef);
      }
docs: Create a Tenant object from the given application definition. If the application
  does not define a tenant, the Tenant for the default database is returned.
  
  @param appDef    {@link ApplicationDefinition}
  @return          {@link Tenant} in which application resides.