EurekaSyncToNacosServiceImpl implements SyncService { @Override public boolean delete(TaskDO taskDO) { try { specialSyncEventBus.unsubscribe(taskDO); EurekaNamingService eurekaNamingService = eurekaServerHolder.get(taskDO.getSourceClusterId(), null); NamingService destNamingService = nacosServerHolder.get(taskDO.getDestClusterId(), null); List<InstanceInfo> eurekaInstances = eurekaNamingService.getApplications(taskDO.getServiceName()); deleteAllInstanceFromEureka(taskDO, destNamingService, eurekaInstances); } catch (Exception e) { log.error("delete a task from eureka to nacos was failed, taskId:{}", taskDO.getTaskId(), e); metricsManager.recordError(MetricsStatisticsType.DELETE_ERROR); return false; } return true; } @Autowired  EurekaSyncToNacosServiceImpl(EurekaServerHolder eurekaServerHolder,
        SkyWalkerCacheServices skyWalkerCacheServices, NacosServerHolder nacosServerHolder,
        SpecialSyncEventBus specialSyncEventBus, MetricsManager metricsManager); @Override boolean delete(TaskDO taskDO); @Override boolean sync(TaskDO taskDO);  }
@Test public void testEurekaDeleteSyncToNacos() throws Exception { TaskDO taskDO = mock(TaskDO.class); mockDelete(taskDO); Assert.assertTrue(eurekaSyncToNacosService.delete(taskDO)); }
@Test(expected = Exception.class) public void testEurekaDeleteToNacosWithException() throws Exception { Assert.assertFalse(eurekaSyncToNacosService.delete(null)); }