hunk.code_window: import static com.appsmith.server.acl.AclPermission.USER_MANAGE_ORGANIZATIONS;
   import static org.assertj.core.api.Assertions.assertThat;
   @Slf4j
  
hunk.labels: add keep keep keep
hunk.after_edit: import static com.appsmith.server.acl.AclPermission.USER_READ_ORGANIZATIONS;
  
hunk.file_path: app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java
hunk.type: add
file: package com.appsmith.server.domains;
  
  import com.appsmith.external.models.BaseDomain;
  import com.appsmith.external.models.DatasourceConfiguration;
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import com.fasterxml.jackson.annotation.JsonProperty;
  import lombok.Getter;
  import lombok.NoArgsConstructor;
  import lombok.Setter;
  import lombok.ToString;
  import org.springframework.data.annotation.Transient;
  import org.springframework.data.mongodb.core.mapping.Document;
  import org.springframework.util.CollectionUtils;
  
  import java.util.Set;
  
  @Getter
  @Setter
  @ToString
  @NoArgsConstructor
  @Document
  public class Datasource extends BaseDomain {
      String name;
  
      String pluginId;
  
      String organizationId;
  
      DatasourceConfiguration datasourceConfiguration;
  
      @JsonProperty(access = JsonProperty.Access.READ_ONLY)
      Set<String> invalids;
  
      /*
       * This field is used to determine if the Datasource has been generated by the client or auto-generated by the system.
       * We use this field because when embedded datasources are null, spring-data auditable interfaces throw exceptions
       * while trying set createdAt and updatedAt properties on the null object
       */
      @Transient
      @JsonIgnore
      Boolean isAutoGenerated = false;
  
      /**
       * This method is here so that the JSON version of this class' instances have a `isValid` field, for backwards
       * compatibility. It may be removed, when sure that no API received is relying on this field.
       *
       * @return boolean, indicating whether this datasource is valid or not.
       */
      public boolean getIsValid() {
          return CollectionUtils.isEmpty(invalids);
      }
  }
  