### Question:
ClouderaManagerPackageLocationFilter implements PackageLocationFilter { @Override public boolean filterImage(Image image, Image currentImage) { if (image == null || image.getRepo() == null || currentImage == null || StringUtils.isBlank(currentImage.getOsType())) { LOGGER.debug("Image or repo is null: {}", image); return false; } else { String repoUrl = image.getRepo().getOrDefault(currentImage.getOsType(), ""); LOGGER.debug("Matching URL: [{}]", repoUrl); return URL_PATTERN.matcher(repoUrl).find(); } }  @Override boolean filterImage(Image image, Image currentImage);  }### Answer:
@Test public void testImageNull() { boolean result = underTest.filterImage(null, mock(Image.class)); assertFalse(result); }
@Test public void testRepoNull() { boolean result = underTest.filterImage(mock(Image.class), mock(Image.class)); assertFalse(result); }
@Test public void testCurrentImageNull() { Image image = mock(Image.class); when(image.getRepo()).thenReturn(Map.of()); boolean result = underTest.filterImage(image, null); assertFalse(result); }
@Test public void testCurrentImageOsTypeEmpty() { Image image = mock(Image.class); when(image.getRepo()).thenReturn(Map.of()); Image currentImage = mock(Image.class); when(currentImage.getOsType()).thenReturn(" "); boolean result = underTest.filterImage(image, currentImage); assertFalse(result); }
@Test public void testOsTypeMissing() { Image image = mock(Image.class); when(image.getRepo()).thenReturn(Map.of()); Image currentImage = mock(Image.class); when(currentImage.getOsType()).thenReturn("redhat7"); boolean result = underTest.filterImage(image, currentImage); assertFalse(result); }
@Test public void testNotMatching() { Image image = mock(Image.class); when(image.getRepo()).thenReturn(Map.of("redhat7", "http: Image currentImage = mock(Image.class); when(currentImage.getOsType()).thenReturn("redhat7"); boolean result = underTest.filterImage(image, currentImage); assertFalse(result); }
@Test public void testMatching() { Image image = mock(Image.class); when(image.getRepo()).thenReturn(Map.of("redhat7", "http: Image currentImage = mock(Image.class); when(currentImage.getOsType()).thenReturn("redhat7"); boolean result = underTest.filterImage(image, currentImage); assertTrue(result); }