// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/connector/beans/ResourcePoolBean.java
// public class ResourcePoolBean implements VmwareManagedEntity, Comparable<ResourcePoolBean> {
//   private final String myName;
//   private final ManagedObjectReference myMOR;
//   private final String myPath;
//   private final ManagedObjectReference myParentRef;
//   private final String myDatacenterId;
// 
// 
//   @Used("Tests")
//   public ResourcePoolBean(final ResourcePool rp){
//     this(rp.getMOR(), rp.getName(), null, rp.getParent().getMOR(), "dc");
//   }
// 
//   public ResourcePoolBean(@NotNull final ManagedObjectReference mor,
//                           @NotNull final String name,
//                           @NotNull final String path,
//                           @Nullable final ManagedObjectReference parentRef,
//                           @Nullable final String datacenterId) {
//     myName = name;
//     myMOR = mor;
//     myPath = path;
//     myParentRef = parentRef;
//     myDatacenterId = datacenterId;
//   }
// 
//   @NotNull
//   @Override
//   public String getId() {
//     return myMOR.getVal();
//   }
// 
//   @NotNull
//   public String getName() {
//     return myName;
//   }
// 
//   @NotNull
//   @Override
//   public String getPath() {
//     return myPath;
//   }
// 
//   @Nullable
//   @Override
//   public String getDatacenterId() {
//     return myDatacenterId;
//   }
// 
//   @NotNull
//   @Override
//   public ManagedObjectReference getMOR() {
//     return myMOR;
//   }
// 
//   @Nullable
//   @Override
//   public ManagedObjectReference getParentMOR() {
//     return myParentRef;
//   }
// 
//   @Override
//   public int compareTo(@NotNull final ResourcePoolBean o) {
//     if (myPath == null && o.myPath == null){
//       return StringUtil.compare(StringUtil.toLowerCase(myName), StringUtil.toLowerCase(o.myName));
//     }
//     return StringUtil.compare(StringUtil.toLowerCase(myPath), StringUtil.toLowerCase(o.myPath));
//   }
// }
// 
// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/errors/VmwareCheckedCloudException.java
// public class VmwareCheckedCloudException extends CheckedCloudException {
// 
//   public VmwareCheckedCloudException(final Throwable cause) {
//     super(cause.getMessage(), cause);
//   }
// 
//   public VmwareCheckedCloudException(final String message) {
//     super(message);
//   }
// 
//   public VmwareCheckedCloudException(final String message, final Throwable cause) {
//     super(message, cause);
//   }
// 
// }


