@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."); }
@Before public void setUp() throws Exception { sourceBandName = "sbn"; _timeRangeStart = ProductData.UTC.parse("2012-05-21 00:00:00", TemporalPercentileOp.DATETIME_PATTERN); _timeRangeEnd = ProductData.UTC.parse("2012-07-08 00:00:00", TemporalPercentileOp.DATETIME_PATTERN); Area targetArea = new Area(new Rectangle(9, 51, 20, 15)); Area intersectingArea = new Area(new Rectangle(3, 45, 20, 15)); _nonIntersectingArea = new Area(new Rectangle(3, 45, 2, 1)); PowerMockito.mockStatic(Utils.class); PowerMockito.when(Utils.createProductArea(any(Product.class))).thenReturn(intersectingArea); final Logger logger = Logger.getAnonymousLogger(); S_logger = PowerMockito.spy(logger); _productValidator = new ProductValidator( sourceBandName, null, null, _timeRangeStart, _timeRangeEnd, targetArea, S_logger); M_geoCoding = PowerMockito.mock(GeoCoding.class); PowerMockito.when(M_geoCoding.canGetPixelPos()).thenReturn(true); final ProductData.UTC productStartTime = ProductData.UTC.parse("2012-05-22 00:00:00", TemporalPercentileOp.DATETIME_PATTERN); final ProductData.UTC productEndTime = ProductData.UTC.parse("2012-07-07 00:00:00", TemporalPercentileOp.DATETIME_PATTERN); M_product = PowerMockito.mock(Product.class); PowerMockito.when(M_product.getName()).thenReturn("ProductMock"); PowerMockito.when(M_product.getGeoCoding()).thenReturn(M_geoCoding); PowerMockito.when(M_product.getStartTime()).thenReturn(productStartTime); PowerMockito.when(M_product.getEndTime()).thenReturn(productEndTime); PowerMockito.when(M_product.containsBand(sourceBandName)).thenReturn(true); }