CheckEqualSizePreprocessor implements Preprocessor { @Override public void process() { if (img1.getWidth() != img2.getWidth() || img1.getHeight() != img2.getHeight()) { throw new PreprocessingException("Image size does not match"); } LOGGER.debug("Images have the same widht [{}] and height [{}]", img1.getWidth(), img1.getHeight()); } CheckEqualSizePreprocessor(final BufferedImage img1, final BufferedImage img2); @Override void process(); @Override BufferedImage getResult1(); @Override BufferedImage getResult2();  }
@Test public void executeTest_equalSize() { BufferedImage img1 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0)); BufferedImage img2 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0)); CheckEqualSizePreprocessor pp = new CheckEqualSizePreprocessor(img1, img2); pp.process(); }
@Test(expected = PreprocessingException.class) public void executeTest_equalWidth_diffHeight() { BufferedImage img1 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 500, 500); BufferedImage img2 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 500, 200); CheckEqualSizePreprocessor pp = new CheckEqualSizePreprocessor(img1, img2); pp.process(); }
@Test(expected = PreprocessingException.class) public void executeTest_diffWidth_equalHeight() { BufferedImage img1 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 200, 500); BufferedImage img2 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 500, 500); CheckEqualSizePreprocessor pp = new CheckEqualSizePreprocessor(img1, img2); pp.process(); }
@Test(expected = PreprocessingException.class) public void executeTest_diffWidth_diffHeight() { BufferedImage img1 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 200, 500); BufferedImage img2 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 500, 200); CheckEqualSizePreprocessor pp = new CheckEqualSizePreprocessor(img1, img2); pp.process(); }