import com.intellij.openapi.util.Pair;
import com.vmware.vim25.*;
import com.vmware.vim25.mo.Datacenter;
import com.vmware.vim25.mo.Folder;
import com.vmware.vim25.mo.ManagedEntity;
import com.vmware.vim25.mo.ResourcePool;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jetbrains.buildServer.BaseTestCase;
import jetbrains.buildServer.clouds.vmware.connector.beans.ResourcePoolBean;
import jetbrains.buildServer.clouds.vmware.errors.VmwareCheckedCloudException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jmock.Mockery;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
  }

  public void allow_same_respool_names() throws Exception{
    final VMWareApiConnector connector = new VMWareApiConnectorImpl(new URL("http://localhost:9999"), "username", "pwd", null, null, null, null){


      private final Map<String, ManagedEntity> myEntitiesMap = new HashMap<>();

      private final Datacenter myDc = new Datacenter(null, null){
        @Override
        public ManagedObjectReference getMOR() {
          ManagedObjectReference mor = new ManagedObjectReference();
          mor.setType("Datacenter");
          mor.setVal("datacenter-2");
          return mor;
        }
      };

      {
        myEntitiesMap.put("datacenter-2", myDc);
        final Folder folder = createEntity(Folder.class, null, "group-v1", "MyFolder");
        myEntitiesMap.put("group-v1", folder);
        final ResourcePool respool2 = createEntity(ResourcePool.class, folder, "resgroup-2", "MyRespool");
        myEntitiesMap.put("resgroup-2", respool2);
        final ResourcePool respool3 = createEntity(ResourcePool.class, folder, "resgroup-3", "MyRespool");
        myEntitiesMap.put("resgroup-3", respool3);
      }


      @Override
// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/connector/beans/ResourcePoolBean.java
// public class ResourcePoolBean implements VmwareManagedEntity, Comparable<ResourcePoolBean> {
//   private final String myName;
//   private final ManagedObjectReference myMOR;
//   private final String myPath;
//   private final ManagedObjectReference myParentRef;
//   private final String myDatacenterId;
// 
// 
//   @Used("Tests")
//   public ResourcePoolBean(final ResourcePool rp){
//     this(rp.getMOR(), rp.getName(), null, rp.getParent().getMOR(), "dc");
//   }
// 
//   public ResourcePoolBean(@NotNull final ManagedObjectReference mor,
//                           @NotNull final String name,
//                           @NotNull final String path,
//                           @Nullable final ManagedObjectReference parentRef,
//                           @Nullable final String datacenterId) {
//     myName = name;
//     myMOR = mor;
//     myPath = path;
//     myParentRef = parentRef;
//     myDatacenterId = datacenterId;
//   }
// 
//   @NotNull
//   @Override
//   public String getId() {
//     return myMOR.getVal();
//   }
// 
//   @NotNull
//   public String getName() {
//     return myName;
//   }
// 
//   @NotNull
//   @Override
//   public String getPath() {
//     return myPath;
//   }
// 
//   @Nullable
//   @Override
//   public String getDatacenterId() {
//     return myDatacenterId;
//   }
// 
//   @NotNull
//   @Override
//   public ManagedObjectReference getMOR() {
//     return myMOR;
//   }
// 
//   @Nullable
//   @Override
//   public ManagedObjectReference getParentMOR() {
//     return myParentRef;
//   }
// 
//   @Override
//   public int compareTo(@NotNull final ResourcePoolBean o) {
//     if (myPath == null && o.myPath == null){
//       return StringUtil.compare(StringUtil.toLowerCase(myName), StringUtil.toLowerCase(o.myName));
//     }
//     return StringUtil.compare(StringUtil.toLowerCase(myPath), StringUtil.toLowerCase(o.myPath));
//   }
// }
// 
// Path: cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/errors/VmwareCheckedCloudException.java
// public class VmwareCheckedCloudException extends CheckedCloudException {
// 
//   public VmwareCheckedCloudException(final Throwable cause) {
//     super(cause.getMessage(), cause);
//   }
// 
//   public VmwareCheckedCloudException(final String message) {
//     super(message);
//   }
// 
//   public VmwareCheckedCloudException(final String message, final Throwable cause) {
//     super(message, cause);
//   }
// 
// }


// Path: cloud-vmware-server/src/test/java/jetbrains/buildServer/clouds/vmware/connector/VmwareApiConnectorTest.java
import com.intellij.openapi.util.Pair;
import com.vmware.vim25.*;
import com.vmware.vim25.mo.Datacenter;
import com.vmware.vim25.mo.Folder;
import com.vmware.vim25.mo.ManagedEntity;
import com.vmware.vim25.mo.ResourcePool;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jetbrains.buildServer.BaseTestCase;
import jetbrains.buildServer.clouds.vmware.connector.beans.ResourcePoolBean;
import jetbrains.buildServer.clouds.vmware.errors.VmwareCheckedCloudException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jmock.Mockery;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

  }

  public void allow_same_respool_names() throws Exception{
    final VMWareApiConnector connector = new VMWareApiConnectorImpl(new URL("http://localhost:9999"), "username", "pwd", null, null, null, null){


      private final Map<String, ManagedEntity> myEntitiesMap = new HashMap<>();

      private final Datacenter myDc = new Datacenter(null, null){
        @Override
        public ManagedObjectReference getMOR() {
          ManagedObjectReference mor = new ManagedObjectReference();
          mor.setType("Datacenter");
          mor.setVal("datacenter-2");
          return mor;
        }
      };

      {
        myEntitiesMap.put("datacenter-2", myDc);
        final Folder folder = createEntity(Folder.class, null, "group-v1", "MyFolder");
        myEntitiesMap.put("group-v1", folder);
        final ResourcePool respool2 = createEntity(ResourcePool.class, folder, "resgroup-2", "MyRespool");
        myEntitiesMap.put("resgroup-2", respool2);
        final ResourcePool respool3 = createEntity(ResourcePool.class, folder, "resgroup-3", "MyRespool");
        myEntitiesMap.put("resgroup-3", respool3);
      }


      @Override
      protected <T extends ManagedEntity> Collection<T> findAllEntitiesOld(final Class<T> instanceType) throws VmwareCheckedCloudException {