### Question:
AspectRatioSelectors { public static SelectorFunction<Collection<Size>, Size> aspectRatio(float aspectRatio, SelectorFunction<Collection<Size>, Size> selector, double tolerance) { return Selectors.filtered( selector, new AspectRatioPredicate(aspectRatio, tolerance) ); }  static SelectorFunction<Collection<Size>, Size> standardRatio(SelectorFunction<Collection<Size>, Size> selector); static SelectorFunction<Collection<Size>, Size> standardRatio(SelectorFunction<Collection<Size>, Size> selector, double tolerance); static SelectorFunction<Collection<Size>, Size> wideRatio(SelectorFunction<Collection<Size>, Size> selector); static SelectorFunction<Collection<Size>, Size> wideRatio(SelectorFunction<Collection<Size>, Size> selector, double tolerance); static SelectorFunction<Collection<Size>, Size> aspectRatio(float aspectRatio, SelectorFunction<Collection<Size>, Size> selector, double tolerance); static SelectorFunction<Collection<Size>, Size> aspectRatio(float aspectRatio,
                                                     SelectorFunction<Collection<Size>, Size> selector);  }### Answer:
@Test public void ratioWithTolerance() throws Exception { given(sizeSelector.select(ArgumentMatchers.<Size>anyCollection())) .willReturn(new Size(110, 100)); Size result = AspectRatioSelectors .aspectRatio(1.0f, sizeSelector, 0.1) .select(asList( new Size(16, 9), new Size(110, 100), new Size(105, 100), new Size(95, 100), new Size(90, 100), new Size(4, 3), new Size(20, 10) )); assertEquals( new Size(110, 100), result ); verify(sizeSelector).select(asSet( new Size(110, 100), new Size(105, 100), new Size(95, 100), new Size(90, 100) )); }
@Test public void ratioWithNegativeToleranceThrows() throws Exception { final double NEGATIVE_TOLERANCE = -0.1; final double ABOVE_RANGE_TOLERANCE = 1.1; try { AspectRatioSelectors .aspectRatio(1.0f, sizeSelector, NEGATIVE_TOLERANCE) .select(asList( new Size(16, 9), new Size(16, 10))); fail("Negative aspect ratio tolerance is illegal"); } catch (IllegalArgumentException ex) { } try { AspectRatioSelectors .aspectRatio(1.0f, sizeSelector, ABOVE_RANGE_TOLERANCE) .select(asList( new Size(16, 9), new Size(16, 10))); fail("Aspect ratio tolerance >1.0 is illegal"); } catch (IllegalArgumentException ex) { } }