### Question:
UiInstanceService { public UiResponse findExpiredInstance(HttpServletRequest request, Map parameterMap) { Map<String, AppEntity> appMap=appService.getCacheData(); UiResponse uiResponse = new UiResponse(); Long count; List<CombinedInstanceDto> instanceList; count = uiInstanceRepository.expiredCount(parameterMap); instanceList = uiInstanceRepository.findExpiredBy(parameterMap); for (CombinedInstanceDto combinedInstanceDto : instanceList) { combinedInstanceDto.setRole(uiUserService.getRole(appMap.get(combinedInstanceDto.getCandAppId()))); setFinalStatus(combinedInstanceDto); } return UiResponseHelper.setUiResponse(uiResponse, count, instanceList); }  UiResponse findInstance(HttpServletRequest request, Map parameterMap); UiResponse findExpiredInstance(HttpServletRequest request, Map parameterMap); UiResponse deleteById(long instanceId); UiResponse findByInstanceId(HttpServletRequest request, String instanceId); void setFinalStatus(CombinedInstanceDto combinedInstanceDto); @Transactional(rollbackFor = Exception.class) String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId); @Transactional(rollbackFor = Exception.class) String updatePublishStatus(HttpServletRequest request, String pubStatus, long instanceId); List<String> getAllSdkVersion();  }### Answer:
@Test public void testFindExpiredInstance() throws Exception{ RegisterInstanceRequest registerInstanceRequest = RegisterInstanceUtil.setRegisterInstanceRequest(); RegisterInstanceResponse response = instanceService.registerInstance(registerInstanceRequest); Thread.sleep(2 * 1000); InstanceEntity testInstanceEntity = RegisterInstanceUtil.createTestInstanceEntity(); HttpServletRequest request = new MockHttpServletRequest(); Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(); parameterMap = setParameterMap(parameterMap); long lastNoActiveTime = System.currentTimeMillis() - 60 * 1000; parameterMap.put("lastNoActiveTime", formatter.format(new Date(lastNoActiveTime))); parameterMap.put("statusSelect", 10); InstanceEntity instanceEntity = instanceService.findByCandInstanceId("w545878765"); Assert.assertEquals(testInstanceEntity.getAppClusterName(), instanceEntity.getAppClusterName()); Assert.assertEquals(testInstanceEntity.getCandAppId(), instanceEntity.getCandAppId()); instanceService.updateHeartStatus(Lists.newArrayList(instanceEntity), false, 1); Assert.assertEquals(0, instanceService.findByCandInstanceId("w545878765").getHeartStatus()); CombinedInstanceDto combinedInstanceDto = (CombinedInstanceDto) uiInstanceService.findExpiredInstance(request, parameterMap).getData().get(0); Assert.assertEquals(testInstanceEntity.getAppClusterName(), combinedInstanceDto.getAppClusterName()); Assert.assertEquals(testInstanceEntity.getCandAppId(), combinedInstanceDto.getCandAppId()); deRegister(combinedInstanceDto.getId()); }