### Question:
FreeIpaCleanupService { public void cleanupOnRecover(Stack stack, Set<String> hostNames, Set<String> ips) { validateCleanupParametersSet(hostNames, ips); LOGGER.info("Cleanup on recover invoked with hostnames {} and IPs {}", hostNames, ips); cleanup(stack, STEPS_TO_SKIP_ON_RECOVER, hostNames, ips); }  void cleanup(Stack stack); void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips); void cleanupOnRecover(Stack stack, Set<String> hostNames, Set<String> ips); void cleanupDnsOnly(Stack stack, Set<String> hostNames, Set<String> ips);  }### Answer:
@Test public void testCleanupOnRecover() { Stack stack = spy(aStack()); Optional<KerberosConfig> kerberosConfig = Optional.of(mock(KerberosConfig.class)); when(kerberosConfigService.get(ENVIRONMENT_CRN, STACK_NAME)).thenReturn(kerberosConfig); when(environmentConfigProvider.isChildEnvironment(ENVIRONMENT_CRN)).thenReturn(false); when(kerberosDetailService.keytabsShouldBeUpdated(CLOUD_PLATFORM, false, kerberosConfig)).thenReturn(true); OperationStatus operationStatus = new OperationStatus("opId", OperationType.CLEANUP, null, null, null, null, 0L, null); ArgumentCaptor<CleanupRequest> captor = ArgumentCaptor.forClass(CleanupRequest.class); when(freeIpaV1Endpoint.internalCleanup(captor.capture(), anyString())).thenReturn(operationStatus); when(freeIpaOperationChecker.pollWithAbsoluteTimeout(any(), any(), anyLong(), anyLong(), anyInt())).thenReturn(pollingResult); victim.cleanupOnRecover(stack, Set.of("asdf", "qwer"), Set.of("1.1.1.1", "1.1.1.2")); CleanupRequest cleanupRequest = captor.getValue(); assertEquals(STACK_NAME, cleanupRequest.getClusterName()); assertEquals(ENVIRONMENT_CRN, cleanupRequest.getEnvironmentCrn()); assertEquals(Set.of(REMOVE_HOSTS, REMOVE_VAULT_ENTRIES, REMOVE_USERS, REMOVE_ROLES), cleanupRequest.getCleanupStepsToSkip()); assertEquals(Set.of(KERBEROS_USER_PREFIX + stack.getName(), KEYTAB_USER_PREFIX + stack.getName(), LDAP_USER_PREFIX + stack.getName()), cleanupRequest.getUsers()); assertEquals(Set.of(ROLE_NAME_PREFIX + stack.getName()), cleanupRequest.getRoles()); assertEquals(Set.of("1.1.1.1", "1.1.1.2"), cleanupRequest.getIps()); assertEquals(Set.of("asdf", "qwer"), cleanupRequest.getHosts()); }