### Question:
ComponentBuildNumberComparator { boolean compare(Image currentImage, Image newImage, String buildNumberKey) { Optional<String> currentVersion = getBuildVersion(currentImage, buildNumberKey); Optional<String> newVersion = getBuildVersion(newImage, buildNumberKey); return currentVersion.isPresent() && newVersion.isPresent() && compare(currentVersion, newVersion); }    }### Answer:
@Test public void testCompareShouldReturnFalseWhenTheCurrentIsGreaterThanTheNewBuildNumber() { Image currentImage = createImage("1234"); Image newImage = createImage("1233"); boolean actual = underTest.compare(currentImage, newImage, BUILD_NUMBER_KEY); assertFalse(actual); }
@Test public void testCompareShouldReturnTrueWhenTheCurrentIsLowerThanTheNewBuildNumber() { Image currentImage = createImage("1233"); Image newImage = createImage("1234"); boolean actual = underTest.compare(currentImage, newImage, BUILD_NUMBER_KEY); assertTrue(actual); }
@Test public void testCompareShouldReturnTrueWhenTheCurrentIsEqualWithTheNewBuildNumber() { Image currentImage = createImage("1234"); Image newImage = createImage("1234"); boolean actual = underTest.compare(currentImage, newImage, BUILD_NUMBER_KEY); assertTrue(actual); }
@Test public void testCompareShouldReturnFalseWhenTheCurrentBuildNumberIsNotPresent() { Image currentImage = createImage(null); Image newImage = createImage("1234"); boolean actual = underTest.compare(currentImage, newImage, BUILD_NUMBER_KEY); assertFalse(actual); }
@Test public void testCompareShouldReturnFalseWhenTheNewBuildNumberIsNotPresent() { Image currentImage = createImage("1234"); Image newImage = createImage(null); boolean actual = underTest.compare(currentImage, newImage, BUILD_NUMBER_KEY); assertFalse(actual); }