### Question:
StackVersionMatcher { public boolean isMatchingStackVersion(Image image, Map<String, String> activatedParcels) { String stackVersion = activatedParcels.get(StackType.CDH.name()); return StringUtils.isEmpty(stackVersion) || isStackVersionEquals(image, stackVersion); }  boolean isMatchingStackVersion(Image image, Map<String, String> activatedParcels);  }### Answer:
@Test public void testMissingCdhVersion() { boolean result = underTest.isMatchingStackVersion(image, Map.of()); assertTrue(result); }
@Test public void testMissingStackDetails() { boolean result = underTest.isMatchingStackVersion(image, ACTIVATED_PARCELS); assertTrue(result); }
@Test public void testMissingStackRepoDetails() { when(image.getStackDetails()).thenReturn(new StackDetails("ver", null, "build")); boolean result = underTest.isMatchingStackVersion(image, ACTIVATED_PARCELS); assertTrue(result); }
@Test public void testMissingStackInStackRepoDetails() { when(image.getStackDetails()).thenReturn(new StackDetails("ver", new StackRepoDetails(null, null), "build")); boolean result = underTest.isMatchingStackVersion(image, ACTIVATED_PARCELS); assertTrue(result); }
@Test public void testEmptyStackInStackRepoDetails() { when(image.getStackDetails()).thenReturn(new StackDetails("ver", new StackRepoDetails(Map.of(), null), "build")); boolean result = underTest.isMatchingStackVersion(image, ACTIVATED_PARCELS); assertTrue(result); }
@Test public void testUnrelatedStackInStackRepoDetails() { when(image.getStackDetails()).thenReturn(new StackDetails("ver", new StackRepoDetails(Map.of("TEST", "DUMMY"), null), "build")); boolean result = underTest.isMatchingStackVersion(image, ACTIVATED_PARCELS); assertTrue(result); }
@Test public void testVersionMatch() { when(image.getStackDetails()).thenReturn(new StackDetails("ver", new StackRepoDetails(Map.of(REPOSITORY_VERSION, "CDHVER"), null), "build")); boolean result = underTest.isMatchingStackVersion(image, ACTIVATED_PARCELS); assertTrue(result); }
@Test public void testVersionNotMatch() { when(image.getStackDetails()).thenReturn(new StackDetails("ver", new StackRepoDetails(Map.of(REPOSITORY_VERSION, "CDHDIFFERENTVER"), null), "build")); boolean result = underTest.isMatchingStackVersion(image, ACTIVATED_PARCELS); assertFalse(result); }