@Test public void validateSpaceNotWithinThreshold() throws Exception { AddVmCommand<AddVmParameters> command = setupCanAddVmTests(0); doReturn( new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN)) .when(storageDomainValidator) .isDomainWithinThresholds(); doReturn(storageDomainValidator) .when(command) .createStorageDomainValidator(any(StorageDomain.class)); assertFalse(command.validateSpaceRequirements()); }
@Test public void validateSpaceAndThreshold() { AddVmCommand<AddVmParameters> command = setupCanAddVmTests(0); doReturn(ValidationResult.VALID).when(storageDomainValidator).isDomainWithinThresholds(); doReturn(ValidationResult.VALID).when(storageDomainValidator).hasSpaceForNewDisks(anyList()); doReturn(storageDomainValidator) .when(command) .createStorageDomainValidator(any(StorageDomain.class)); assertTrue(command.validateSpaceRequirements()); verify(storageDomainValidator, times(TOTAL_NUM_DOMAINS)).hasSpaceForNewDisks(anyList()); verify(storageDomainValidator, never()).hasSpaceForClonedDisks(anyList()); }