ProductValidator { public boolean isValid(Product product) { return product != null && containsGeoCodingWithReverseOperationSupport(product) && fulfillsTimeConditions(product) && canHandleExpressionOrSourceBand(product) && isInDateRange(product) && intersectsTargetArea(product); } ProductValidator(String sourceBandName, String bandMathExpression, String validPixelExpression, ProductData.UTC startDate, ProductData.UTC endDate, Area targetArea, Logger logger); boolean isValid(Product product);  }
@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 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."); }
@Test public void testThatVerificationFailsIfTheProductDoesNotContainAStartTime() { PowerMockito.when(M_product.getStartTime()).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 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 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 testThatVerificationFailsIfTheProductStartsBeforeTimeRange() { final long timeRangeStartTime = _timeRangeStart.getAsDate().getTime(); final Date beforeTime = new Date(timeRangeStartTime - 1); PowerMockito.when(M_product.getStartTime()).thenReturn(ProductData.UTC.create(beforeTime, 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"); }
@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"); }
@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."); }