ImageComparatorFactory { public ImageComparator<? extends ComparisonParameters> getImageComparator(CompareOption[] options) { if (options != null && options.length > 0) { for (CompareOption option : options) { if (option.getType() == CompareOptionType.IGNORE_CLEAR_PIXELS) { return new IgnoringClearPixelsImageComparator(); } if (option.getType() == CompareOptionType.DEFAULT) { return new DefaultImageComparator((DefaultComparisonParameters) option.getParameters()); } if (option.getType() == CompareOptionType.SIMILARITY) { return new SimilarityImageComparator((SimilarityComparisonParameters) option.getParameters()); } if (option.getType() == CompareOptionType.CATEGORY) { return new CategoryImageComparator((CategoryComparisonParameters) option.getParameters()); } } } return new DefaultImageComparator(); } private  ImageComparatorFactory(); static ImageComparatorFactory getInstance(); ImageComparator<? extends ComparisonParameters> getImageComparator(CompareOption[] options);  }
@Test public void compareOptionがnullの場合はデフォルト() throws Exception { ImageComparator<? extends ComparisonParameters> actual = instance.getImageComparator(null); assertTrue(actual instanceof DefaultImageComparator); }
@Test public void compareOptionの要素数が0の場合はデフォルト() throws Exception { ImageComparator<? extends ComparisonParameters> actual = instance.getImageComparator(new CompareOption[0]); assertTrue(actual instanceof DefaultImageComparator); }
@Test public void compareOptionIgnoreClearPixels() throws Exception { CompareOption[] options = new CompareOption[] { new CompareOption(CompareOptionType.IGNORE_CLEAR_PIXELS) }; ImageComparator<? extends ComparisonParameters> actual = instance.getImageComparator(options); assertTrue(actual instanceof IgnoringClearPixelsImageComparator); }
@Test public void compareOptionDefault() throws Exception { CompareOption[] options = new CompareOption[] { new CompareOption(CompareOptionType.DEFAULT) }; ImageComparator<? extends ComparisonParameters> actual = instance.getImageComparator(options); assertTrue(actual instanceof DefaultImageComparator); }
@Test public void compareOptionSimilarity() throws Exception { CompareOption[] options = new CompareOption[] { new CompareOption(CompareOptionType.SIMILARITY) }; ImageComparator<? extends ComparisonParameters> actual = instance.getImageComparator(options); assertTrue(actual instanceof SimilarityImageComparator); }
@Test public void compareOptionCategory() throws Exception { CompareOption[] options = new CompareOption[] { new CompareOption(CompareOptionType.CATEGORY) }; ImageComparator<? extends ComparisonParameters> actual = instance.getImageComparator(options); assertTrue(actual instanceof CategoryImageComparator); }
@Test public void compareOptions() throws Exception { CompareOption[] options = new CompareOption[] { new CompareOption(CompareOptionType.IGNORE_CLEAR_PIXELS), new CompareOption(CompareOptionType.SIMILARITY), new CompareOption(CompareOptionType.CATEGORY) }; ImageComparator<? extends ComparisonParameters> actual = instance.getImageComparator(options); assertTrue(actual instanceof IgnoringClearPixelsImageComparator); }