### Question:
InstanceRefreshService { @Scheduled( initialDelayString = "${apiml.service-registry.cacheRefreshInitialDelayInMillis}", fixedDelayString = "${apiml.service-registry.cacheRefreshRetryDelayInMillis}") public void refreshCacheFromDiscovery() { if (!isStarted) { log.debug("InstanceRefreshService is stopped. Skip refresh."); return; } log.debug("Refreshing API Catalog with the latest state of discovery service"); Callable<Set<String>> callableTask = this::compareServices; ExecutorService executorService = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()); Future<Set<String>> future = executorService.submit(callableTask); executorService.shutdown(); try { final Set<String> containersUpdated = future.get(20, TimeUnit.SECONDS); if (containersUpdated.isEmpty()) { log.debug("No containers updated from discovered services."); } else { log.debug(containersUpdated.size() + " containers updated from discovered services."); log.debug("Catalog status updates will occur for containers: " + containersUpdated.toString()); } } catch (InterruptedException e) { log.debug("Failed to update cache with discovered services: {}", e.getMessage()); Thread.currentThread().interrupt(); } catch (ExecutionException | TimeoutException e) { apimlLog.log("org.zowe.apiml.apicatalog.cacheUpdateError", e.getMessage()); } }  void start(); @Scheduled( initialDelayString = "${apiml.service-registry.cacheRefreshInitialDelayInMillis}", fixedDelayString = "${apiml.service-registry.cacheRefreshRetryDelayInMillis}") void refreshCacheFromDiscovery();  }### Answer:
@Test public void testServiceAddedToDiscoveryThatIsNotInCache() { ContainerServiceState cachedState = containerServiceMockUtil.createContainersServicesAndInstances(); containerServiceMockUtil.mockServiceRetrievalFromCache(cachedServicesService, cachedState.getApplications()); ContainerServiceState discoveredState = new ContainerServiceState(); discoveredState.setServices(new ArrayList<>()); discoveredState.setContainers(new ArrayList<>()); discoveredState.setInstances(new ArrayList<>()); discoveredState.setApplications(new ArrayList<>()); HashMap<String, String> metadata = new HashMap<>(); metadata.put(CATALOG_ID, "api-five"); InstanceInfo newInstanceOfService5 = containerServiceMockUtil.createInstance("service5", "service5:9999", InstanceInfo.InstanceStatus.UP, InstanceInfo.ActionType.ADDED, metadata); discoveredState.getInstances().add(newInstanceOfService5); Application service5 = new Application("service5", Collections.singletonList(newInstanceOfService5)); discoveredState.getApplications().add(service5); Applications discoveredServices = new Applications("1", 1L, discoveredState.getApplications()); when(instanceRetrievalService.getAllInstancesFromDiscovery(true)).thenReturn(discoveredServices); Applications cachedServices = new Applications("1", 1L, cachedState.getApplications()); when(cachedServicesService.getAllCachedServices()).thenReturn(cachedServices); when(cachedProductFamilyService.saveContainerFromInstance("api-five", newInstanceOfService5)) .thenReturn(new APIContainer()); instanceRefreshService.refreshCacheFromDiscovery(); verify(cachedProductFamilyService, times(1)) .saveContainerFromInstance("api-five", newInstanceOfService5); }