@Test public void testValidProduct() { boolean result = _productValidator.isValid(M_product); assertEquals(true, result); verifyNoMoreInteractions(S_logger); }
@Test public void testThatVerificationFailsIfProductHasNoGeoCoding() { PowerMockito.when(M_product.getGeoCoding()).thenReturn(null); boolean result = _productValidator.isValid(M_product); assertEquals(false, result); verify(S_logger, times(1)) .info("Product skipped. The product 'ProductMock' does not contain a geo coding."); }
@Test public void testThatVerificationFailsIfTheProductDoesNotIntersectTheTargetArea() { PowerMockito.when(Utils.createProductArea(any(Product.class))).thenReturn(_nonIntersectingArea); boolean result = _productValidator.isValid(M_product); assertEquals(false, result); verify(S_logger, times(1)) .info("Product skipped. The product 'ProductMock' does not intersect the target product."); }
@Test public void testThatVerificationFailsIfTheProductCanNotHandleTheBandConfiguration() { PowerMockito.when(M_product.containsBand(sourceBandName)).thenReturn(false); boolean result = _productValidator.isValid(M_product); assertEquals(false, result); verify(S_logger, times(1)) .info("Product skipped. The product 'ProductMock' does not contain the band 'sbn'."); }
@Test public void testThatVerificationFailsIfTheProductDoesNotContainAnEndTime() { PowerMockito.when(M_product.getEndTime()).thenReturn(null); boolean result = _productValidator.isValid(M_product); assertEquals(false, result); verify(S_logger, times(1)) .info("Product skipped. The product 'ProductMock' must contain start and end time."); }
@Test public void testThatVerificationFailsIfTheGeoCodingCanNotGetPixelPositionFromGeoPos() { PowerMockito.when(M_geoCoding.canGetPixelPos()).thenReturn(false); boolean result = _productValidator.isValid(M_product); assertEquals(false, result); verify(S_logger, times(1)) .info( "Product skipped. The geo-coding of the product 'ProductMock' can not determine the pixel position from a geodetic position."); }
/** * @param claudiaData * @param tierDto * @throws InfrastructureException * @throws QuotaExceededException * @throws InvalidEntityException * @throws InvalidEnvironmentInstanceException */ private void validateCreateTier(ClaudiaData claudiaData, TierDto tierDto) throws InfrastructureException, QuotaExceededException, InvalidEntityException, InvalidEnvironmentInstanceException { resourceValidator.validateName(tierDto.getName()); validataDefaultTier(tierDto); productValidator.validateAttributes(tierDto); validateSecurityGroups(claudiaData, tierDto); }
@Test public void testThatVerificationFailsIfTheProductEndsAfterTimeRange() { final long timeRangeEndTime = _timeRangeEnd.getAsDate().getTime(); final Date afterTime = new Date(timeRangeEndTime + 1000); PowerMockito.when(M_product.getEndTime()).thenReturn(ProductData.UTC.create(afterTime, 0)); boolean result = _productValidator.isValid(M_product); assertEquals(false, result); verify(S_logger, times(1)) .info( "Product skipped. The product 'ProductMock' is not inside the date range from 21-MAY-2012 00:00:00.000000 to 08-JUL-2012 00:00:00.000000"); }
/** * Validate the request to create an abstract. * * @param tierDto The tier data. * @param environmentName The name of the environment. * @throws InvalidEntityException * @throws AlreadyExistEntityException * @throws InvalidEnvironmentInstanceException */ public void validateCreateAbstract(TierDto tierDto, String environmentName) throws InvalidEntityException, AlreadyExistEntityException, InvalidEnvironmentInstanceException { try { tierManager.load(tierDto.getName(), "", environmentName); log.error("The tier " + tierDto.getName() + " already exists in "); throw new AlreadyExistEntityException( "The tier " + tierDto.getName() + " already exists in environment" + environmentName); } catch (EntityNotFoundException e) { log.debug("Entity not found. It is possible to create it "); resourceValidator.validateName(tierDto.getName()); validataDefaultTier(tierDto); productValidator.validateAttributes(tierDto); } }