@Test public void assertGetAllFailoverTasksWithoutRootNode() { when(regCenter.isExisted(FailoverNode.ROOT)).thenReturn(false); assertTrue(failoverService.getAllFailoverTasks().isEmpty()); verify(regCenter).isExisted(FailoverNode.ROOT); }
public Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks() { if (!regCenter.isExisted(FailoverNode.ROOT)) { return Collections.emptyMap(); } List<String> jobNames = regCenter.getChildrenKeys(FailoverNode.ROOT); Map<String, Collection<FailoverTaskInfo>> result = new HashMap<>(jobNames.size(), 1); for (String each : jobNames) { Collection<FailoverTaskInfo> failoverTasks = getFailoverTasks(each); if (!failoverTasks.isEmpty()) { result.put(each, failoverTasks); } } return result; }
FailoverService { public Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks() { if (!regCenter.isExisted(FailoverNode.ROOT)) { return Collections.emptyMap(); } List<String> jobNames = regCenter.getChildrenKeys(FailoverNode.ROOT); Map<String, Collection<FailoverTaskInfo>> result = new HashMap<>(jobNames.size(), 1); for (String each : jobNames) { Collection<FailoverTaskInfo> failoverTasks = getFailoverTasks(each); if (!failoverTasks.isEmpty()) { result.put(each, failoverTasks); } } return result; } }
FailoverService { public Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks() { if (!regCenter.isExisted(FailoverNode.ROOT)) { return Collections.emptyMap(); } List<String> jobNames = regCenter.getChildrenKeys(FailoverNode.ROOT); Map<String, Collection<FailoverTaskInfo>> result = new HashMap<>(jobNames.size(), 1); for (String each : jobNames) { Collection<FailoverTaskInfo> failoverTasks = getFailoverTasks(each); if (!failoverTasks.isEmpty()) { result.put(each, failoverTasks); } } return result; } FailoverService(final CoordinatorRegistryCenter regCenter); }
FailoverService { public Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks() { if (!regCenter.isExisted(FailoverNode.ROOT)) { return Collections.emptyMap(); } List<String> jobNames = regCenter.getChildrenKeys(FailoverNode.ROOT); Map<String, Collection<FailoverTaskInfo>> result = new HashMap<>(jobNames.size(), 1); for (String each : jobNames) { Collection<FailoverTaskInfo> failoverTasks = getFailoverTasks(each); if (!failoverTasks.isEmpty()) { result.put(each, failoverTasks); } } return result; } FailoverService(final CoordinatorRegistryCenter regCenter); void add(final TaskContext taskContext); Collection<JobContext> getAllEligibleJobContexts(); void remove(final Collection<MetaInfo> metaInfoList); Optional<String> getTaskId(final MetaInfo metaInfo); Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks(); }
FailoverService { public Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks() { if (!regCenter.isExisted(FailoverNode.ROOT)) { return Collections.emptyMap(); } List<String> jobNames = regCenter.getChildrenKeys(FailoverNode.ROOT); Map<String, Collection<FailoverTaskInfo>> result = new HashMap<>(jobNames.size(), 1); for (String each : jobNames) { Collection<FailoverTaskInfo> failoverTasks = getFailoverTasks(each); if (!failoverTasks.isEmpty()) { result.put(each, failoverTasks); } } return result; } FailoverService(final CoordinatorRegistryCenter regCenter); void add(final TaskContext taskContext); Collection<JobContext> getAllEligibleJobContexts(); void remove(final Collection<MetaInfo> metaInfoList); Optional<String> getTaskId(final MetaInfo metaInfo); Map<String, Collection<FailoverTaskInfo>> getAllFailoverTasks();  }