/** Ensures removing a VM pool works as expected. */
  @Test
  public void testRemoveVmPool() {
    dao.remove(deletableVmPool.getvm_pool_id());

    vm_pools result = dao.get(deletableVmPool.getvm_pool_id());

    assertNull(result);
  }
  /** Ensures that updating a VM pool works as expected. */
  @Test
  public void testUpdateVmPool() {
    existingVmPool.setvm_pool_description("This is an updated VM pool.");

    dao.update(existingVmPool);

    vm_pools result = dao.get(existingVmPool.getvm_pool_id());

    assertEquals(existingVmPool, result);
  }
  /** Ensures that getting a VM pool by name works as expected. */
  @Test
  public void testGetByName() {
    vm_pools result = dao.getByName(existingVmPool.getvm_pool_name());

    assertNotNull(result);
    assertEquals(existingVmPool, result);
  }
  /** Ensures that saving a VM pool works as expected. */
  @Test
  public void testSaveVmPool() {
    dao.save(newVmPool);

    vm_pools result = dao.getByName(newVmPool.getvm_pool_name());

    assertNotNull(result);
    assertEquals(newVmPool, result);
  }
  @Override
  public void setUp() throws Exception {
    super.setUp();

    dao = prepareDAO(dbFacade.getVmPoolDAO());

    existingVmPool = dao.get(EXISTING_VM_POOL_ID);
    deletableVmPool = dao.get(DELETABLE_VM_POOL_ID);

    newVmPool = new vm_pools();
    newVmPool.setvm_pool_name("New VM Pool");
    newVmPool.setvm_pool_description("This is a new VM pool.");
    newVmPool.setvds_group_id(VDS_GROUP_ID);

    existingVmPoolMap = dao.getVmPoolMapByVmGuid(new Guid("77296e00-0cad-4e5a-9299-008a7b6f4355"));
    newVmPoolMap = new vm_pool_map(FREE_VM_ID, existingVmPool.getvm_pool_id());

    existingTimeLeaseVmPoolMap =
        dao.getTimeLeasedVmPoolMapByIdForVmPool(EXISTING_LEASE_ID, EXISTING_VM_POOL_ID);
    newTimeLeaseVmPoolMap =
        new time_lease_vm_pool_map(new Date(), Guid.NewGuid(), new Date(), 1, FREE_VM_POOL_ID);
  }
    @Override
    public VdcActionParametersBase getParameters(VmPool incoming, vm_pools current) {
      int currentVmCount = current.getvm_assigned_count();
      vm_pools entity = map(incoming, current);

      VM vm = mapToVM(map(entity));

      int size =
          incoming.isSetSize() && incoming.getSize() > currentVmCount
              ? incoming.getSize() - currentVmCount
              : 0;

      if (incoming.isSetTemplate()) {
        vm.setvmt_guid(new Guid(incoming.getTemplate().getId()));
      } else {
        VM existing =
            currentVmCount > 0
                ? getEntity(VM.class, SearchType.VM, "Vms: pool=" + incoming.getName())
                : null;
        if (existing != null) {
          vm.setvmt_guid(existing.getvmt_guid());
        }
      }

      if (vm.getvmt_guid() != null) {
        VmTemplate template =
            getEntity(
                VmTemplate.class,
                VdcQueryType.GetVmTemplate,
                new GetVmTemplateParameters(vm.getvm_guid()),
                vm.getvm_guid().toString());
        vm.getStaticData().setmem_size_mb(template.getmem_size_mb());
      }

      AddVmPoolWithVmsParameters parameters = new AddVmPoolWithVmsParameters(entity, vm, size, -1);
      parameters.setStorageDomainId(getStorageDomainId(vm.getvmt_guid()));
      return parameters;
    }